This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [BUG] powerpc-linux-ld not handling R_PPC_GOT16_HA relocations correctly
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Peter Bergner <bergner at vnet dot ibm dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Fri, 10 Jan 2003 09:19:01 +1030
- Subject: Re: [BUG] powerpc-linux-ld not handling R_PPC_GOT16_HA relocations correctly
- References: <3E1D887A.5040900@vnet.ibm.com>
On Thu, Jan 09, 2003 at 08:34:34AM -0600, Peter Bergner wrote:
> I think your problem is that ld didn't compute the R_PPC_GOT16_HA
> reloc correctly.
Indeed. ppc64 suffers from the same problem too.
* elf32-ppc.c (ppc_elf_relocate_section): Adjust addend for GOT16_HA.
* elf64-ppc.c (ppc64_elf_relocate_section): Likewise. PLTGOT16_HA too.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.60
diff -u -p -r1.60 elf32-ppc.c
--- bfd/elf32-ppc.c 18 Dec 2002 13:16:35 -0000 1.60
+++ bfd/elf32-ppc.c 9 Jan 2003 22:43:26 -0000
@@ -3414,6 +3414,8 @@ ppc_elf_relocate_section (output_bfd, in
relocation = sgot->output_offset + off - 4;
}
+ if (r_type == R_PPC_GOT16_HA)
+ addend += ((relocation + addend) & 0x8000) << 1;
break;
/* Indirect .sdata relocation */
Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.76
diff -u -p -r1.76 elf64-ppc.c
--- bfd/elf64-ppc.c 12 Dec 2002 10:17:14 -0000 1.76
+++ bfd/elf64-ppc.c 9 Jan 2003 22:45:46 -0000
@@ -5903,6 +5903,8 @@ ppc64_elf_relocate_section (output_bfd,
case R_PPC64_ADDR16_HA:
case R_PPC64_ADDR16_HIGHERA:
case R_PPC64_ADDR16_HIGHESTA:
+ case R_PPC64_GOT16_HA:
+ case R_PPC64_PLTGOT16_HA:
case R_PPC64_PLT16_HA:
case R_PPC64_TOC16_HA:
case R_PPC64_SECTOFF_HA: