Cross compiling for FreeBSD/ARM on cygwin?
Matthias Reyelt
Matthias.Reyelt at brunel.de
Wed Aug 11 11:40:18 UTC 2010
Hi,
I have tried to build a cross-compiler environment for FreeBSD/ARM on cygwin.
I have built a gcc toolchain for cygwin and I can compile a test program:
------------------------------------------------------------------------------------------
./arm-unknown-freebsd8.0-gcc -c -v -Wa,-mfloat-abi=softfp,-mfpu=vfp
-Wl,--eh-frame-hdr,-X main.c
---> test.o
------------------------------------------------------------------------------------------
I can link this object file on the ARM (Marvell db-78xxx) and the resulting
binary runs fine:
------------------------------------------------------------------------------------------
ld --eh-frame-hdr -V -dynamic-linker /libexec/ld-elf.so.1 -X /usr/lib/crt1.o
/usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib -L/usr/lib -lgcc --as-needed
-lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
/usr/lib/crtend.o /usr/lib/crtn.o test.o
------------------------------------------------------------------------------------------
I haven't yet managed to do the linking under cygwin:
-------------------------------------------------------------------------------------
/usr/local/bin/arm-unknown-freebsd8.0-ld.exe --eh-frame-hdr -V
-dynamic-linker /usr/local/arm-unknown-freebsd8.0/libexec/ld-elf.so.1 -X
/usr/local/arm-unknown-freebsd8.0/lib/crt1.o
/usr/local/arm-unknown-freebsd8.0/lib/crti.o
/usr/local/arm-unknown-freebsd8.0/lib/crtbegin.o
-L/usr/local/arm-unknown-freebsd8.0/lib -lgcc --as-needed -lgcc_s
--no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
/usr/local/arm-unknown-freebsd8.0/lib/crtend.o
/usr/local/arm-unknown-freebsd8.0/lib/crtn.o test.o
------------------------------------------------------------------------------------------
When I try to run the resulting binary, I get the message:
"Exec format error. Binary not executable"
I have copied the crt1.o and the other files from the ARM target.
Any idea what is missing?
Matthias
readelf on the binary looks like this:
-------------------------------------------------------------------------------------------
ELF Header:
Magic: 7f 45 4c 46 01 01 01 61 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: ARM
ABI Version: 0
Type: EXEC (Executable file)
Machine: ARM
Version: 0x1
Entry point address: 0x8234
Start of program headers: 52 (bytes into file)
Start of section headers: 35128 (bytes into file)
Flags: 0x602, has entry point, GNU EABI,
software FP, <unknown>
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 5
Size of section headers: 40 (bytes)
Number of section headers: 28
Section header string table index: 25
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf
Al
[ 0] NULL 00000000 000000 000000 00 0 0
0
[ 1] .interp PROGBITS 00008000 008000 000036 00 A 0 0
1
[ 2] .note.ABI-tag NOTE 00008038 008038 000018 00 A 0 0
4
[ 3] .hash HASH 00008050 008050 000038 04 A 4 0
4
[ 4] .dynsym DYNSYM 00008088 008088 000090 10 A 5 1
4
[ 5] .dynstr STRTAB 00008118 008118 000058 00 A 0 0
1
[ 6] .gnu.version VERSYM 00008170 008170 000012 02 A 4 0
2
[ 7] .gnu.version_r VERNEED 00008184 008184 000020 00 A 5 1
4
[ 8] .rel.plt REL 000081a4 0081a4 000020 08 A 4 a
4
[ 9] .init PROGBITS 000081d0 0081d0 000020 00 AX 0 0
16
[10] .plt PROGBITS 000081f0 0081f0 000044 04 AX 0 0
4
[11] .text PROGBITS 00008234 008234 000254 00 AX 0 0
4
[12] .fini PROGBITS 00008490 008490 00001c 00 AX 0 0
16
[13] .rodata PROGBITS 000084ac 0084ac 000018 00 A 0 0
4
[14] .data PROGBITS 000085c4 0085c4 000014 00 WA 0 0
4
[15] .eh_frame PROGBITS 000085d8 0085d8 000004 00 A 0 0
4
[16] .dynamic DYNAMIC 000085dc 0085dc 0000b0 08 WA 5 0
4
[17] .ctors PROGBITS 0000868c 00868c 000008 00 WA 0 0
4
[18] .dtors PROGBITS 00008694 008694 000008 00 WA 0 0
4
[19] .jcr PROGBITS 0000869c 00869c 000004 00 WA 0 0
4
[20] .got PROGBITS 000086a0 0086a0 00001c 04 WA 0 0
4
[21] .bss NOBITS 000086bc 0086bc 00000c 00 WA 0 0
4
[22] .comment PROGBITS 00000000 0086bc 0001a2 00 0 0
1
[23] .stack PROGBITS 00080000 00885e 000000 00 W 0 0
1
[24] .arm.atpcs PROGBITS 00000000 00885e 000000 00 0 0
1
[25] .shstrtab STRTAB 00000000 00885e 0000d7 00 0 0
1
[26] .symtab SYMTAB 00000000 008d98 000740 10 27 5b
4
[27] .strtab STRTAB 00000000 0094d8 000313 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)
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000034 0x00008034 0x00000000 0x000a0 0x000a0 R E 0x4
INTERP 0x008000 0x00008000 0x00008000 0x00036 0x00036 R 0x1
[Requesting program
interpreter: /usr/local/arm-unknown-freebsd8.0/libexec/ld-elf.so.1]
LOAD 0x008000 0x00008000 0x00008000 0x006bc 0x006c8 RWE 0x8000
DYNAMIC 0x0085dc 0x000085dc 0x000085dc 0x000b0 0x000b0 RW 0x4
NOTE 0x008038 0x00008038 0x00008038 0x00018 0x00018 R 0x4
Section to Segment mapping:
Segment Sections...
00 .note.ABI-tag .hash
01 .interp
02 .interp .note.ABI-tag .hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.plt .init .plt .text .fini .rodata .data .eh_frame .dynamic .ctors .dtors .jcr .got .bss
03 .dynamic
04 .note.ABI-tag
Dynamic segment at offset 0x85dc contains 17 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libc.so.7]
0x0000000c (INIT) 0x81d0
0x0000000d (FINI) 0x8490
0x00000004 (HASH) 0x8050
0x00000005 (STRTAB) 0x8118
0x00000006 (SYMTAB) 0x8088
0x0000000a (STRSZ) 88 (bytes)
0x0000000b (SYMENT) 16 (bytes)
0x00000015 (DEBUG) 0x0
0x00000003 (PLTGOT) 0x86a0
0x00000002 (PLTRELSZ) 32 (bytes)
0x00000014 (PLTREL) REL
0x00000017 (JMPREL) 0x81a4
0x6ffffffe (VERNEED) 0x8184
0x6fffffff (VERNEEDNUM) 1
0x6ffffff0 (VERSYM) 0x8170
0x00000000 (NULL) 0x0
Relocation section '.rel.plt' at offset 0x81a4 contains 4 entries:
Offset Info Type Sym.Value Sym. Name
000086ac 00000116 R_ARM_JUMP_SLOT 00008204 _init_tls
000086b0 00000416 R_ARM_JUMP_SLOT 00008210 printf
000086b4 00000516 R_ARM_JUMP_SLOT 0000821c exit
000086b8 00000716 R_ARM_JUMP_SLOT 00008228 atexit
There are no unwind sections in this file.
Symbol table '.dynsym' contains 9 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00008204 4 FUNC GLOBAL DEFAULT UND _init_tls at FBSD_1.0 (2)
2: 000086c0 4 OBJECT GLOBAL DEFAULT 21 environ
3: 000085c4 4 OBJECT GLOBAL DEFAULT 14 __progname
4: 00008210 72 FUNC GLOBAL DEFAULT UND printf at FBSD_1.0 (2)
5: 0000821c 92 FUNC GLOBAL DEFAULT UND exit at FBSD_1.0 (2)
6: 000086c8 0 NOTYPE GLOBAL DEFAULT ABS _end
7: 00008228 56 FUNC GLOBAL DEFAULT UND atexit at FBSD_1.0 (2)
8: 00000000 0 NOTYPE WEAK DEFAULT UND _Jv_RegisterClasses
Symbol table '.symtab' contains 116 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00008000 0 SECTION LOCAL DEFAULT 1
2: 00008038 0 SECTION LOCAL DEFAULT 2
3: 00008050 0 SECTION LOCAL DEFAULT 3
4: 00008088 0 SECTION LOCAL DEFAULT 4
5: 00008118 0 SECTION LOCAL DEFAULT 5
6: 00008170 0 SECTION LOCAL DEFAULT 6
7: 00008184 0 SECTION LOCAL DEFAULT 7
8: 000081a4 0 SECTION LOCAL DEFAULT 8
9: 000081d0 0 SECTION LOCAL DEFAULT 9
10: 000081f0 0 SECTION LOCAL DEFAULT 10
11: 00008234 0 SECTION LOCAL DEFAULT 11
12: 00008490 0 SECTION LOCAL DEFAULT 12
13: 000084ac 0 SECTION LOCAL DEFAULT 13
14: 000085c4 0 SECTION LOCAL DEFAULT 14
15: 000085d8 0 SECTION LOCAL DEFAULT 15
16: 000085dc 0 SECTION LOCAL DEFAULT 16
17: 0000868c 0 SECTION LOCAL DEFAULT 17
18: 00008694 0 SECTION LOCAL DEFAULT 18
19: 0000869c 0 SECTION LOCAL DEFAULT 19
20: 000086a0 0 SECTION LOCAL DEFAULT 20
21: 000086bc 0 SECTION LOCAL DEFAULT 21
22: 00000000 0 SECTION LOCAL DEFAULT 22
23: 00080000 0 SECTION LOCAL DEFAULT 23
24: 00000000 0 SECTION LOCAL DEFAULT 24
25: 00000000 0 SECTION LOCAL DEFAULT 25
26: 00000000 0 SECTION LOCAL DEFAULT 26
27: 00000000 0 SECTION LOCAL DEFAULT 27
28: 00000000 0 FILE LOCAL DEFAULT ABS crt1.c
29: 00008234 0 FUNC LOCAL DEFAULT 11 $a
30: 00008310 0 OBJECT LOCAL DEFAULT 11 $d
31: 000085c4 0 OBJECT LOCAL DEFAULT 14 $d
32: 00008038 24 OBJECT LOCAL DEFAULT 2 abitag
33: 00008038 0 OBJECT LOCAL DEFAULT 2 $d
34: 00000000 0 FILE LOCAL DEFAULT ABS /root/ARM/head/lib/csu/ar
35: 00000000 0 FILE LOCAL DEFAULT ABS /usr/obj/arm/root/ARM/hea
36: 00000000 0 FILE LOCAL DEFAULT ABS /usr/obj/arm/root/ARM/hea
37: 00000000 0 FILE LOCAL DEFAULT ABS /usr/obj/arm/root/ARM/hea
38: 00000000 0 FILE LOCAL DEFAULT ABS /root/ARM/head/lib/csu/ar
39: 00000000 0 FILE LOCAL DEFAULT ABS <command-line>
40: 00000000 0 FILE LOCAL DEFAULT ABS <built-in>
41: 00000000 0 FILE LOCAL DEFAULT ABS /root/ARM/head/lib/csu/ar
42: 000081d0 0 FUNC LOCAL DEFAULT 9 $a
43: 00008490 0 FUNC LOCAL DEFAULT 12 $a
44: 00000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
45: 000085c8 0 OBJECT LOCAL DEFAULT 14 force_to_data
46: 0000868c 0 OBJECT LOCAL DEFAULT 17 __CTOR_LIST__
47: 0000868c 0 OBJECT LOCAL DEFAULT 17 $d
48: 00008694 0 OBJECT LOCAL DEFAULT 18 __DTOR_LIST__
49: 00008694 0 OBJECT LOCAL DEFAULT 18 $d
50: 0000869c 0 OBJECT LOCAL DEFAULT 19 __JCR_LIST__
51: 00008324 0 FUNC LOCAL DEFAULT 11 __do_global_dtors_aux
52: 00008324 0 FUNC LOCAL DEFAULT 11 $a
53: 00008388 0 OBJECT LOCAL DEFAULT 11 $d
54: 000086bc 1 OBJECT LOCAL DEFAULT 21 completed.4826
55: 000085d0 0 OBJECT LOCAL DEFAULT 14 p.4824
56: 00008390 0 FUNC LOCAL DEFAULT 11 call___do_global_dtors_au
57: 00008390 0 FUNC LOCAL DEFAULT 11 $a
58: 000084a0 0 FUNC LOCAL DEFAULT 12 $a
59: 000083a0 0 FUNC LOCAL DEFAULT 11 frame_dummy
60: 000083d0 0 OBJECT LOCAL DEFAULT 11 $d
61: 000083d8 0 FUNC LOCAL DEFAULT 11 call_frame_dummy
62: 000083d8 0 FUNC LOCAL DEFAULT 11 $a
63: 000081e0 0 FUNC LOCAL DEFAULT 9 $a
64: 000085d0 0 OBJECT LOCAL DEFAULT 14 $d
65: 00000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
66: 000085d4 0 OBJECT LOCAL DEFAULT 14 force_to_data
67: 00008690 0 OBJECT LOCAL DEFAULT 17 __CTOR_END__
68: 00008698 0 OBJECT LOCAL DEFAULT 18 __DTOR_END__
69: 000085d8 0 OBJECT LOCAL DEFAULT 15 __FRAME_END__
70: 0000869c 0 OBJECT LOCAL DEFAULT 19 __JCR_END__
71: 000083e8 0 FUNC LOCAL DEFAULT 11 __do_global_ctors_aux
72: 000083e8 0 FUNC LOCAL DEFAULT 11 $a
73: 00008424 0 OBJECT LOCAL DEFAULT 11 $d
74: 00008428 0 FUNC LOCAL DEFAULT 11 call___do_global_ctors_au
75: 00008428 0 FUNC LOCAL DEFAULT 11 $a
76: 000081e4 0 FUNC LOCAL DEFAULT 9 $a
77: 00000000 0 FILE LOCAL DEFAULT ABS /root/ARM/head/lib/csu/ar
78: 00000000 0 FILE LOCAL DEFAULT ABS /usr/obj/arm/root/ARM/hea
79: 00000000 0 FILE LOCAL DEFAULT ABS /usr/obj/arm/root/ARM/hea
80: 00000000 0 FILE LOCAL DEFAULT ABS /usr/obj/arm/root/ARM/hea
81: 00000000 0 FILE LOCAL DEFAULT ABS /root/ARM/head/lib/csu/ar
82: 00000000 0 FILE LOCAL DEFAULT ABS <command-line>
83: 00000000 0 FILE LOCAL DEFAULT ABS <built-in>
84: 00000000 0 FILE LOCAL DEFAULT ABS /root/ARM/head/lib/csu/ar
85: 000081e8 0 FUNC LOCAL DEFAULT 9 $a
86: 000084a4 0 FUNC LOCAL DEFAULT 12 $a
87: 00000000 0 FILE LOCAL DEFAULT ABS test.c
88: 000084b0 0 NOTYPE LOCAL DEFAULT 13 $d
89: 00008438 0 NOTYPE LOCAL DEFAULT 11 $a
90: 00008484 0 NOTYPE LOCAL DEFAULT 11 $d
91: 000085dc 0 OBJECT GLOBAL DEFAULT 16 _DYNAMIC
92: 000086c8 0 NOTYPE GLOBAL DEFAULT ABS _bss_end__
93: 000086bc 0 NOTYPE GLOBAL DEFAULT ABS __bss_start__
94: 000085cc 0 OBJECT GLOBAL HIDDEN 14 __dso_handle
95: 00008204 4 FUNC GLOBAL DEFAULT UND _init_tls@@FBSD_1.0
96: 000081d0 0 FUNC GLOBAL DEFAULT 9 _init
97: 000086c0 4 OBJECT GLOBAL DEFAULT 21 environ
98: 00008264 192 FUNC GLOBAL DEFAULT 11 __start
99: 000086c8 0 NOTYPE GLOBAL DEFAULT ABS __bss_end__
100: 000085c4 4 OBJECT GLOBAL DEFAULT 14 __progname
101: 00008234 0 NOTYPE GLOBAL DEFAULT 11 _start
102: 00008210 72 FUNC GLOBAL DEFAULT UND printf@@FBSD_1.0
103: 000086bc 0 NOTYPE GLOBAL DEFAULT ABS __bss_start
104: 00008438 80 FUNC GLOBAL DEFAULT 11 main
105: 000086c8 0 NOTYPE GLOBAL DEFAULT ABS __end__
106: 00008490 0 FUNC GLOBAL DEFAULT 12 _fini
107: 0000821c 92 FUNC GLOBAL DEFAULT UND exit@@FBSD_1.0
108: 000086bc 0 NOTYPE GLOBAL DEFAULT ABS _edata
109: 000086a0 0 OBJECT GLOBAL DEFAULT 20 _GLOBAL_OFFSET_TABLE_
110: 000086c8 0 NOTYPE GLOBAL DEFAULT ABS _end
111: 000086c4 4 OBJECT GLOBAL DEFAULT 21 __ps_strings
112: 00008228 56 FUNC GLOBAL DEFAULT UND atexit@@FBSD_1.0
113: 00080000 0 NOTYPE GLOBAL DEFAULT 23 _stack
114: 000085c4 0 NOTYPE GLOBAL DEFAULT 14 __data_start
115: 00000000 0 NOTYPE WEAK DEFAULT UND _Jv_RegisterClasses
Histogram for bucket list length (total of 3 buckets):
Length Number % of total Coverage
0 0 ( 0.0%)
1 1 ( 33.3%) 12.5%
2 0 ( 0.0%) 12.5%
3 1 ( 33.3%) 50.0%
4 1 ( 33.3%) 100.0%
Version symbols section '.gnu.version' contains 9 entries:
Addr: 0000000000008170 Offset: 0x008170 Link: 4 (.dynsym)
000: 0 (*local*) 2 (FBSD_1.0) 1 (*global*) 1 (*global*)
004: 2 (FBSD_1.0) 2 (FBSD_1.0) 1 (*global*) 2 (FBSD_1.0)
008: 0 (*local*)
Version needs section '.gnu.version_r' contains 1 entries:
Addr: 0x0000000000008184 Offset: 0x008184 Link to section: 5 (.dynstr)
000000: Version: 1 File: libc.so.7 Cnt: 1
0x0010: Name: FBSD_1.0 Flags: none Version: 2
More information about the freebsd-arm
mailing list