[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
EXTERN doesn't work as -u
From: |
Marcus Brinkmann |
Subject: |
EXTERN doesn't work as -u |
Date: |
Thu, 14 Mar 2002 12:07:53 +0100 |
User-agent: |
Mutt/1.3.27i |
Hi,
EXTERN doesn't seem to work properly. I am using:
ulysses:/tmp# ld --version
GNU ld version 2.11.93.0.2 20020207 Debian/GNU Linux
The attached Makefile produces the following output:
ulysses:/tmp# make
echo 'main() {};' > foo.c
cc -c -o foo.o foo.c
echo 'bar() { return 0; }' > bar.c
cc -c -o bar.o bar.c
ar cru libbar.a bar.o
ranlib libbar.a
gcc -static -o foo1 foo.o -u bar libbar.a
echo 'EXTERN(bar);' > libbar-script.a
gcc -static -o foo2 foo.o libbar-script.a libbar.a
objdump --syms foo1 | grep bar && echo BAR defined in foo1 || echo BAR
undefined in foo1
00000000 l df *ABS* 00000000 bar.c
080481d0 g F .text 00000009 bar
BAR defined in foo1
objdump --syms foo2 | grep bar && echo BAR defined in foo2 || echo BAR
undefined in foo2
BAR undefined in foo2
I would expect that foo2 also contains the symbol bar.
The verbose runs were not really illuminative. Here is the diff, except for
the command line itself:
@@ -175,8 +175,9 @@
/usr/lib/gcc-lib/i386-linux/2.95.4/crtbegin.o
attempt to open foo.o succeeded
foo.o
+attempt to open libbar-script.a succeeded
+opened script file libbar-script.a
attempt to open libbar.a succeeded
-(libbar.a)bar.o
attempt to open /usr/lib/gcc-lib/i386-linux/2.95.4/libgcc.a succeeded
attempt to open /usr/lib/gcc-lib/i386-linux/2.95.4/libc.a failed
attempt to open /usr/lib/libc.a succeeded
I run ld in the debugger, and ldlang_add_undef was invoked for foo2, but I
don't know enough about the internals to see why it didn't have an effect.
Thanks,
Marcus
Thanks,
Marcus
--
`Rhubarb is no Egyptian god.' Debian http://www.debian.org address@hidden
Marcus Brinkmann GNU http://www.gnu.org address@hidden
address@hidden
http://www.marcus-brinkmann.de
- EXTERN doesn't work as -u,
Marcus Brinkmann <=