This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: weak and strong aliases for global data fail

On Mon, May 22, 2006 at 10:38:56PM +0200, Peter S. Mazinger wrote:
> On Wed, 17 May 2006, Peter S. Mazinger wrote:
> Could anyone tell me if this is a binutils bug (tested 2.16.1/2.16.92) or 
> I should send it to the gcc list (tested with 3.4.6). It seems to me that 
> it is rather an ld bug.
> Thanks, Peter
> > Hello!
> > 
> > Attached tests show a case, when a final binary is OK if 
> > compiled w/ -fPIC (or -fPIE, it does not have to be ET_DYN, but can be), 
> > else it fails if using aliases (both weak and strong) for global data.
> > 
> > Sorry for the "big" test cases, I couldn't make them smaller.

It's a user bug.  When the linker needs to generate a copy reloc, eg. as
it does for x86 non-PIC code, for a variable like "optind_test" in your
main app, then space is allocated in your main app and initialised from
the shared object.  The main app uses this location for references to
"optind_test", as do references from within the shared lib.  However,
your shared lib is not referencing "optind_test" but an alias stored at
a different location (in the shared lib).

With PIC code the linker can generally dispense with the copy reloc, so
both the main app and the shared lib use the same location.

Alan Modra
IBM OzLabs - Linux Technology Centre

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]