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 Mon, Feb 20, 2006 at 11:30:20AM +1030, Alan Modra wrote:
> On Sun, Feb 19, 2006 at 04:40:41PM -0800, H. J. Lu wrote:
> > On Mon, Feb 20, 2006 at 10:19:39AM +1030, Alan Modra wrote:
> > > 
> > > 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).
> > 
> > I have no strong opionions on either approach as long as we can get
> > undefined weak symbol in PIE to work correctly. If we want to make it
> > target dependent, I'd like to add 2 hooks to ELF backend:
> > 
> > 1. fixup_undefined_weak_symbol, which will be called to fix up
> > the undefined weak symbol. The default will be NULL.
> > 2. pie_fixup_output_extsym, which be called to fix up output symbol
> > for PIE. The default will also be NULL.
> > 
> > 2 generic versions will be provided and x86/x86-64/ia64 will use them.
> 
> I don't see that these are needed.  I'm testing the following.
> 
> 	PR ld/2218
> 	* elf32-arm.c (allocate_dynrelocs): Ensure undef weak sym in pie
> 	is dynamic.
> 	* elf32-hppa.c (allocate_dynrelocs): Likewise.
> 	* elf32-i386.c (allocate_dynrelocs): Likewise.
> 	* elf32-s390.c (allocate_dynrelocs): Likewise.
> 	* elf32-sh.c (allocate_dynrelocs): Likewise.
> 	* elf64-s390.c (allocate_dynrelocs): Likewise.
> 	* elf64-x86-64.c (allocate_dynrelocs): Likewise.
> 	* elf32-m32r.c (allocate_dynrelocs): Likewise.  Discard relocs
> 	on undef weak with non-default visibility too.
> 	* elfxx-sparc.c (allocate_dynrelocs): Ditto.
> 

Do you have a patch for ia64? Also how do you address

http://sourceware.org/bugzilla/show_bug.cgi?id=2251

My patch changes to if we don't export all symbols into the dynamic
symbol table, a symbol in PIE, which isn't defined in nor referenced
by any dynamic object, has the hidden visibility.


H.J.


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