This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
linking weak symbols on interix
- From: Martin Koeppe <mkoeppe at gmx dot de>
- To: binutils at sourceware dot org
- Date: Sat, 1 Jul 2006 22:38:06 +0200 (CEST)
- Subject: linking weak symbols on interix
Hi all,
I'm trying to build a working cross linker running on linux and
linking pe files for interix.
When linking a very simple program with ld 2.17, I get
$ i586-pc-interix3-ld crt0.o hello.o -L. -lgcc -lc -lpsxdll --print-map
./libgcc.a(__main.o): In function `_main':
/dev/fs/C/gnu2.intel/egcs.source/gcc/libgcc2.c:1885: undefined reference to `atexit'
The beginning of the map is as follows:
Archive member included because of file (symbol)
./libgcc.a(__main.o) hello.o (__main)
./libc.a(exit.o) crt0.o (_s_exit)
./libc.a(strlen.o) crt0.o (_strlen)
./libc.a(_init.o) crt0.o (_init)
./libc.a(atexit.o) crt0.o (_atexit)
./libc.a(loaderstub.o) crt0.o (_LOADER_NAME)
./libc.a(strcpy.o) crt0.o (_strcpy)
./libc.a(path_convert.o) crt0.o (_path_convert)
./libc.a(strrchr.o) crt0.o (_strrchr)
./libc.a(fpinit.obj) hello.o (_fltused)
./libc.a(crt0dat.o) ./libc.a(_init.o) (_cinit)
./libc.a(heapinit.obj) ./libc.a(_init.o) (_heap_init)
./libc.a(malloc.obj) ./libc.a(atexit.o) (_malloc)
./libc.a(strncpy.o) ./libc.a(path_convert.o) (_strncpy)
./libc.a(setlocale.o) ./libc.a(path_convert.o) (__mb_cur_max)
./libc.a(strchr.o) ./libc.a(path_convert.o) (_strchr)
./libc.a(strncmp.o) ./libc.a(path_convert.o) (_strncmp)
./libc.a(strlcpy.o) ./libc.a(path_convert.o) (_strlcpy)
./libc.a(crt0init.obj) ./libc.a(crt0dat.o) (__xt_z)
./libc.a(err.o) ./libc.a(setlocale.o) (_errx)
[...]
When linking the same files on interix 3.5 with microsoft's version of
gnu ld, the link is successful and the generated map begins with:
$ ld crt0.o hello.o -L. -lgcc -lc -lpsxdll --print-map
Archive member included because of file (symbol)
./libgcc.a(__main.o) hello.o (__main)
./libc.a(exit.o) crt0.o (_s_exit)
./libc.a(strlen.o) crt0.o (_strlen)
./libc.a(_init.o) crt0.o (_init)
./libc.a(atexit.o) crt0.o (_atexit)
./libc.a(loaderstub.o) crt0.o (_LOADER_NAME)
./libc.a(strcpy.o) crt0.o (_strcpy)
./libc.a(path_convert.o) crt0.o (_path_convert)
./libc.a(strrchr.o) crt0.o (_strrchr)
./libc.a(fpinit.obj) hello.o (_fltused)
./libc.a(wk_atexit.o) ./libgcc.a(__main.o) (atexit)
note this ^^^ line
./libc.a(crt0dat.o) ./libc.a(_init.o) (_cinit)
./libc.a(heapinit.obj) ./libc.a(_init.o) (_heap_init)
./libc.a(malloc.obj) ./libc.a(atexit.o) (_malloc)
./libc.a(strncpy.o) ./libc.a(path_convert.o) (_strncpy)
./libc.a(setlocale.o) ./libc.a(path_convert.o) (__mb_cur_max)
./libc.a(strchr.o) ./libc.a(path_convert.o) (_strchr)
./libc.a(strncmp.o) ./libc.a(path_convert.o) (_strncmp)
./libc.a(strlcpy.o) ./libc.a(path_convert.o) (_strlcpy)
./libc.a(crt0init.obj) ./libc.a(crt0dat.o) (__xt_z)
[...]
The relevant output from:
$ nm -p libc.a
wk_atexit.o:
000e200c a @comp.id
U __atexit
U __atexit
w _atexit
So the weak symbol _atexit doesn't seem to be handled correctly.
For details how I configured binutils and where to get the files
mentioned in this mail, see:
http://sourceware.org/bugzilla/show_bug.cgi?id=2729
(The libgcc.a used this time comes from interix.)
Any ideas?
Martin
(please CC me, I'm not on the list!)