This is the mail archive of the binutils@sourceware.org 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: PATCH: ld/2218: Weak undefined symbol doesn't work properly with PIE


On Fri, Feb 17, 2006 at 07:47:56AM -0800, H. J. Lu wrote:
> On Fri, Feb 17, 2006 at 06:46:56AM -0800, H. J. Lu wrote:
> > On Fri, Feb 17, 2006 at 05:15:06PM +1030, Alan Modra wrote:
> > > On Thu, Feb 16, 2006 at 10:14:31PM -0800, H. J. Lu wrote:
> > > > It is a generic ELF problem. Why does each backend have to handle it
> > > > separately?
> > > 
> > > Well, if you are clever you might be able to make a generic patch that
> > > handles undef weak in pie.  The right place to do it is after all
> > > symbols have been loaded.
> > 
> > Thanks for the pointer. Here is the updated patch.
> 
> I added the h->ref_regular check. It may not be strictly necessary
> since it isn't easy to generate an unreferenced weak undefined
> symbol :-(.

After giving this some more thought, I'm inclined to say that this patch
does not belong in the generic ELF support.  The reason is that the
behaviour of weak undefined symbols is not well defined.  At least, I'm
not aware of any standard that says an undefined weak sym should be made
dynamic when dynamic objects are involved in the link.  I think it would
be quite reasonable for an ELF target to choose to resolve undefined
weak syms in an executable to zero at link time.

So I think we ought to patch each backend individually, painful as that
might be.  Note that many backends already handle undef weak syms
specially, eg. calling bfd_elf_link_record_dynamic_symbol for plt and
got references (even in non-pie exes).

-- 
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]