Graeme_Dixon@TRANSARC.COM (04/19/91)
I've discovered 2 bugs in the loader/ranlib, one minor, one not so minor: 1. ranlib doesn't generate a table of contents if a libray only contains variables. Trying to link against the library produces a message like: /bin/ld: warning empty table of contents: libfoo.a (can't load from it) 2. When a library contains uninitialized global variables, and an application (or functions in the library) that uses the globals is linked against that library, the linker can't locate the (uninitialized) globals -- /bin/ld claims the variables are undefined. This only occurs for uninitialized globals -- if they are initialized then the link succeeds. The following simple program illustrates bug 2 (this program works fine on other machines). It fails on NeXTStations and NeXTCubes running both 2.0 and 2.1. Anyone know a work-around for this? Graeme N. Dixon (graeme@transarc.com) Transarc Corporation ------- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # Makefile # bar.c # foo.c # garbage.c # This archive created: Thu Apr 18 10:39:09 1991 export PATH; PATH=/bin:$PATH if test -f 'Makefile' then echo shar: will not over-write existing file "'Makefile'" else sed 's/^X//' << \SHAR_EOF > 'Makefile' Xall : foo X Xfoo : foo.o libfoo.a X cc -o foo foo.o libfoo.a X Xlibfoo.a : bar.o garbage.o X ar r libfoo.a bar.o garbage.o X ranlib libfoo.a X Xclean: X rm -f foo.o bar.o garbage.o libfoo.a foo SHAR_EOF fi # end of overwriting check if test -f 'bar.c' then echo shar: will not over-write existing file "'bar.c'" else sed 's/^X//' << \SHAR_EOF > 'bar.c' Xint foobar; SHAR_EOF fi # end of overwriting check if test -f 'foo.c' then echo shar: will not over-write existing file "'foo.c'" else sed 's/^X//' << \SHAR_EOF > 'foo.c' Xextern int foobar; X Xmain() X{ X printf("foobar is %d\n", foobar); X} SHAR_EOF fi # end of overwriting check if test -f 'garbage.c' then echo shar: will not over-write existing file "'garbage.c'" else sed 's/^X//' << \SHAR_EOF > 'garbage.c' X/* X * This file is necessary because the version of ranlib on the X * NeXT won't generate a table of contents when there is the object X * files in the library just contain variables. The ranlib suceeds, but X * attempts to link with the library produce the following: X X/bin/ld: warning empty table of contents: libfoo.a (can't load from it) X X */ Xint garbage; X Xvoid arg() X{ X garbage = 1; X} SHAR_EOF fi # end of overwriting check # End of shell archive exit 0