This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Question about archive search behavior vs. --defsym
- From: Mark Mitchell <mark at codesourcery dot com>
- To: binutils at sourceware dot org
- Date: Wed, 08 Sep 2010 21:52:59 -0700
- Subject: Question about archive search behavior vs. --defsym
If you do something like this:
int main () { f(); }
and don't define "f" anywhere, you can do:
gcc main.c -Wl,--defsym=f=4
and your program will link, with the call being replaced with a call to 0x4.
But, I was surprised to find that if "f" is defined in an archive it is
still pulled in. Concretely:
f.c
===
void f() {}
main.c
======
int main () { f(); }
$ gcc -c f.c
$ ar cr libf.a f.o
$ gcc main.c -Wl,--defsym=f=4 -L. -lf
pulls in f.o from libf.a even though the symbol is already defined.
This behavior was surprising to me. Is this a bug?
Thanks,
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713