ld in binutils-1.9l.3
Ian Lance Taylor
ian@cygnus.com
Mon Aug 29 09:46:00 GMT 1994
From: hjl@nynexst.com (H.J. Lu)
Date: Sun, 28 Aug 94 20:02:06 EDT
> This is a weird problem that `ld' should really detect and prevent
> (via a warning message).
>
> To reproduce:
>
> $ cat > test.c
> main () { printf("this is a test\n"); }
> ^D
> $ gcc -o test.o test.c (Note the missing "-c")
> $ file test.o
> test.o: Linux/i386 demand-paged executable (QMAGIC) not stripped
> $ gcc -o test test.o
> $ file test
> test: Linux/i386 demand-paged executable (QMAGIC) not stripped
> $ test.o
> this is a test
> $ test
> [ no output ]
>
> When this snuck up on us for real, it caused lots of problems and took
> a bit of debugging to track down a bad Makefile.
>
> Sometimes, they'll (twice linked binaries) run peacefully, but
> sometimes they do bad things: seg. fault (untraceable) and suck up all
> virtual memory are the two I've seen.
>
> Could some better magic detection be put into ld?
I don't really see how to do this in a system independent fashion. On
some systems there is no simple way to distinguish files which are
reasonable linker inputs from files which are not.
Of course, I am open to suggestions.
Note that if you define a globally visible symbol in the crt0.o file,
then you will get a multiple definition error when you attempt to link
an already linked file. That should prevent this type of error from
occurring.
Ian
More information about the Gas2
mailing list