[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [BUG] ld -shared resolves strong ref to defined weak sym as 0?

From: Ian Lance Taylor
Subject: Re: [BUG] ld -shared resolves strong ref to defined weak sym as 0?
Date: 22 Dec 2003 09:27:44 -0500
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Roland McGrath <address@hidden> writes:

> The resolution of the reference to `loser' in b.o is wrong.  It was
> resolved as if the value of the symbol were zero (or equivalently, as if
> there reference were weak and the symbol were undefined).  The symbol is in
> fact defined.  Moreover, the reference is strong (to wit, ld -shared -z
> defs of b.o without a.o does indeed barf on the undefined reference).  If
> the the b.o reference is R_386_PLT32 instead of R_386_PC32 (i.e. b.s says
> "call address@hidden"), it works right (creates a PLT entry).

If you do objdump -R on x.so, you will see that there is a R_386_PC32
reloc.  When the dynamic linker sees that reloc, it will resolve it to
the correct address.  So this shared library should execute fine.

This is what the linker is supposed to do, since it permits the main
program to override the symbol `loser'.  If the main program defines
`loser', then the dynamic linker will resolve the R_386_PC32 reloc to
the instance in the main program.

If you use the -Bsymbolic option when you link, then the PC relative
reference will be resolved directly, without using a relocation.  The
same should happen if you use a version script to force `loser' to be
a local symbol.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]