This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PowerPC ld --relax vs -fPIC code
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: binutils at sourceware dot org
- Date: Wed, 6 Aug 2008 17:03:14 +0930
- Subject: PowerPC ld --relax vs -fPIC code
Fixes a bug in ppc ld --relax. If relaxing code which has PLTREL24
relocs with the magic got2 offset addends (as in -fPIC) and the
PLTREL24 symbol resolves locally rather than going via the plt, then
the addend made its way into the trampoline. Typically this meant
that the trampoline bounced 32k away from where it should have landed.
* elf32-ppc.c (ppc_elf_relax_section): Clear R_PPC_PLTREL24 addend.
(ppc_elf_relocate_section <R_PPC_RELAX32_PLT>): Don't bother here.
Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.241
diff -u -p -r1.241 elf32-ppc.c
--- bfd/elf32-ppc.c 26 Jul 2008 13:10:47 -0000 1.241
+++ bfd/elf32-ppc.c 6 Aug 2008 07:13:20 -0000
@@ -5797,6 +5797,8 @@ ppc_elf_relax_section (bfd *abfd,
irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
stub_rtype);
irel->r_offset = trampoff + insn_offset;
+ if (r_type == R_PPC_PLTREL24)
+ irel->r_addend = 0;
/* Record the fixup so we don't do it again this section. */
f = bfd_malloc (sizeof (*f));
@@ -5879,7 +5881,7 @@ ppc_elf_relax_section (bfd *abfd,
isec->size = (isec->size + 3) & (bfd_vma) -4;
/* Branch around the trampolines. */
- val = trampoff - isec->size + 0x48000000;
+ val = B + trampoff - isec->size;
dest = contents + isec->size;
isec->size = trampoff;
bfd_put_32 (abfd, val, dest);
@@ -6911,7 +6913,6 @@ ppc_elf_relocate_section (bfd *output_bf
relocation = (htab->plt->output_section->vma
+ htab->plt->output_offset
+ ent->plt.offset);
- addend = 0;
}
if (r_type == R_PPC_RELAX32_PLT)
goto relax32;
--
Alan Modra
Australia Development Lab, IBM