This is the mail archive of the binutils@sources.redhat.com 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]

[PATCH] Fix broken -pie on ppc32


On Fri, Feb 20, 2004 at 11:06:24AM +1030, Alan Modra wrote:
> On Thu, Feb 19, 2004 at 04:07:06PM -0800, Geoff Keating wrote:
> > Jakub Jelinek <jakub@redhat.com> writes:
> > [about undefined weak syms]
> > > Should ld in this case (on all arches) just skip the dynamic relocation
> > > and store 0?
> > 
> > I believe that the right thing to do is to create the dynamic
> > relocation.  ld should assume that an undefined weak symbol is
> > actually defined in a shared library.
> 
> I think so too, but this is a gray area.  The handling of weak symbols
> isn't fully defined in the gABI ELF spec, so you could make a case for
> all undefined weaks being resolved to zero at link time.  In any case,
> we ought to be consistent in our handling of undefined weaks.  Since
> we currently make them dynamic in other cases, I think we should here
> too.

Like this?

2004-02-20  Jakub Jelinek  <jakub@redhat.com>

	* elf32-ppc.c (allocate_dynrelocs): Create dynsym for undef weak
	symbols used in PIE relocs.

--- bfd/elf32-ppc.c.jj	2004-01-19 00:08:02.000000000 +0100
+++ bfd/elf32-ppc.c	2004-02-20 13:30:13.947305152 +0100
@@ -3189,6 +3189,18 @@ allocate_dynrelocs (struct elf_link_hash
       if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
 	  && h->root.type == bfd_link_hash_undefweak)
 	eh->dyn_relocs = NULL;
+
+      /* Make sure undefined weak symbols are output as a dynamic symbol
+	 in PIEs.  */
+      if (info->pie
+	  && eh->dyn_relocs != NULL
+	  && h->dynindx == -1
+	  && h->root.type == bfd_link_hash_undefweak
+	  && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
+	{
+	  if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+	    return FALSE;
+	}
     }
   else if (ELIMINATE_COPY_RELOCS)
     {


	Jakub


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