Start work to all full PowerPC V.4 reloc support.

This commit is contained in:
Michael Meissner 1995-09-22 20:30:18 +00:00
parent d9677195b1
commit 02f85cda33
4 changed files with 119 additions and 40 deletions

View File

@ -1,3 +1,16 @@
Fri Sep 22 16:23:18 1995 Michael Meissner <meissner@tiktok.cygnus.com>
* reloc.c (bfd_reloc_code_type): Add relocations to support all of
PowerPC V.4.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
* elf32-ppc.c (reloc_type): Update names to match current draft.
(ppc_elf_howto_raw): Mark 14 bit relocs as short sized and PC
relative. Update names to current V.4 draft.
(ppc_elf_reloc_type_lookup): Add support for more relocations.
(ppc_elf_relocate_section): Rename relocations to match draft.
Thu Sep 21 21:53:18 1995 Michael Meissner <meissner@cygnus.com>
* elf32-ppc.c (ppc_elf_merge_private_bfd_data): Allow modules

View File

@ -1355,12 +1355,19 @@ The 24-bit relocation is used in some Intel 960 configurations. */
BFD_RELOC_8_GOT_PCREL,
BFD_RELOC_32_GOTOFF,
BFD_RELOC_16_GOTOFF,
BFD_RELOC_LO16_GOTOFF,
BFD_RELOC_HI16_GOTOFF,
BFD_RELOC_HI16_S_GOTOFF,
BFD_RELOC_8_GOTOFF,
BFD_RELOC_32_PLT_PCREL,
BFD_RELOC_24_PLT_PCREL,
BFD_RELOC_16_PLT_PCREL,
BFD_RELOC_8_PLT_PCREL,
BFD_RELOC_32_PLTOFF,
BFD_RELOC_16_PLTOFF,
BFD_RELOC_LO16_PLTOFF,
BFD_RELOC_HI16_PLTOFF,
BFD_RELOC_HI16_S_PLTOFF,
BFD_RELOC_8_PLTOFF,
/* Relocations used by 68K ELF. */
@ -1371,6 +1378,9 @@ The 24-bit relocation is used in some Intel 960 configurations. */
/* Linkage-table relative. */
BFD_RELOC_32_BASEREL,
BFD_RELOC_16_BASEREL,
BFD_RELOC_LO16_BASEREL,
BFD_RELOC_HI16_BASEREL,
BFD_RELOC_HI16_S_BASEREL,
BFD_RELOC_8_BASEREL,
BFD_RELOC_RVA,
@ -1538,16 +1548,21 @@ to compensate for the borrow when the low bits are added. */
BFD_RELOC_NS32K_DISP_16_PCREL,
BFD_RELOC_NS32K_DISP_32_PCREL,
/* PowerPC/POWER (RS/6000) relocs.
26 bit relative branch. Low two bits must be zero. High 24
bits installed in bits 6 through 29 of instruction. */
/* Power(rs6000) and PowerPC relocations. */
BFD_RELOC_PPC_B26,
/* 26 bit absolute branch, like BFD_RELOC_PPC_B26 but absolute. */
BFD_RELOC_PPC_BA26,
/* 16 bit TOC relative reference. */
BFD_RELOC_PPC_TOC16,
BFD_RELOC_PPC_B16,
BFD_RELOC_PPC_B16_BRTAKEN,
BFD_RELOC_PPC_B16_BRNTAKEN,
BFD_RELOC_PPC_BA16,
BFD_RELOC_PPC_BA16_BRTAKEN,
BFD_RELOC_PPC_BA16_BRNTAKEN,
BFD_RELOC_PPC_COPY,
BFD_RELOC_PPC_GLOB_DAT,
BFD_RELOC_PPC_JMP_SLOT,
BFD_RELOC_PPC_RELATIVE,
BFD_RELOC_PPC_LOCAL24PC,
/* The type of reloc used to build a contructor table - at the moment
probably a 32 bit wide absolute relocation, but the target can choose.

View File

@ -81,9 +81,9 @@ enum reloc_type
R_PPC_GOT16_LO, /* 15 */
R_PPC_GOT16_HI, /* 16 */
R_PPC_GOT16_HA, /* 17 */
R_PPC_PLT24, /* 18 */
R_PPC_PLTREL24, /* 18 */
R_PPC_COPY, /* 19 */
R_PPC_GLOB_DAT, /* 20 -- not in final System V spec */
R_PPC_GLOB_DAT, /* 20 */
R_PPC_JMP_SLOT, /* 21 */
R_PPC_RELATIVE, /* 22 */
R_PPC_LOCAL24PC, /* 23 */
@ -95,7 +95,7 @@ enum reloc_type
R_PPC_PLT16_LO, /* 29 */
R_PPC_PLT16_HI, /* 30 */
R_PPC_PLT16_HA, /* 31 */
R_PPC_SDAREL, /* 32 */
R_PPC_SDAREL16, /* 32 */
/* Relocations added by Sun. */
R_PPC_SECTOFF, /* 33 */
@ -240,7 +240,7 @@ static reloc_howto_type ppc_elf_howto_raw[] =
FIXME: we don't check that, we just clear them. */
HOWTO (R_PPC_ADDR14, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
1, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
false, /* pc_relative */
0, /* bitpos */
@ -257,7 +257,7 @@ static reloc_howto_type ppc_elf_howto_raw[] =
bits must be zero. */
HOWTO (R_PPC_ADDR14_BRTAKEN, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
1, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
false, /* pc_relative */
0, /* bitpos */
@ -274,7 +274,7 @@ static reloc_howto_type ppc_elf_howto_raw[] =
two bits must be zero. */
HOWTO (R_PPC_ADDR14_BRNTAKEN, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
1, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
false, /* pc_relative */
0, /* bitpos */
@ -304,7 +304,7 @@ static reloc_howto_type ppc_elf_howto_raw[] =
/* A relative 16 bit branch; the lower two bits must be zero. */
HOWTO (R_PPC_REL14, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
1, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
true, /* pc_relative */
0, /* bitpos */
@ -321,12 +321,12 @@ static reloc_howto_type ppc_elf_howto_raw[] =
zero. */
HOWTO (R_PPC_REL14_BRTAKEN, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
1, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
false, /* pc_relative */
true, /* pc_relative */
0, /* bitpos */
complain_overflow_signed, /* complain_on_overflow */
ppc_elf_unsupported_reloc, /* special_function */
ppc_elf_std_reloc, /* special_function */
"R_PPC_REL14_BRTAKEN", /* name */
false, /* partial_inplace */
0, /* src_mask */
@ -338,12 +338,12 @@ static reloc_howto_type ppc_elf_howto_raw[] =
be zero. */
HOWTO (R_PPC_REL14_BRNTAKEN, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
1, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
false, /* pc_relative */
true, /* pc_relative */
0, /* bitpos */
complain_overflow_signed, /* complain_on_overflow */
ppc_elf_unsupported_reloc, /* special_function */
ppc_elf_std_reloc, /* special_function */
"R_PPC_REL14_BRNTAKEN",/* name */
false, /* partial_inplace */
0, /* src_mask */
@ -416,7 +416,7 @@ static reloc_howto_type ppc_elf_howto_raw[] =
/* Like R_PPC_REL24, but referring to the procedure linkage table
entry for the symbol. FIXME: Not supported. */
HOWTO (R_PPC_PLT24, /* type */
HOWTO (R_PPC_PLTREL24, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
26, /* bitsize */
@ -424,7 +424,7 @@ static reloc_howto_type ppc_elf_howto_raw[] =
0, /* bitpos */
complain_overflow_signed, /* complain_on_overflow */
ppc_elf_std_reloc, /* special_function */
"R_PPC_PLT24", /* name */
"R_PPC_PLTREL24", /* name */
false, /* partial_inplace */
0, /* src_mask */
0x3fffffc, /* dst_mask */
@ -641,7 +641,7 @@ static reloc_howto_type ppc_elf_howto_raw[] =
/* A sign-extended 16 bit value relative to _SDA_BASE, for use with
small data items. */
HOWTO (R_PPC_SDAREL, /* type */
HOWTO (R_PPC_SDAREL16, /* type */
0, /* rightshift */
1, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
@ -649,7 +649,7 @@ static reloc_howto_type ppc_elf_howto_raw[] =
0, /* bitpos */
complain_overflow_signed, /* complain_on_overflow */
ppc_elf_got16_reloc, /* special_function */
"R_PPC_SDAREL", /* name */
"R_PPC_SDAREL16", /* name */
false, /* partial_inplace */
0, /* src_mask */
0xffff, /* dst_mask */
@ -819,25 +819,53 @@ ppc_elf_reloc_type_lookup (abfd, code)
bfd *abfd;
bfd_reloc_code_real_type code;
{
enum reloc_type ppc_reloc = R_PPC_NONE;
if (!ppc_elf_howto_table[ R_PPC_ADDR32 ]) /* Initialize howto table if needed */
ppc_elf_howto_init ();
switch ((int)code)
{
case BFD_RELOC_NONE: return ppc_elf_howto_table[ (int) R_PPC_NONE ];
case BFD_RELOC_32: return ppc_elf_howto_table[ (int) R_PPC_ADDR32 ];
case BFD_RELOC_32_PCREL: return ppc_elf_howto_table[ (int) R_PPC_REL32 ];
case BFD_RELOC_CTOR: return ppc_elf_howto_table[ (int) R_PPC_ADDR32 ];
case BFD_RELOC_PPC_B26: return ppc_elf_howto_table[ (int) R_PPC_REL24 ];
case BFD_RELOC_PPC_BA26: return ppc_elf_howto_table[ (int) R_PPC_ADDR24 ];
case BFD_RELOC_PPC_TOC16: return ppc_elf_howto_table[ (int) R_PPC_GOT16 ];
case BFD_RELOC_LO16: return ppc_elf_howto_table[ (int) R_PPC_ADDR16_LO ];
case BFD_RELOC_HI16: return ppc_elf_howto_table[ (int) R_PPC_ADDR16_HI ];
case BFD_RELOC_HI16_S: return ppc_elf_howto_table[ (int) R_PPC_ADDR16_HA ];
case BFD_RELOC_GPREL16: return ppc_elf_howto_table[ (int) R_PPC_SDAREL ];
default:
return (reloc_howto_type *)NULL;
case BFD_RELOC_NONE: ppc_reloc = R_PPC_NONE; break;
case BFD_RELOC_32: ppc_reloc = R_PPC_ADDR32; break;
case BFD_RELOC_PPC_BA26: ppc_reloc = R_PPC_ADDR24; break;
case BFD_RELOC_16: ppc_reloc = R_PPC_ADDR16; break;
case BFD_RELOC_LO16: ppc_reloc = R_PPC_ADDR16_LO; break;
case BFD_RELOC_HI16: ppc_reloc = R_PPC_ADDR16_HI; break;
case BFD_RELOC_HI16_S: ppc_reloc = R_PPC_ADDR16_HA; break;
case BFD_RELOC_PPC_BA16: ppc_reloc = R_PPC_ADDR14; break;
case BFD_RELOC_PPC_BA16_BRTAKEN: ppc_reloc = R_PPC_ADDR14_BRTAKEN; break;
case BFD_RELOC_PPC_BA16_BRNTAKEN: ppc_reloc = R_PPC_ADDR14_BRNTAKEN; break;
case BFD_RELOC_PPC_B26: ppc_reloc = R_PPC_REL24; break;
case BFD_RELOC_PPC_B16: ppc_reloc = R_PPC_REL14; break;
case BFD_RELOC_PPC_B16_BRTAKEN: ppc_reloc = R_PPC_REL14_BRTAKEN; break;
case BFD_RELOC_PPC_B16_BRNTAKEN: ppc_reloc = R_PPC_REL14_BRNTAKEN; break;
case BFD_RELOC_PPC_TOC16: ppc_reloc = R_PPC_GOT16; break;
case BFD_RELOC_LO16_GOTOFF: ppc_reloc = R_PPC_GOT16_LO; break;
case BFD_RELOC_HI16_GOTOFF: ppc_reloc = R_PPC_GOT16_HI; break;
case BFD_RELOC_HI16_S_GOTOFF: ppc_reloc = R_PPC_GOT16_HA; break;
case BFD_RELOC_24_PLT_PCREL: ppc_reloc = R_PPC_PLTREL24; break;
case BFD_RELOC_PPC_COPY: ppc_reloc = R_PPC_COPY; break;
case BFD_RELOC_PPC_GLOB_DAT: ppc_reloc = R_PPC_GLOB_DAT; break;
case BFD_RELOC_PPC_LOCAL24PC: ppc_reloc = R_PPC_LOCAL24PC; break;
case BFD_RELOC_32_PCREL: ppc_reloc = R_PPC_REL32; break;
case BFD_RELOC_32_PLTOFF: ppc_reloc = R_PPC_PLT32; break;
case BFD_RELOC_32_PLT_PCREL: ppc_reloc = R_PPC_PLTREL32; break;
case BFD_RELOC_LO16_PLTOFF: ppc_reloc = R_PPC_PLT16_LO; break;
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_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;
case BFD_RELOC_CTOR: ppc_reloc = R_PPC_ADDR32; break;
}
return (reloc_howto_type *)NULL;
return ppc_elf_howto_table[ (int)ppc_reloc ];
};
/* Set the howto pointer for a PowerPC ELF reloc. */
@ -1307,7 +1335,7 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
case (int)R_PPC_GOT16: /* GOT16 relocations */
case (int)R_PPC_GOT16_LO:
case (int)R_PPC_GOT16_HI:
case (int)R_PPC_SDAREL:
case (int)R_PPC_SDAREL16:
BFD_ASSERT (sec != (asection *)0);
addend += ppc_elf_got16_inner (sec);
break;

View File

@ -446,18 +446,20 @@ extern bfd *bfd_last_cache;
extern const bfd_target * const bfd_target_vector[];
extern const bfd_target * const bfd_default_vector[];
/* A function shared by the ECOFF and MIPS ELF backends, which have no
/* Functions shared by the ECOFF and MIPS ELF backends, which have no
other common header files. */
#if defined(__STDC__) || defined(ALMOST_STDC)
struct ecoff_find_line;
#endif
extern boolean
_bfd_ecoff_locate_line
extern boolean _bfd_ecoff_locate_line
PARAMS ((bfd *, asection *, bfd_vma, struct ecoff_debug_info * const,
const struct ecoff_debug_swap * const, struct ecoff_find_line *,
const char **, const char **, unsigned int *));
extern boolean _bfd_ecoff_get_accumulated_pdr PARAMS ((PTR, bfd_byte *));
extern boolean _bfd_ecoff_get_accumulated_sym PARAMS ((PTR, bfd_byte *));
extern boolean _bfd_ecoff_get_accumulated_ss PARAMS ((PTR, bfd_byte *));
/* And more follows */
@ -510,18 +512,28 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
"BFD_RELOC_8_GOT_PCREL",
"BFD_RELOC_32_GOTOFF",
"BFD_RELOC_16_GOTOFF",
"BFD_RELOC_LO16_GOTOFF",
"BFD_RELOC_HI16_GOTOFF",
"BFD_RELOC_HI16_S_GOTOFF",
"BFD_RELOC_8_GOTOFF",
"BFD_RELOC_32_PLT_PCREL",
"BFD_RELOC_24_PLT_PCREL",
"BFD_RELOC_16_PLT_PCREL",
"BFD_RELOC_8_PLT_PCREL",
"BFD_RELOC_32_PLTOFF",
"BFD_RELOC_16_PLTOFF",
"BFD_RELOC_LO16_PLTOFF",
"BFD_RELOC_HI16_PLTOFF",
"BFD_RELOC_HI16_S_PLTOFF",
"BFD_RELOC_8_PLTOFF",
"BFD_RELOC_68K_GLOB_DAT",
"BFD_RELOC_68K_JMP_SLOT",
"BFD_RELOC_68K_RELATIVE",
"BFD_RELOC_32_BASEREL",
"BFD_RELOC_16_BASEREL",
"BFD_RELOC_LO16_BASEREL",
"BFD_RELOC_HI16_BASEREL",
"BFD_RELOC_HI16_S_BASEREL",
"BFD_RELOC_8_BASEREL",
"BFD_RELOC_RVA",
"BFD_RELOC_8_FFnn",
@ -600,6 +612,17 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
"BFD_RELOC_PPC_B26",
"BFD_RELOC_PPC_BA26",
"BFD_RELOC_PPC_TOC16",
"BFD_RELOC_PPC_B16",
"BFD_RELOC_PPC_B16_BRTAKEN",
"BFD_RELOC_PPC_B16_BRNTAKEN",
"BFD_RELOC_PPC_BA16",
"BFD_RELOC_PPC_BA16_BRTAKEN",
"BFD_RELOC_PPC_BA16_BRNTAKEN",
"BFD_RELOC_PPC_COPY",
"BFD_RELOC_PPC_GLOB_DAT",
"BFD_RELOC_PPC_JMP_SLOT",
"BFD_RELOC_PPC_RELATIVE",
"BFD_RELOC_PPC_LOCAL24PC",
"BFD_RELOC_CTOR",
"BFD_RELOC_ARM_PCREL_BRANCH",
"BFD_RELOC_ARM_IMMEDIATE",