--defsym foo=bar when bar is in libc

Shaun Jackman sjackman@pathwayconnect.com
Fri Aug 1 16:06:00 GMT 2003


An object file foo.o has an undefined reference to the symbol foo. I'm
trying to use --defsym foo=puts to fix the reference. If puts is used
anywhere else in foo.o this works fine. So, I tried to pull in puts by
adding '-u puts', but no luck. How do I pull in a symbol from libc for
use with --defsym?

Thanks,
Shaun


--host=i686-pc-linux-gnu --target=i686-pc-linux-gnu

$ nm foo.o
         U foo
00000000 T main

$ gcc foo.c -o foo -Wl,--defsym,foo=puts 
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../libc.so:6:
unresolvable symbol `puts' referenced in expression
/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../libc.so:6:
unresolvable symbol `puts' referenced in expression
/tmp/ccS6WHEH.o(.text+0x19): In function `main':
: undefined reference to `foo'
collect2: ld returned 1 exit status



More information about the Binutils mailing list