diff options
author | Clément Chigot <clement.chigot@atos.net> | 2021-03-11 11:08:19 +0100 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2021-03-12 22:47:23 +1030 |
commit | 4a403be0c1b4540e22c8c608ea0bfecbf0f85e51 (patch) | |
tree | 3908b8d38af9e56e3fd960da596c4d600f5915c5 /bfd/coff64-rs6000.c | |
parent | 2c1bef53dee85aede31e6de6fa8276d6869f6512 (diff) | |
download | gdb-4a403be0c1b4540e22c8c608ea0bfecbf0f85e51.zip gdb-4a403be0c1b4540e22c8c608ea0bfecbf0f85e51.tar.gz gdb-4a403be0c1b4540e22c8c608ea0bfecbf0f85e51.tar.bz2 |
aix: implement R_TOCU and R_TOCL relocations
Implement support for largetoc on XCOFF.
R_TOCU and R_TOCL are referenced by the new BFD defines:
BFD_RELOC_PPC_TOC16_HI and BFD_RELOC_PPC_TOC16_LO.
A new toc storage class is added XMC_TE.
In order to correctly handle R_TOCU, the logic behind
xcoff_reloc_type_toc is changed to compute the whole TOC offset
instead of just the difference between the "link" offset and the
"assembly" offset.
In gas, add a function to transform addis format used by AIX
"addis RT, D(RA)" into the ELF format "addis RT, RA, SI".
bfd/
* reloc.c (BFD_RELOC_PPC_TOC16_HI, BFD_RELOC_PPC_TOC16_LO):
New relocations.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
* coff-rs6000.c (xcoff_calculate_relocation): Call
xcoff_reloc_type_toc for R_TOCU and R_TOCL.
(xcoff_howto_table): Remove src_mask for TOC relocations.
Add R_TOCU and R_TOCL howtos.
(_bfd_xcoff_reloc_type_lookup): Add cases for
BFD_RELOC_PPC_TOC16_HI and BFD_RELOC_PPC_TOC16_LO.
(xcoff_reloc_type_toc): Compute the whole offset.
Implement R_TOCU and R_TOCL.
* coff64-rs6000.c (xcoff64_calculate_relocation):
Likewise.
(xcoff64_howto_table): Likewise.
(xcoff64_reloc_type_lookup): Likewise.
gas/
* config/tc-ppc.c (ppc_xcoff_suffix): New function.
(MAP, MAP32, MAP64): New macros for XCOFF.
(ppc_xcoff_fixup_addis): New function.
(ppc_is_toc_sym): Handle XMC_TE.
(fixup_size): Add cases for BFD_RELOC_PPC_TOC16_HI and
BFD_RELOC_PPC_TOC16_LO.
(md_assemble): Call ppc_xcoff_fixup_addis for XCOFF.
(ppc_change_csect): Handle XMC_TE.
(ppc_tc): Enable .tc symbols to have only a XMC_TC or XMC_TE
storage class.
(ppc_symbol_new_hook): Handle XMC_TE.
(ppc_frob_symbol): Likewise.
(ppc_fix_adjustable): Likewise.
(md_apply_fix): Handle BFD_RELOC_PPC_TOC16_HI and
BFD_RELOC_PPC_TOC16_LO.
ld/
* scripttempl/aix.sc: Add .te to .data section.
* testsuite/ld-powerpc/aix52.exp: Add test structure for AIX7+.
Add aix-largetoc-1 test.
* testsuite/ld-powerpc/aix-largetoc-1-32.d: New test.
* testsuite/ld-powerpc/aix-largetoc-1-64.d: New test.
* testsuite/ld-powerpc/aix-largetoc-1.ex: New test.
* testsuite/ld-powerpc/aix-largetoc-1.s: New test.
Diffstat (limited to 'bfd/coff64-rs6000.c')
-rw-r--r-- | bfd/coff64-rs6000.c | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c index 0cb7e8b..55a6821 100644 --- a/bfd/coff64-rs6000.c +++ b/bfd/coff64-rs6000.c @@ -228,8 +228,8 @@ xcoff64_calculate_relocation[XCOFF_MAX_CALCULATE_RELOCATION] = xcoff_reloc_type_fail, /* (0x2d) */ xcoff_reloc_type_fail, /* (0x2e) */ xcoff_reloc_type_fail, /* (0x2f) */ - xcoff_reloc_type_fail, /* R_TOCU (0x30) */ - xcoff_reloc_type_fail, /* R_TOCL (0x31) */ + xcoff_reloc_type_toc, /* R_TOCU (0x30) */ + xcoff_reloc_type_toc, /* R_TOCL (0x31) */ }; /* coffcode.h needs these to be defined. */ @@ -899,7 +899,7 @@ reloc_howto_type xcoff64_howto_table[] = 0, /* special_function */ "R_TOC", /* name */ TRUE, /* partial_inplace */ - 0xffff, /* src_mask */ + 0, /* src_mask */ 0xffff, /* dst_mask */ FALSE), /* pcrel_offset */ @@ -914,7 +914,7 @@ reloc_howto_type xcoff64_howto_table[] = 0, /* special_function */ "R_TRL", /* name */ TRUE, /* partial_inplace */ - 0xffff, /* src_mask */ + 0, /* src_mask */ 0xffff, /* dst_mask */ FALSE), /* pcrel_offset */ @@ -929,7 +929,7 @@ reloc_howto_type xcoff64_howto_table[] = 0, /* special_function */ "R_GL", /* name */ TRUE, /* partial_inplace */ - 0xffff, /* src_mask */ + 0, /* src_mask */ 0xffff, /* dst_mask */ FALSE), /* pcrel_offset */ @@ -944,7 +944,7 @@ reloc_howto_type xcoff64_howto_table[] = 0, /* special_function */ "R_TCL", /* name */ TRUE, /* partial_inplace */ - 0xffff, /* src_mask */ + 0, /* src_mask */ 0xffff, /* dst_mask */ FALSE), /* pcrel_offset */ @@ -1260,11 +1260,34 @@ reloc_howto_type xcoff64_howto_table[] = EMPTY_HOWTO(0x2e), EMPTY_HOWTO(0x2f), - /* 0x30: High-order 16 bit TOC relative relocation. */ - EMPTY_HOWTO (R_TOCU), + HOWTO (R_TOCU, /* type */ + 16, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + 0, /* special_function */ + "R_TOCU", /* name */ + TRUE, /* partial_inplace */ + 0, /* src_mask */ + 0xffff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* 0x31: Low-order 16 bit TOC relative relocation. */ - EMPTY_HOWTO (R_TOCL), + HOWTO (R_TOCL, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + 0, /* special_function */ + "R_TOCL", /* name */ + TRUE, /* partial_inplace */ + 0, /* src_mask */ + 0xffff, /* dst_mask */ + FALSE), /* pcrel_offset */ }; @@ -1319,6 +1342,10 @@ xcoff64_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, return &xcoff64_howto_table[8]; case BFD_RELOC_PPC_TOC16: return &xcoff64_howto_table[3]; + case BFD_RELOC_PPC_TOC16_HI: + return &xcoff64_howto_table[0x30]; + case BFD_RELOC_PPC_TOC16_LO: + return &xcoff64_howto_table[0x31]; case BFD_RELOC_PPC_B16: return &xcoff64_howto_table[0x1e]; case BFD_RELOC_32: |