Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Dec 2016 03:16:09 +0100
From:      Goran =?utf-8?B?TWVracSH?= <meka@tilda.center>
To:        freebsd-arm@freebsd.org
Subject:   Cross compiling error for cortex-m3 chip (was: Arduino Due)
Message-ID:  <20161230021609.dghfg4ipwcla4avr@thinker.meka.no-ip.org>

next in thread | raw e-mail | index | archive | help

--opjwieh5nrfpyus3
Content-Type: multipart/mixed; boundary="lkl2277mfdqdn5e7"
Content-Disposition: inline


--lkl2277mfdqdn5e7
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline

Hello,

I tried my best at figuring out what was wrong and this is my analysis. I have two binary files: one generated on Linux, the other on FreeBSD. Their respecive links are: http://meka.rs/Blink.ino.linux.elf and http://meka.rs/Blink.ino.freebsd.elf. I attached the output of "readelf -e <binary>" for both files. As I could see, there's .ARM.exidx section missing from the FreeBSD generated binary.

I also tried to cross compile a dumb C program with clang using this command:
cc -Os -nostdlib --target=arm-none-eabi -mcpu=cortex-m3 -Xlinker "--entry=main" -o prog prog.c

The prog.c is just "int main() {return 0;}". Using readelf on prog shows .ARM.exidx is present. Does anyone has any tip on how to continue the search for the bug?

Regards,
meka

--lkl2277mfdqdn5e7
Content-Type: text/plain; charset=utf-8
Content-Disposition: attachment; filename="readelf-freebsd.txt"
Content-Transfer-Encoding: quoted-printable

ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00=20
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            NONE
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x806d1
  Start of program headers:          52 (bytes into file)
  Start of section headers:          519320 (bytes into file)
  Flags:                             0x5000200, Version5 EABI, software FP
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         2
  Size of section headers:           40 (bytes)
  Number of section headers:         17
  Section header string table index: 14

Elf file type is EXEC (Executable file)
Entry point 0x806d1
There are 2 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x010000 0x00080000 0x00080000 0x06ea8 0x06ea8 R E 0x10000
  LOAD           0x020000 0x20070000 0x00086ea8 0x00930 0x01350 RWE 0x10000

 Section to Segment mapping:
  Segment Sections...
   00     .text=20
   01     .relocate .bss=20
There are 17 section headers, starting at offset 0x7ec98:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk I=
nf Al
  [ 0] (null)            NULL            00000000 000000 000000 00      0  =
 0  0
  [ 1] .text             PROGBITS        00080000 010000 006ea8 00  AX  0  =
 0  4
  [ 2] .relocate         REL             20070000 020000 000930 08 WAX  0  =
 0  8
  [ 3] .bss              NOBITS          20070930 020930 000a20 00  WA  0  =
 0  4
  [ 4] .ARM.attributes   LOPROC+0x3      00000000 020930 000031 00      0  =
 0  1
  [ 5] .comment          PROGBITS        00000000 020961 0000dc 01  MS  0  =
 0  1
  [ 6] .debug_info       PROGBITS        00000000 020a3d 032c4c 00      0  =
 0  1
  [ 7] .debug_abbrev     PROGBITS        00000000 053689 008c19 00      0  =
 0  1
  [ 8] .debug_aranges    PROGBITS        00000000 05c2a8 000b80 00      0  =
 0  8
  [ 9] .debug_ranges     PROGBITS        00000000 05ce28 000ef0 00      0  =
 0  1
  [10] .debug_line       PROGBITS        00000000 05dd18 009668 00      0  =
 0  1
  [11] .debug_str        PROGBITS        00000000 067380 0063f8 01  MS  0  =
 0  1
  [12] .debug_frame      PROGBITS        00000000 06d778 001d88 00      0  =
 0  4
  [13] .debug_loc        PROGBITS        00000000 06f500 00a47b 00      0  =
 0  1
  [14] .shstrtab         STRTAB          00000000 07ebe6 0000af 00      0  =
 0  1
  [15] .symtab           SYMTAB          00000000 07997c 0039b0 10     16 6=
03  4
  [16] .strtab           STRTAB          00000000 07d32c 0018ba 00      0  =
 0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

--lkl2277mfdqdn5e7
Content-Type: text/plain; charset=utf-8
Content-Disposition: attachment; filename="readelf-linux.txt"
Content-Transfer-Encoding: quoted-printable

ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00=20
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            NONE
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x80625
  Start of program headers:          52 (bytes into file)
  Start of section headers:          223156 (bytes into file)
  Flags:                             0x5000002, Version5 EABI, has entry po=
int
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         3
  Size of section headers:           40 (bytes)
  Number of section headers:         18
  Section header string table index: 15

Elf file type is EXEC (Executable file)
Entry point 0x80625
There are 3 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOPROC+0x1     0x00d66c 0x0008566c 0x0008566c 0x00008 0x00008 R   0x4
  LOAD           0x008000 0x00080000 0x00080000 0x05674 0x05674 R E 0x8000
  LOAD           0x010000 0x20070000 0x00085674 0x008d4 0x012fc RWE 0x8000

 Section to Segment mapping:
  Segment Sections...
   00     .ARM.exidx=20
   01     .text .ARM.exidx=20
   02     .relocate .bss=20
There are 18 section headers, starting at offset 0x367b4:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk I=
nf Al
  [ 0] (null)            NULL            00000000 000000 000000 00      0  =
 0  0
  [ 1] .text             PROGBITS        00080000 008000 00566c 00  AX  0  =
 0  8
  [ 2] .ARM.exidx        LOPROC+0x1      0008566c 00d66c 000008 00   A  1  =
 0  4
  [ 3] .relocate         REL             20070000 010000 0008d4 08 WAX  0  =
 0  8
  [ 4] .bss              NOBITS          200708d4 0108d4 000a28 00  WA  0  =
 0  4
  [ 5] .ARM.attributes   LOPROC+0x3      00000000 0108d4 000029 00      0  =
 0  1
  [ 6] .comment          PROGBITS        00000000 0108fd 0000f0 01  MS  0  =
 0  1
  [ 7] .debug_info       PROGBITS        00000000 0109ed 0124f7 00      0  =
 0  1
  [ 8] .debug_abbrev     PROGBITS        00000000 022ee4 003432 00      0  =
 0  1
  [ 9] .debug_aranges    PROGBITS        00000000 026316 0006d0 00      0  =
 0  1
  [10] .debug_ranges     PROGBITS        00000000 0269e6 000940 00      0  =
 0  1
  [11] .debug_line       PROGBITS        00000000 027326 0051ec 00      0  =
 0  1
  [12] .debug_str        PROGBITS        00000000 02c512 004c58 01  MS  0  =
 0  1
  [13] .debug_frame      PROGBITS        00000000 03116c 0019fc 00      0  =
 0  4
  [14] .debug_loc        PROGBITS        00000000 032b68 003b90 00      0  =
 0  1
  [15] .shstrtab         STRTAB          00000000 0366f8 0000ba 00      0  =
 0  1
  [16] .symtab           SYMTAB          00000000 036a84 003950 10     17 6=
15  4
  [17] .strtab           STRTAB          00000000 03a3d4 001932 00      0  =
 0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

--lkl2277mfdqdn5e7--

--opjwieh5nrfpyus3
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEE1WIFkXy2ZeMKjjKEWj1TknovrLYFAlhlw2YACgkQWj1Tknov
rLa3LA//eqBZViEnzbmsYjAKnwosxB6gU2Uzi9nbzNT4YN10Vittfxde0iyInnBe
YWnClp25fzYpAzEwPNop6/06X5pVwJHWVCPxR7hj2HdIbSlDFc+0LVlLAz6SZ16j
AkTYqYIp0WML3s/dUVN8vDcx10c70Y5cyTLKVXvvravuIzVVgiDpN18025q9SkUw
ytrNF4QCxI9xyz5v00JnUScgaHTsE9SgDFiqpA0od2tRT8rpApAQwleKNn9+CYbF
d9jLQhKvuZ//QB5h+7TseELsIMZUVukRTlgDeiklopmRpxyEGnyN3IsfTFlm2NLt
8oh+HV38yhIah0c+re+Ae4YAs2JrOA5zvK6tN1z0mldx6PtlPhbcjHwIY89c4TZh
9VKVckcJQE/YADpoZFj6YlUWx0Pm7YElg/TVvTVXJauPoMK0OOiC+jKSOjiPvNL7
yl9BHthp5gFfFLAbXkN/X9LK89XvM1eRb1ID4aJ880OZqu7WXxtU9X1QlZHTMrMA
9G5P0eEYfyJbhJLLPraga/GbRwfh1OX1jsVuhR9NHF4HDcLGI6J5redIoSF+X0WI
2rDojuPeIx6bJ+ZDF/qtk0coc4xiWvO7nHp/fHrCli6mUtGuNTgUEC0CsJG7VQlZ
T14VE1hAj7RdsbGtp3baSHzdVHBoVFgmta+7VKKRptLsCSA5Vrk=
=z+UH
-----END PGP SIGNATURE-----

--opjwieh5nrfpyus3--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20161230021609.dghfg4ipwcla4avr>