Cross compiling error for cortex-m3 chip (was: Arduino Due)

Goran Mekić meka at tilda.center
Fri Dec 30 02:16:41 UTC 2016


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
-------------- next part --------------
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  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 
   01     .relocate .bss 
There are 17 section headers, starting at offset 0x7ec98:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf 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 603  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)
-------------- next part --------------
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  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 point
  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 
   01     .text .ARM.exidx 
   02     .relocate .bss 
There are 18 section headers, starting at offset 0x367b4:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf 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 615  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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-arm/attachments/20161230/e37f0138/attachment.sig>


More information about the freebsd-arm mailing list