From: Oscar Waddell R.S. (owaddell@nickel.ucs.indiana.edu)
Date: 04/26/93


From: "Oscar Waddell R.S." <owaddell@nickel.ucs.indiana.edu>
Subject: 'ld' curiosity (bug?)
Date: Mon, 26 Apr 1993 00:10:24 -0500


Here is a transcript of an experiment run on my Linux box:

% cat > test.c
main() { }
% gcc -o test test.c
% test
% gcc -o test test.c /usr/lib/crt0.o
% test
Segmentation fault
% gcc -o test test.c -lc /usr/lib/crt0.o
% test
test: can't load library 'w `
        No such library.

Three different compiles with three different results. The GCC used is
2.3.3, and ld, crt0.o, libc, etc. are the ones from image-4.3.3.tar.

When I try this on a friend's NeXT (also gcc) I get apropriate
error messages from ld about multiply defined symbols (for the second
and third compiles):

   /bin/ld: multiple definitions of symbol __environ
   (etc. etc.)

Why don't I get an error message under Linux? The compile appears to
succeed but produces an executable that either segmentation faults,
or tries to load a bogus library.

Incidently, I realize the above looks like a really stupid thing to
do. The problem surfaced while I was trying to port something which
originally was linked explicitly with ld. I changed part of the
makefile so that it used gcc instead but didn't notice that crt0.o had
been included among the files to link with. When the compile
succeeded but the executable bombed trying to load some bogus library,
I was confused. I'd like to think I might have found the problem
a lot sooner if ld had been generating the error messages that it
seems it should be (based on the tests on the NeXT).