This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
--export-dynamic question
- From: Toon Knapen <toon dot knapen at fft dot be>
- To: binutils at sources dot redhat dot com
- Date: Tue, 31 Aug 2004 13:54:14 +0200
- Subject: --export-dynamic question
I would suspect the symbols defined in the static libraries that I link
into my executable to appear in the final exe when the --export-dynamic
option is passed on the command-line. However my findings proove
otherwise (using redhat 8, ld version 2.13.90.02)
Using following files:
<begin foo.cpp>
int foo()
{ return 99 ; }
<end foo.cpp>
<begin main.cpp>
int main()
{ return 0 ; }
<end main.cpp>
I do:
gcc -c foo.cpp
gcc -c main.cpp
ld main.o foo.o
If I now 'nm a.out', I clearly see the function 'foo' in my a.out.
Now I first put the foo.o object-file into a library and then link the
library into the exe like so:
ar ru libfoo.a foo.o
ld main.o libfoo.a
Now the function foo does not appear anymore when I 'nm a.out' (as
expected since it is dead code)
Now however I link a.out using following command-line:
ld --export-dynamic main.o libfoo.a
And the funtion foo does not appear either (although I would expect the
export-dynamic flag to prevent the dead-code elimination) ?
Thanks in advance,
Toon