static linking with gcc on OSX 10.6
response.
http://developer.apple.com/mac/library/qa/qa2001/qa1118.html
Apple recommends:
"get the Csu module from Darwin and try building crt0.o statically"
I downloaded the Csu module from:
http://www.opensource.apple.com/source/Csu/Csu-79/
Did a 'make install' and then tried a test program. Does anybody know where
I can get a 'crt0.o' that will work or what I did wrong? I am using a MacBook
with a 10.6 upgrade. Thanks. Here is output of simple test programs.
//32-bit static - compiles fine
[167]gcc -static -m32 -g t.c
[168]a.out
Bus error
[169]
//gdb from above "Bus error"
(gdb) r
Starting program: /private/tmp/a.out
Program received signal EXC BADACCESS, Could not access memory.
Reason: KERN PROTECTIONFAILURE at address: 0x00000001
0x00000001 in ?? ()
//64-bit static
[172]gcc -static t.c
ld: warning: in /usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc_static.a,
file is not of required architecture
Undefined symbols:
"_exit", referenced from:
start in crt0.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
//64-bit static
[172]gcc -static t.c
ld: warning: in /usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc_static.a,
file is not of required architecture
Undefined symbols:
"_exit", referenced from:
start in crt0.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
//64-bit static
[172]gcc -static t.c
ld: warning: in /usr/lib/gcc/i686-apple-darwin10/4.2.1/libgcc_static.a,
file is not of required architecture
Undefined symbols:
"_exit", referenced from:
start in crt0.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
//now 32-bit no longer works due to the Csu 'make install' overridding
// /usr/lib/crt1.10.6.o
[175]gcc -m32 t.c
ld: warning: in /usr/lib/crt1.10.6.o, file is not of required
architecture ld: could not find entry point "start" (perhaps missing
crt1.o)
collect2: ld returned 1 exit status
Mac OS X (10.6)