This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: A patch for default version and archive
On Wed, Nov 08, 2000 at 01:38:06PM -0800, H . J . Lu wrote:
> On Wed, Nov 08, 2000 at 11:23:06AM -0800, H . J . Lu wrote:
> > When we have default version in an archive, we fail to resolve the
> > reference with only one `@':
> >
> > # make
> > gcc -O -c -o test.o test.c
> > gcc -O -c -o foo.o foo.c
> > gcc -o test1 test.o foo.o
> > ar rv libfoo.a foo.o
> > r - foo.o
> > gcc -o test2 test.o libfoo.a
> > test.o: In function `main':
> > test.o(.text+0x7): undefined reference to `foo@GLIBC_2.0'
> > collect2: ld returned 1 exit status
> >
> > I am enclosing a patch and a testcae here.
> >
> >
> > --
> > H.J. Lu (hjl@gnu.org)
> > ---
> > 2000-11-08 H.J. Lu <hjl@gnu.org>
> >
> > * elflink.h (elf_link_add_archive_symbols): For the default
> > version, check references with only one `@' first.
> >
>
> My last patch has a typo. It should be strcpy, not strcat.
>
Just clarify my patch. The default versioned symbol, foo@@verion1,
will resolve references to foo and foo@verion1. That is how symbol
versioning works. When you do
# gcc ... libfoo.a ...
the linker won't pull in a .o file from libfoo.a unless it sees
references to symbols defined in libfoo.a before reading libfoo.a.
There is a bug in elf_link_add_archive_symbols. When the linker sees
a definition like foo@@verion1, it only checks references to foo. It
misses foo@verion1. That is why
# gcc -o test1 test.o foo.o
works, but
# gcc -o test1 test.o libfoo.a
doesn't. My patch adds the check for references to foo@verion1. Let
me know if there are questions.
Thanks.
H.J.