This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: powerpc64-linux finishing touches
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: binutils at sources dot redhat dot com
- Date: Thu, 2 May 2002 22:02:46 +0930
- Subject: Re: powerpc64-linux finishing touches
- References: <20020502094655.GF3698@bubble.sa.bigpond.net.au>
Hmm, I shouldn't believe comments, or existing gas code for that
matter. According to the SYS4 PPC ABI and PPC-ELF64 ABI,
R_PPC{,64}_SECTOFF is a 16 bit reloc. This patch corrects
both ppc64 and ppc32. Note that ppc32 could never have used this
reloc anyway, as dst_mask was zero!
bfd/ChangeLog
* elf64-ppc.c (ppc64_elf_howto_raw <R_PPC64_SECTOFF>): Change to a
16 bit reloc.
<R_PPC64_SECTOFF_DS>: Likewise.
(ppc64_elf_reloc_type_lookup): Map from BFD_RELOC_16_BASEREL to
SECTOFF reloc.
* elf32-ppc.c (ppc_elf_howto_raw <R_PPC_SECTOFF>): Correct.
(ppc_elf_reloc_type_lookup): Map from BFD_RELOC_16_BASEREL to
SECTOFF reloc.
gas/ChangeLog
* config/tc-ppc.c (mapping): Map sectoff to BFD_RELOC_16_BASEREL.
(ppc_elf_validate_fix): Replace BFD_RELOC_32_BASEREL with
BFD_RELOC_16_BASEREL.
(md_assemble): Likewise.
(md_apply_fix3): Likewise.
Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.35
diff -u -p -r1.35 elf64-ppc.c
--- bfd/elf64-ppc.c 2 May 2002 09:48:13 -0000 1.35
+++ bfd/elf64-ppc.c 2 May 2002 11:43:16 -0000
@@ -617,11 +617,11 @@ static reloc_howto_type ppc64_elf_howto_
0xffff, /* dst_mask */
false), /* pcrel_offset */
- /* 32-bit section relative relocation. */
+ /* 16-bit section relative relocation. */
HOWTO (R_PPC64_SECTOFF, /* type */
0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
false, /* pc_relative */
0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
@@ -629,10 +629,10 @@ static reloc_howto_type ppc64_elf_howto_
"R_PPC64_SECTOFF", /* name */
false, /* partial_inplace */
0, /* src_mask */
- 0xffffffff, /* dst_mask */
+ 0xffff, /* dst_mask */
false), /* pcrel_offset */
- /* 16-bit lower half section relative relocation. */
+ /* Like R_PPC64_SECTOFF, but no overflow warning. */
HOWTO (R_PPC64_SECTOFF_LO, /* type */
0, /* rightshift */
1, /* size (0 = byte, 1 = short, 2 = long) */
@@ -1072,8 +1072,8 @@ static reloc_howto_type ppc64_elf_howto_
/* Like R_PPC64_SECTOFF, but for instructions with a DS field. */
HOWTO (R_PPC64_SECTOFF_DS, /* type */
0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
false, /* pc_relative */
0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
@@ -1081,7 +1081,7 @@ static reloc_howto_type ppc64_elf_howto_
"R_PPC64_SECTOFF_DS", /* name */
false, /* partial_inplace */
0, /* src_mask */
- 0xfffffffc, /* dst_mask */
+ 0xfffc, /* dst_mask */
false), /* pcrel_offset */
/* Like R_PPC64_SECTOFF_LO, but for instructions with a DS field. */
@@ -1280,7 +1280,7 @@ ppc64_elf_reloc_type_lookup (abfd, code)
break;
case BFD_RELOC_HI16_S_PLTOFF: ppc_reloc = R_PPC64_PLT16_HA;
break;
- case BFD_RELOC_32_BASEREL: ppc_reloc = R_PPC64_SECTOFF;
+ case BFD_RELOC_16_BASEREL: ppc_reloc = R_PPC64_SECTOFF;
break;
case BFD_RELOC_LO16_BASEREL: ppc_reloc = R_PPC64_SECTOFF_LO;
break;
Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.41
diff -u -p -r1.41 elf32-ppc.c
--- bfd/elf32-ppc.c 15 Apr 2002 08:47:03 -0000 1.41
+++ bfd/elf32-ppc.c 2 May 2002 11:43:11 -0000
@@ -679,20 +679,20 @@ static reloc_howto_type ppc_elf_howto_ra
0xffff, /* dst_mask */
false), /* pcrel_offset */
- /* 32-bit section relative relocation. */
+ /* 16-bit section relative relocation. */
HOWTO (R_PPC_SECTOFF, /* type */
0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- true, /* pc_relative */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
bfd_elf_generic_reloc, /* special_function */
"R_PPC_SECTOFF", /* name */
false, /* partial_inplace */
0, /* src_mask */
- 0, /* dst_mask */
- true), /* pcrel_offset */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
/* 16-bit lower half section relative relocation. */
HOWTO (R_PPC_SECTOFF_LO, /* type */
@@ -1295,7 +1295,7 @@ ppc_elf_reloc_type_lookup (abfd, code)
case BFD_RELOC_HI16_PLTOFF: ppc_reloc = R_PPC_PLT16_HI; break;
case BFD_RELOC_HI16_S_PLTOFF: ppc_reloc = R_PPC_PLT16_HA; break;
case BFD_RELOC_GPREL16: ppc_reloc = R_PPC_SDAREL16; break;
- case BFD_RELOC_32_BASEREL: ppc_reloc = R_PPC_SECTOFF; break;
+ case BFD_RELOC_16_BASEREL: ppc_reloc = R_PPC_SECTOFF; break;
case BFD_RELOC_LO16_BASEREL: ppc_reloc = R_PPC_SECTOFF_LO; break;
case BFD_RELOC_HI16_BASEREL: ppc_reloc = R_PPC_SECTOFF_HI; break;
case BFD_RELOC_HI16_S_BASEREL: ppc_reloc = R_PPC_SECTOFF_HA; break;
Index: gas/config/tc-ppc.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ppc.c,v
retrieving revision 1.45
diff -u -p -r1.45 tc-ppc.c
--- gas/config/tc-ppc.c 18 Mar 2002 12:46:11 -0000 1.45
+++ gas/config/tc-ppc.c 2 May 2002 11:43:20 -0000
@@ -1378,7 +1378,7 @@ ppc_elf_suffix (str_p, exp_p)
MAP ("plt@h", (int) BFD_RELOC_HI16_PLTOFF),
MAP ("plt@ha", (int) BFD_RELOC_HI16_S_PLTOFF),
MAP ("sdarel", (int) BFD_RELOC_GPREL16),
- MAP ("sectoff", (int) BFD_RELOC_32_BASEREL),
+ MAP ("sectoff", (int) BFD_RELOC_16_BASEREL),
MAP ("sectoff@l", (int) BFD_RELOC_LO16_BASEREL),
MAP ("sectoff@h", (int) BFD_RELOC_HI16_BASEREL),
MAP ("sectoff@ha", (int) BFD_RELOC_HI16_S_BASEREL),
@@ -1687,7 +1687,7 @@ ppc_elf_validate_fix (fixp, seg)
&& fixp->fx_r_type != BFD_RELOC_HI16_GOTOFF
&& fixp->fx_r_type != BFD_RELOC_LO16_GOTOFF
&& fixp->fx_r_type != BFD_RELOC_HI16_S_GOTOFF
- && fixp->fx_r_type != BFD_RELOC_32_BASEREL
+ && fixp->fx_r_type != BFD_RELOC_16_BASEREL
&& fixp->fx_r_type != BFD_RELOC_LO16_BASEREL
&& fixp->fx_r_type != BFD_RELOC_HI16_BASEREL
&& fixp->fx_r_type != BFD_RELOC_HI16_S_BASEREL
@@ -2240,7 +2265,7 @@ md_assemble (str)
case BFD_RELOC_LO16_PLTOFF:
reloc = BFD_RELOC_PPC64_PLT16_LO_DS;
break;
- case BFD_RELOC_32_BASEREL:
+ case BFD_RELOC_16_BASEREL:
reloc = BFD_RELOC_PPC64_SECTOFF_DS;
break;
case BFD_RELOC_LO16_BASEREL:
@@ -5284,7 +5309,6 @@ md_apply_fix3 (fixP, valP, seg)
case BFD_RELOC_RVA:
case BFD_RELOC_32_PCREL:
- case BFD_RELOC_32_BASEREL:
case BFD_RELOC_PPC_EMB_NADDR32:
md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where,
value, 4);
@@ -5309,6 +5333,7 @@ md_apply_fix3 (fixP, valP, seg)
case BFD_RELOC_LO16_GOTOFF:
case BFD_RELOC_HI16_GOTOFF:
case BFD_RELOC_HI16_S_GOTOFF:
+ case BFD_RELOC_16_BASEREL:
case BFD_RELOC_LO16_BASEREL:
case BFD_RELOC_HI16_BASEREL:
case BFD_RELOC_HI16_S_BASEREL:
--
Alan Modra
IBM OzLabs - Linux Technology Centre