diff options
author | Stafford Horne <shorne@gmail.com> | 2021-05-06 20:51:24 +0900 |
---|---|---|
committer | Stafford Horne <shorne@gmail.com> | 2021-05-06 20:51:24 +0900 |
commit | 0b3e14c90283c5d234884d0ebe8510bc3c9bc687 (patch) | |
tree | fb335ba73d837382eb109019f7e4b8ac8f379501 /bfd | |
parent | a76ef689b60405e494cb99e198acf3c82f467f7d (diff) | |
download | gdb-0b3e14c90283c5d234884d0ebe8510bc3c9bc687.zip gdb-0b3e14c90283c5d234884d0ebe8510bc3c9bc687.tar.gz gdb-0b3e14c90283c5d234884d0ebe8510bc3c9bc687.tar.bz2 |
or1k: Implement relocation R_OR1K_GOT_AHI16 for gotha()
The gotha() relocation mnemonic will be outputted by OpenRISC GCC when
using the -mcmodel=large option. This relocation is used along with
got() to generate 32-bit GOT offsets. This increases the previous GOT
offset limit from the previous 16-bit (64K) limit.
This is needed on large binaries where the GOT grows larger than 64k.
bfd/ChangeLog:
PR 21464
* bfd-in2.h: Add BFD_RELOC_OR1K_GOT_AHI16 relocation.
* elf32-or1k.c (or1k_elf_howto_table, or1k_reloc_map): Likewise.
(or1k_final_link_relocate, or1k_elf_relocate_section,
or1k_elf_check_relocs): Likewise.
* libbfd.h (bfd_reloc_code_real_names): Likewise.
* reloc.c: Likewise.
cpu/ChangeLog:
PR 21464
* or1k.opc (or1k_imm16_relocs, parse_reloc): Define parse logic
for gotha() relocation.
include/ChangeLog:
PR 21464
* elf/or1k.h (elf_or1k_reloc_type): Define R_OR1K_GOT_AHI16 number.
opcodes/ChangeLog:
PR 21464
* or1k-asm.c: Regenerate.
gas/ChangeLog:
PR 21464
* testsuite/gas/or1k/reloc-1.s: Add test for new relocation.
* testsuite/gas/or1k/reloc-1.d: Add test result for new
relocation.
Cc: Giulio Benetti <giulio.benetti@benettiengineering.com>
fixup reloc, add tests
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 10 | ||||
-rw-r--r-- | bfd/bfd-in2.h | 1 | ||||
-rw-r--r-- | bfd/elf32-or1k.c | 21 | ||||
-rw-r--r-- | bfd/libbfd.h | 1 | ||||
-rw-r--r-- | bfd/reloc.c | 2 |
5 files changed, 34 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 7a6b9a1..c4a83df 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,15 @@ 2021-05-06 Stafford Horne <shorne@gmail.com> + PR 21464 + * bfd-in2.h: Add BFD_RELOC_OR1K_GOT_AHI16 relocation. + * elf32-or1k.c (or1k_elf_howto_table, or1k_reloc_map): Likewise. + (or1k_final_link_relocate, or1k_elf_relocate_section, + or1k_elf_check_relocs): Likewise. + * libbfd.h (bfd_reloc_code_real_names): Likewise. + * reloc.c: Likewise. + +2021-05-06 Stafford Horne <shorne@gmail.com> + PR 27624 * elf32-or1k.c (or1k_elf_adjust_dynamic_symbol): Change condition used to cleanup plt entries to cleanup forced local diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index d5780e4..7650522 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -5032,6 +5032,7 @@ then it may be truncated to 8 bits. */ BFD_RELOC_OR1K_TLS_TPOFF, BFD_RELOC_OR1K_TLS_DTPOFF, BFD_RELOC_OR1K_TLS_DTPMOD, + BFD_RELOC_OR1K_GOT_AHI16, /* H8 elf Relocations. */ BFD_RELOC_H8_DIR16A8, diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c index cc6c512..1b8938d 100644 --- a/bfd/elf32-or1k.c +++ b/bfd/elf32-or1k.c @@ -808,6 +808,20 @@ static reloc_howto_type or1k_elf_howto_table[] = 0, /* Source Mask. */ 0x03ffffff, /* Dest Mask. */ true), /* PC relative offset? */ + + HOWTO (R_OR1K_GOT_AHI16, /* type */ + 16, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_OR1K_GOT_AHI16", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ }; /* Map BFD reloc types to Or1k ELF reloc types. */ @@ -871,6 +885,7 @@ static const struct or1k_reloc_map or1k_reloc_map[] = { BFD_RELOC_OR1K_TLS_IE_LO13, R_OR1K_TLS_IE_LO13 }, { BFD_RELOC_OR1K_SLO13, R_OR1K_SLO13 }, { BFD_RELOC_OR1K_PLTA26, R_OR1K_PLTA26 }, + { BFD_RELOC_OR1K_GOT_AHI16, R_OR1K_GOT_AHI16 }, }; /* tls_type is a mask used to track how each symbol is accessed, @@ -1111,6 +1126,7 @@ or1k_final_link_relocate (reloc_howto_type *howto, bfd *input_bfd, switch (howto->type) { case R_OR1K_AHI16: + case R_OR1K_GOT_AHI16: case R_OR1K_GOTOFF_AHI16: case R_OR1K_TLS_IE_AHI16: case R_OR1K_TLS_LE_AHI16: @@ -1373,6 +1389,7 @@ or1k_elf_relocate_section (bfd *output_bfd, } break; + case R_OR1K_GOT_AHI16: case R_OR1K_GOT16: case R_OR1K_GOT_PG21: case R_OR1K_GOT_LO13: @@ -1464,7 +1481,8 @@ or1k_elf_relocate_section (bfd *output_bfd, /* The GOT_PG21 and GOT_LO13 relocs are pc-relative, while the GOT16 reloc is GOT relative. */ relocation = got_base + off; - if (r_type == R_OR1K_GOT16) + if (r_type == R_OR1K_GOT16 + || r_type == R_OR1K_GOT_AHI16) relocation -= got_sym_value; /* Addend should be zero. */ @@ -1990,6 +2008,7 @@ or1k_elf_check_relocs (bfd *abfd, } break; + case R_OR1K_GOT_AHI16: case R_OR1K_GOT16: case R_OR1K_GOT_PG21: case R_OR1K_GOT_LO13: diff --git a/bfd/libbfd.h b/bfd/libbfd.h index f3a32fa..bbd3b0d 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -2774,6 +2774,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_OR1K_TLS_TPOFF", "BFD_RELOC_OR1K_TLS_DTPOFF", "BFD_RELOC_OR1K_TLS_DTPMOD", + "BFD_RELOC_OR1K_GOT_AHI16", "BFD_RELOC_H8_DIR16A8", "BFD_RELOC_H8_DIR16R8", "BFD_RELOC_H8_DIR24A8", diff --git a/bfd/reloc.c b/bfd/reloc.c index 674b075..6d920e1 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -6207,6 +6207,8 @@ ENUMX ENUMX BFD_RELOC_OR1K_GOTPC_LO16 ENUMX + BFD_RELOC_OR1K_GOT_AHI16 +ENUMX BFD_RELOC_OR1K_GOT16 ENUMX BFD_RELOC_OR1K_GOT_PG21 |