This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
ld/2218 fix for powerpc64
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: binutils at sources dot redhat dot com
- Date: Fri, 17 Feb 2006 15:18:26 +1030
- Subject: ld/2218 fix for powerpc64
Jakub fixed the undef weak in PIE a long time ago for powerpc-linux.
powerpc64-linux needs the same treatment. I also tweaked the ppc32
code to use the same tests as ppc64. Not that there is anything wrong
with Jakub's code, but the simpler test (leaving out info->pie) is
sufficient.
PR ld/2218
* elf64-ppc.c (allocate_dynrelocs): Ensure undef weak sym is
dynamic.
(ppc64_elf_relocate_section): Check output reloc section size.
* elf32-ppc.c (allocate_dynrelocs): Simplify undef weak test.
Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.232
diff -u -p -r1.232 elf64-ppc.c
--- bfd/elf64-ppc.c 17 Jan 2006 15:32:41 -0000 1.232
+++ bfd/elf64-ppc.c 17 Feb 2006 04:22:24 -0000
@@ -7582,9 +7582,20 @@ allocate_dynrelocs (struct elf_link_hash
/* Also discard relocs on undefined weak syms with non-default
visibility. */
- if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
- && h->root.type == bfd_link_hash_undefweak)
- eh->dyn_relocs = NULL;
+ if (h->root.type == bfd_link_hash_undefweak)
+ {
+ if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
+ eh->dyn_relocs = NULL;
+
+ /* Make sure this symbol is output as a dynamic symbol.
+ Undefined weak syms won't yet be marked as dynamic. */
+ else if (h->dynindx == -1
+ && !h->forced_local)
+ {
+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
+ return FALSE;
+ }
+ }
}
else if (ELIMINATE_COPY_RELOCS)
{
@@ -10757,6 +10768,9 @@ ppc64_elf_relocate_section (bfd *output_
if (sreloc == NULL)
abort ();
+ if (sreloc->reloc_count * sizeof (Elf64_External_Rela)
+ >= sreloc->size)
+ abort ();
loc = sreloc->contents;
loc += sreloc->reloc_count++ * sizeof (Elf64_External_Rela);
bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.185
diff -u -p -r1.185 elf32-ppc.c
--- bfd/elf32-ppc.c 27 Dec 2005 03:54:33 -0000 1.185
+++ bfd/elf32-ppc.c 17 Feb 2006 04:39:01 -0000
@@ -4546,20 +4546,19 @@ allocate_dynrelocs (struct elf_link_hash
/* Also discard relocs on undefined weak syms with non-default
visibility. */
- 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->forced_local)
+ if (h->root.type == bfd_link_hash_undefweak)
{
- if (! bfd_elf_link_record_dynamic_symbol (info, h))
- return FALSE;
+ if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
+ eh->dyn_relocs = NULL;
+
+ /* Make sure undefined weak symbols are output as a dynamic
+ symbol in PIEs. */
+ else if (h->dynindx == -1
+ && !h->forced_local)
+ {
+ if (! bfd_elf_link_record_dynamic_symbol (info, h))
+ return FALSE;
+ }
}
}
else if (ELIMINATE_COPY_RELOCS)
--
Alan Modra
IBM OzLabs - Linux Technology Centre