This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Fix copy relocs on powerpc, PR13470
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Sat, 3 Dec 2011 11:23:17 +1030
- Subject: Fix copy relocs on powerpc, PR13470
The comment tells the story on what I broke with what was supposed to
be just a cleanup patch.
Applying mainline and branch.
PR ld/13470
* elf32-ppc.c (ppc_elf_copy_indirect_symbol): Revert substantive
change in 2011-07-01 commit. Comment.
* elf64-ppc.c (ppc64_elf_copy_indirect_symbol): Likewise.
Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.305
diff -u -p -r1.305 elf32-ppc.c
--- bfd/elf32-ppc.c 21 Nov 2011 13:18:07 -0000 1.305
+++ bfd/elf32-ppc.c 3 Dec 2011 00:33:05 -0000
@@ -2987,10 +2987,6 @@ ppc_elf_copy_indirect_symbol (struct bfd
edir->elf.needs_plt |= eind->elf.needs_plt;
edir->elf.pointer_equality_needed |= eind->elf.pointer_equality_needed;
- /* If we were called to copy over info for a weak sym, that's all. */
- if (eind->elf.root.type != bfd_link_hash_indirect)
- return;
-
if (eind->dyn_relocs != NULL)
{
if (edir->dyn_relocs != NULL)
@@ -3022,6 +3018,16 @@ ppc_elf_copy_indirect_symbol (struct bfd
eind->dyn_relocs = NULL;
}
+ /* If we were called to copy over info for a weak sym, that's all.
+ You might think dyn_relocs need not be copied over; After all,
+ both syms will be dynamic or both non-dynamic so we're just
+ moving reloc accounting around. However, ELIMINATE_COPY_RELOCS
+ code in ppc_elf_adjust_dynamic_symbol needs to check for
+ dyn_relocs in read-only sections, and it does so on what is the
+ DIR sym here. */
+ if (eind->elf.root.type != bfd_link_hash_indirect)
+ return;
+
/* Copy over the GOT refcount entries that we may have already seen to
the symbol which just became indirect. */
edir->elf.got.refcount += eind->elf.got.refcount;
Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.371
diff -u -p -r1.371 elf64-ppc.c
--- bfd/elf64-ppc.c 21 Nov 2011 13:18:07 -0000 1.371
+++ bfd/elf64-ppc.c 3 Dec 2011 00:33:07 -0000
@@ -4435,10 +4441,6 @@ ppc64_elf_copy_indirect_symbol (struct b
edir->elf.ref_regular_nonweak |= eind->elf.ref_regular_nonweak;
edir->elf.needs_plt |= eind->elf.needs_plt;
- /* If we were called to copy over info for a weak sym, that's all. */
- if (eind->elf.root.type != bfd_link_hash_indirect)
- return;
-
/* Copy over any dynamic relocs we may have on the indirect sym. */
if (eind->dyn_relocs != NULL)
{
@@ -4471,6 +4473,16 @@ ppc64_elf_copy_indirect_symbol (struct b
eind->dyn_relocs = NULL;
}
+ /* If we were called to copy over info for a weak sym, that's all.
+ You might think dyn_relocs need not be copied over; After all,
+ both syms will be dynamic or both non-dynamic so we're just
+ moving reloc accounting around. However, ELIMINATE_COPY_RELOCS
+ code in ppc64_elf_adjust_dynamic_symbol needs to check for
+ dyn_relocs in read-only sections, and it does so on what is the
+ DIR sym here. */
+ if (eind->elf.root.type != bfd_link_hash_indirect)
+ return;
+
/* Copy over got entries that we may have already seen to the
symbol which just became indirect. */
if (eind->elf.got.glist != NULL)
--
Alan Modra
Australia Development Lab, IBM