From: Siddhesh Poyarekar Date: Fri, 11 Sep 2020 03:48:09 +0000 (+0530) Subject: [Morello] Add Morello relocations for ADRP X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=925041050d890f90ce8411057bf21302cf4d94a5;p=thirdparty%2Fbinutils-gdb.git [Morello] Add Morello relocations for ADRP New relocations R_MORELLO_ADR_PREL_PG_HI20, R_MORELLO_ADR_PREL_PG_HI20_NC and R_MORELLO_ADR_GOT_PAGE bfd/ChangeLog: 2020-10-20 Siddhesh Poyarekar * reloc.c: Add MORELLO_ADR_HI20_PCREL, MORELLO_ADR_HI20_NC_PCREL and MORELLO_ADR_GOT_PAGE. * elfnn-aarch64.c (elfNN_aarch64_howto_table): Likewise. (aarch64_reloc_got_type): Add MORELLO_ADR_GOT_PAGE. (_bfd_aarch64_erratum_843419_branch_to_stub): Add C64 argument to _bfd_aarch64_reencode_adr_imm. (elfNN_aarch64_final_link_relocate, elfNN_aarch64_check_relocs): Add MORELLO_ADR_GOT_PAGE, MORELLO_ADR_HI20_PCREL and MORELLO_ADR_HI20_NC_PCREL. * elfxx-aarch64.c (_bfd_aarch64_reencode_adr_imm): Add C64 argument. (_bfd_aarch64_elf_put_addend): Adjust callers. * elfxx-aarch64.h (_bfd_aarch64_reencode_adr_imm): Add C64 argument. * libbfd.h (bfd_reloc_code_real_names): Add MORELLO_ADR_GOT_PAGE, MORELLO_ADR_HI20_PCREL and MORELLO_ADR_HI20_NC_PCREL. * bfd-in2.h: Regenerate. gas/ChangeLog: 2020-10-20 Siddhesh Poyarekar * config/tc-aarch64.c (reloc_table_entry): Add c64_adrp_type field. (reloc_table): Adjust. (parse_adrp): Adjust users. (md_apply_fix): Add MORELLO_ADR_GOT_PAGE, MORELLO_ADR_HI20_PCREL and MORELLO_ADR_HI20_NC_PCREL. * testsuite/gas/aarch64/morello_insn-c64.d: Adjust test. include/ChangeLog: 2020-10-20 Siddhesh Poyarekar * elf/aarch64.h: Add R_MORELLO_ADR_PREL_PG_HI20, R_MORELLO_ADR_PREL_PG_HI20_NC and R_MORELLO_ADR_GOT_PAGE. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 87370d68b62..dcec7b2f264 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,24 @@ +2020-10-20 Siddhesh Poyarekar + + * reloc.c: Add MORELLO_ADR_HI20_PCREL, + MORELLO_ADR_HI20_NC_PCREL and MORELLO_ADR_GOT_PAGE. + * elfnn-aarch64.c (elfNN_aarch64_howto_table): Likewise. + (aarch64_reloc_got_type): Add MORELLO_ADR_GOT_PAGE. + (_bfd_aarch64_erratum_843419_branch_to_stub): Add C64 argument + to _bfd_aarch64_reencode_adr_imm. + (elfNN_aarch64_final_link_relocate, + elfNN_aarch64_check_relocs): Add MORELLO_ADR_GOT_PAGE, + MORELLO_ADR_HI20_PCREL and MORELLO_ADR_HI20_NC_PCREL. + * elfxx-aarch64.c (_bfd_aarch64_reencode_adr_imm): Add C64 + argument. + (_bfd_aarch64_elf_put_addend): Adjust callers. + * elfxx-aarch64.h (_bfd_aarch64_reencode_adr_imm): Add C64 + argument. + * libbfd.h (bfd_reloc_code_real_names): Add + MORELLO_ADR_GOT_PAGE, MORELLO_ADR_HI20_PCREL and + MORELLO_ADR_HI20_NC_PCREL. + * bfd-in2.h: Regenerate. + 2020-10-20 Siddhesh Poyarekar * elfnn-aarch64.c (elfNN_aarch64_howto_table): Add diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index caa2265ae22..01a2dccde4c 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -5615,6 +5615,15 @@ offset. The lowest two bits must be zero and are not stored in the instruction, giving a 21 bit signed byte offset. */ BFD_RELOC_AARCH64_LD_LO19_PCREL, +/* Morello ADRP instruction, with bits 12 to 31 of a pc-relative page +offset, giving a 4KB aligned page base address. */ + BFD_RELOC_MORELLO_ADR_HI20_PCREL, + +/* Morello ADRP instruction, with bits 12 to 31 of a pc-relative page +offset, giving a 4KB aligned page base address, but with no overflow +checking. */ + BFD_RELOC_MORELLO_ADR_HI20_NC_PCREL, + /* AArch64 ADR instruction, holding a simple 21 bit pc-relative byte offset. */ BFD_RELOC_AARCH64_ADR_LO21_PCREL, @@ -5683,6 +5692,11 @@ part of an ADRP instruction using a 21 bit PC relative value.Used in conjunction with BFD_RELOC_AARCH64_LD64_GOT_LO12_NC. */ BFD_RELOC_AARCH64_ADR_GOT_PAGE, +/* Get to the page base of the global offset table entry for a symbol as +part of an ADRP instruction using a 20 bit PC relative value.Used in +conjunction with BFD_RELOC_MORELLO_LD128_GOT_LO12_NC. */ + BFD_RELOC_MORELLO_ADR_GOT_PAGE, + /* Unsigned 12 bit byte offset for 64 bit load/store from the page of the GOT entry for this symbol. Used in conjunction with BFD_RELOC_AARCH64_ADR_GOT_PAGE. Valid in LP64 ABI only. */ diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index 1a563fa8354..0cc63cc2889 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -858,6 +858,36 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = 0x7ffff, /* dst_mask */ TRUE), /* pcrel_offset */ + /* C64 ADRP: ((PG(S+A)-PG(P)) >> 12) & 0xfffff */ + HOWTO64 (MORELLO_R (ADR_PREL_PG_HI20), /* type */ + 12, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + MORELLO_R_STR (ADR_PREL_PG_HI20), /* name */ + FALSE, /* partial_inplace */ + 0xfffff, /* src_mask */ + 0xfffff, /* dst_mask */ + TRUE), /* pcrel_offset */ + + /* C64 ADRP: ((PG(S+A)-PG(P)) >> 12) & 0xfffff [no overflow check] */ + HOWTO64 (MORELLO_R (ADR_PREL_PG_HI20_NC), /* type */ + 12, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + MORELLO_R_STR (ADR_PREL_PG_HI20_NC), /* name */ + FALSE, /* partial_inplace */ + 0xfffff, /* src_mask */ + 0xfffff, /* dst_mask */ + TRUE), /* pcrel_offset */ + /* ADR: (S+A-P) & 0x1fffff */ HOWTO (AARCH64_R (ADR_PREL_LO21), /* type */ 0, /* rightshift */ @@ -1087,6 +1117,22 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = 0x1fffff, /* dst_mask */ TRUE), /* pcrel_offset */ + /* Get to the page for the GOT entry for the symbol + (G(S) - P) using a C64 ADRP instruction. */ + HOWTO64 (MORELLO_R (ADR_GOT_PAGE), /* type */ + 12, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 20, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + MORELLO_R_STR (ADR_GOT_PAGE), /* name */ + FALSE, /* partial_inplace */ + 0xfffff, /* src_mask */ + 0xfffff, /* dst_mask */ + TRUE), /* pcrel_offset */ + /* LD64: GOT offset G(S) & 0xff8 */ HOWTO64 (AARCH64_R (LD64_GOT_LO12_NC), /* type */ 3, /* rightshift */ @@ -5064,6 +5110,7 @@ aarch64_reloc_got_type (bfd_reloc_code_real_type r_type) switch (r_type) { case BFD_RELOC_AARCH64_ADR_GOT_PAGE: + case BFD_RELOC_MORELLO_ADR_GOT_PAGE: case BFD_RELOC_AARCH64_GOT_LD_PREL19: case BFD_RELOC_AARCH64_LD32_GOTPAGE_LO14: case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC: @@ -5394,7 +5441,7 @@ _bfd_aarch64_erratum_843419_branch_to_stub (struct bfd_hash_entry *gen_entry, if ((htab->fix_erratum_843419 & ERRAT_ADR) && (imm >= AARCH64_MIN_ADRP_IMM && imm <= AARCH64_MAX_ADRP_IMM)) { - insn = (_bfd_aarch64_reencode_adr_imm (AARCH64_ADR_OP, imm) + insn = (_bfd_aarch64_reencode_adr_imm (AARCH64_ADR_OP, imm, 0) | AARCH64_RT (insn)); bfd_putl32 (insn, contents + stub_entry->adrp_offset); /* Stub is not needed, don't map it out. */ @@ -5691,6 +5738,7 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, return _bfd_aarch64_elf_put_addend (input_bfd, hit_data, bfd_r_type, howto, value); case BFD_RELOC_AARCH64_ADR_GOT_PAGE: + case BFD_RELOC_MORELLO_ADR_GOT_PAGE: case BFD_RELOC_AARCH64_GOT_LD_PREL19: case BFD_RELOC_AARCH64_LD32_GOTPAGE_LO14: case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC: @@ -5768,6 +5816,7 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, return _bfd_aarch64_elf_put_addend (input_bfd, hit_data, bfd_r_type, howto, value); case BFD_RELOC_AARCH64_ADD_LO12: case BFD_RELOC_AARCH64_ADR_HI21_PCREL: + case BFD_RELOC_MORELLO_ADR_HI20_PCREL: break; } } @@ -5952,6 +6001,8 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, case BFD_RELOC_AARCH64_64_PCREL: case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL: case BFD_RELOC_AARCH64_ADR_HI21_PCREL: + case BFD_RELOC_MORELLO_ADR_HI20_NC_PCREL: + case BFD_RELOC_MORELLO_ADR_HI20_PCREL: case BFD_RELOC_AARCH64_ADR_LO21_PCREL: case BFD_RELOC_AARCH64_LD_LO19_PCREL: case BFD_RELOC_MORELLO_LD_LO17_PCREL: @@ -6032,6 +6083,7 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, break; case BFD_RELOC_AARCH64_ADR_GOT_PAGE: + case BFD_RELOC_MORELLO_ADR_GOT_PAGE: case BFD_RELOC_AARCH64_GOT_LD_PREL19: case BFD_RELOC_AARCH64_LD32_GOTPAGE_LO14: case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC: @@ -7775,7 +7827,9 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, case BFD_RELOC_AARCH64_ADD_LO12: case BFD_RELOC_AARCH64_ADR_GOT_PAGE: + case BFD_RELOC_MORELLO_ADR_GOT_PAGE: case BFD_RELOC_AARCH64_ADR_HI21_PCREL: + case BFD_RELOC_MORELLO_ADR_HI20_PCREL: case BFD_RELOC_AARCH64_CALL26: case BFD_RELOC_AARCH64_GOT_LD_PREL19: case BFD_RELOC_AARCH64_JUMP26: @@ -7853,6 +7907,8 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, case BFD_RELOC_AARCH64_ADD_LO12: case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL: case BFD_RELOC_AARCH64_ADR_HI21_PCREL: + case BFD_RELOC_MORELLO_ADR_HI20_NC_PCREL: + case BFD_RELOC_MORELLO_ADR_HI20_PCREL: case BFD_RELOC_AARCH64_ADR_LO21_PCREL: case BFD_RELOC_AARCH64_LDST128_LO12: case BFD_RELOC_AARCH64_LDST16_LO12: @@ -7978,6 +8034,7 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, /* RR: We probably want to keep a consistency check that there are no dangling GOT_PAGE relocs. */ case BFD_RELOC_AARCH64_ADR_GOT_PAGE: + case BFD_RELOC_MORELLO_ADR_GOT_PAGE: case BFD_RELOC_AARCH64_GOT_LD_PREL19: case BFD_RELOC_AARCH64_LD32_GOTPAGE_LO14: case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC: diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c index 7f5de69a050..82e725e8c1d 100644 --- a/bfd/elfxx-aarch64.c +++ b/bfd/elfxx-aarch64.c @@ -57,10 +57,10 @@ reencode_add_imm (uint32_t insn, uint32_t imm) /* Reencode the IMM field of ADR. */ uint32_t -_bfd_aarch64_reencode_adr_imm (uint32_t insn, uint32_t imm) +_bfd_aarch64_reencode_adr_imm (uint32_t insn, uint32_t imm, uint32_t c64) { - return (insn & ~((MASK (2) << 29) | (MASK (19) << 5))) - | ((imm & MASK (2)) << 29) | ((imm & (MASK (19) << 2)) << 3); + return (insn & ~((MASK (2) << 29) | (MASK (19 - c64) << 5))) + | ((imm & MASK (2)) << 29) | ((imm & (MASK (19 - c64) << 2)) << 3); } /* Reencode the imm field of ld/st pos immediate. */ @@ -247,6 +247,12 @@ _bfd_aarch64_elf_put_addend (bfd *abfd, case BFD_RELOC_AARCH64_TLSDESC_CALL: break; + case BFD_RELOC_MORELLO_ADR_GOT_PAGE: + case BFD_RELOC_MORELLO_ADR_HI20_NC_PCREL: + case BFD_RELOC_MORELLO_ADR_HI20_PCREL: + contents = _bfd_aarch64_reencode_adr_imm (contents, addend, 1); + break; + case BFD_RELOC_AARCH64_ADR_GOT_PAGE: case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL: case BFD_RELOC_AARCH64_ADR_HI21_PCREL: @@ -258,7 +264,7 @@ _bfd_aarch64_elf_put_addend (bfd *abfd, case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21: case BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21: case BFD_RELOC_AARCH64_TLSLD_ADR_PREL21: - contents = _bfd_aarch64_reencode_adr_imm (contents, addend); + contents = _bfd_aarch64_reencode_adr_imm (contents, addend, 0); break; case BFD_RELOC_AARCH64_ADD_LO12: @@ -496,6 +502,8 @@ _bfd_aarch64_elf_resolve_relocation (bfd *input_bfd, value = value + addend; break; + case BFD_RELOC_MORELLO_ADR_HI20_NC_PCREL: + case BFD_RELOC_MORELLO_ADR_HI20_PCREL: case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL: case BFD_RELOC_AARCH64_ADR_HI21_PCREL: if (weak_undef_p) @@ -507,6 +515,7 @@ _bfd_aarch64_elf_resolve_relocation (bfd *input_bfd, value = value + addend - place; break; + case BFD_RELOC_MORELLO_ADR_GOT_PAGE: case BFD_RELOC_AARCH64_ADR_GOT_PAGE: case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21: case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21: diff --git a/bfd/elfxx-aarch64.h b/bfd/elfxx-aarch64.h index 9d390da9c03..0bb78aa896b 100644 --- a/bfd/elfxx-aarch64.h +++ b/bfd/elfxx-aarch64.h @@ -111,7 +111,7 @@ extern uint32_t _bfd_aarch64_decode_adrp_imm (uint32_t); extern uint32_t -_bfd_aarch64_reencode_adr_imm (uint32_t, uint32_t); +_bfd_aarch64_reencode_adr_imm (uint32_t, uint32_t, uint32_t); extern bfd_reloc_status_type _bfd_aarch64_elf_put_addend (bfd *, bfd_byte *, bfd_reloc_code_real_type, diff --git a/bfd/libbfd.h b/bfd/libbfd.h index 38f0754f79f..a5e30ce2bb0 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -3016,6 +3016,8 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_AARCH64_MOVW_PREL_G3", "BFD_RELOC_MORELLO_LD_LO17_PCREL", "BFD_RELOC_AARCH64_LD_LO19_PCREL", + "BFD_RELOC_MORELLO_ADR_HI20_PCREL", + "BFD_RELOC_MORELLO_ADR_HI20_NC_PCREL", "BFD_RELOC_AARCH64_ADR_LO21_PCREL", "BFD_RELOC_AARCH64_ADR_HI21_PCREL", "BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL", @@ -3031,6 +3033,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_AARCH64_LDST128_LO12", "BFD_RELOC_AARCH64_GOT_LD_PREL19", "BFD_RELOC_AARCH64_ADR_GOT_PAGE", + "BFD_RELOC_MORELLO_ADR_GOT_PAGE", "BFD_RELOC_AARCH64_LD64_GOT_LO12_NC", "BFD_RELOC_AARCH64_LD32_GOT_LO12_NC", "BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC", diff --git a/bfd/reloc.c b/bfd/reloc.c index 0f76fd1a40f..1d2eefd02b2 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -7114,6 +7114,17 @@ ENUMDOC AArch64 Load Literal instruction, holding a 19 bit pc-relative word offset. The lowest two bits must be zero and are not stored in the instruction, giving a 21 bit signed byte offset. +ENUM + BFD_RELOC_MORELLO_ADR_HI20_PCREL +ENUMDOC + Morello ADRP instruction, with bits 12 to 31 of a pc-relative page + offset, giving a 4KB aligned page base address. +ENUM + BFD_RELOC_MORELLO_ADR_HI20_NC_PCREL +ENUMDOC + Morello ADRP instruction, with bits 12 to 31 of a pc-relative page + offset, giving a 4KB aligned page base address, but with no overflow + checking. ENUM BFD_RELOC_AARCH64_ADR_LO21_PCREL ENUMDOC @@ -7197,6 +7208,12 @@ ENUMDOC Get to the page base of the global offset table entry for a symbol as part of an ADRP instruction using a 21 bit PC relative value.Used in conjunction with BFD_RELOC_AARCH64_LD64_GOT_LO12_NC. +ENUM + BFD_RELOC_MORELLO_ADR_GOT_PAGE +ENUMDOC + Get to the page base of the global offset table entry for a symbol as + part of an ADRP instruction using a 20 bit PC relative value.Used in + conjunction with BFD_RELOC_MORELLO_LD128_GOT_LO12_NC. ENUM BFD_RELOC_AARCH64_LD64_GOT_LO12_NC ENUMDOC diff --git a/gas/ChangeLog b/gas/ChangeLog index 7fdd3728883..92e1bc64116 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,13 @@ +2020-10-20 Siddhesh Poyarekar + + * config/tc-aarch64.c (reloc_table_entry): Add c64_adrp_type + field. + (reloc_table): Adjust. + (parse_adrp): Adjust users. + (md_apply_fix): Add MORELLO_ADR_GOT_PAGE, + MORELLO_ADR_HI20_PCREL and MORELLO_ADR_HI20_NC_PCREL. + * testsuite/gas/aarch64/morello_insn-c64.d: Adjust test. + 2020-10-20 Siddhesh Poyarekar * config/tc-aarch64.c (process_omitted_operand, diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index 3c5988acfbd..b80573e65d7 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -2562,6 +2562,7 @@ struct reloc_table_entry int pc_rel; bfd_reloc_code_real_type adr_type; bfd_reloc_code_real_type adrp_type; + bfd_reloc_code_real_type c64_adrp_type; bfd_reloc_code_real_type movw_type; bfd_reloc_code_real_type add_type; bfd_reloc_code_real_type ldst_type; @@ -2574,6 +2575,7 @@ static struct reloc_table_entry reloc_table[] = { 0, /* adr_type */ 0, 0, + 0, BFD_RELOC_AARCH64_ADD_LO12, BFD_RELOC_AARCH64_LDST_LO12, 0}, @@ -2582,15 +2584,18 @@ static struct reloc_table_entry reloc_table[] = { {"pg_hi21", 1, 0, /* adr_type */ BFD_RELOC_AARCH64_ADR_HI21_PCREL, + BFD_RELOC_MORELLO_ADR_HI20_PCREL, 0, 0, 0, 0}, - /* Higher 21 bits of pc-relative page offset: ADRP, no check */ + /* Higher 21 bits (20 bits for C64) of pc-relative page offset: ADRP, no + check */ {"pg_hi21_nc", 1, 0, /* adr_type */ BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL, + BFD_RELOC_MORELLO_ADR_HI20_NC_PCREL, 0, 0, 0, @@ -2600,6 +2605,7 @@ static struct reloc_table_entry reloc_table[] = { {"abs_g0", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_MOVW_G0, 0, 0, @@ -2609,6 +2615,7 @@ static struct reloc_table_entry reloc_table[] = { {"abs_g0_s", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_MOVW_G0_S, 0, 0, @@ -2618,6 +2625,7 @@ static struct reloc_table_entry reloc_table[] = { {"abs_g0_nc", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_MOVW_G0_NC, 0, 0, @@ -2627,6 +2635,7 @@ static struct reloc_table_entry reloc_table[] = { {"abs_g1", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_MOVW_G1, 0, 0, @@ -2636,6 +2645,7 @@ static struct reloc_table_entry reloc_table[] = { {"abs_g1_s", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_MOVW_G1_S, 0, 0, @@ -2645,6 +2655,7 @@ static struct reloc_table_entry reloc_table[] = { {"abs_g1_nc", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_MOVW_G1_NC, 0, 0, @@ -2654,6 +2665,7 @@ static struct reloc_table_entry reloc_table[] = { {"abs_g2", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_MOVW_G2, 0, 0, @@ -2663,6 +2675,7 @@ static struct reloc_table_entry reloc_table[] = { {"abs_g2_s", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_MOVW_G2_S, 0, 0, @@ -2672,6 +2685,7 @@ static struct reloc_table_entry reloc_table[] = { {"abs_g2_nc", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_MOVW_G2_NC, 0, 0, @@ -2681,6 +2695,7 @@ static struct reloc_table_entry reloc_table[] = { {"abs_g3", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_MOVW_G3, 0, 0, @@ -2690,6 +2705,7 @@ static struct reloc_table_entry reloc_table[] = { {"prel_g0", 1, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_MOVW_PREL_G0, 0, 0, @@ -2699,6 +2715,7 @@ static struct reloc_table_entry reloc_table[] = { {"prel_g0_nc", 1, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_MOVW_PREL_G0_NC, 0, 0, @@ -2708,6 +2725,7 @@ static struct reloc_table_entry reloc_table[] = { {"prel_g1", 1, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_MOVW_PREL_G1, 0, 0, @@ -2717,6 +2735,7 @@ static struct reloc_table_entry reloc_table[] = { {"prel_g1_nc", 1, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_MOVW_PREL_G1_NC, 0, 0, @@ -2726,6 +2745,7 @@ static struct reloc_table_entry reloc_table[] = { {"prel_g2", 1, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_MOVW_PREL_G2, 0, 0, @@ -2735,6 +2755,7 @@ static struct reloc_table_entry reloc_table[] = { {"prel_g2_nc", 1, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_MOVW_PREL_G2_NC, 0, 0, @@ -2744,6 +2765,7 @@ static struct reloc_table_entry reloc_table[] = { {"prel_g3", 1, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_MOVW_PREL_G3, 0, 0, @@ -2753,6 +2775,7 @@ static struct reloc_table_entry reloc_table[] = { {"got", 1, 0, /* adr_type */ BFD_RELOC_AARCH64_ADR_GOT_PAGE, + BFD_RELOC_MORELLO_ADR_GOT_PAGE, 0, 0, 0, @@ -2764,6 +2787,7 @@ static struct reloc_table_entry reloc_table[] = { 0, 0, 0, + 0, BFD_RELOC_AARCH64_LD_GOT_LO12_NC, 0}, @@ -2771,6 +2795,7 @@ static struct reloc_table_entry reloc_table[] = { {"gotoff_g0_nc", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC, 0, 0, @@ -2780,6 +2805,7 @@ static struct reloc_table_entry reloc_table[] = { {"gotoff_g1", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_MOVW_GOTOFF_G1, 0, 0, @@ -2791,6 +2817,7 @@ static struct reloc_table_entry reloc_table[] = { 0, 0, 0, + 0, BFD_RELOC_AARCH64_LD64_GOTOFF_LO15, 0}, @@ -2798,6 +2825,7 @@ static struct reloc_table_entry reloc_table[] = { {"gottprel_g0_nc", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC, 0, 0, @@ -2807,6 +2835,7 @@ static struct reloc_table_entry reloc_table[] = { {"gottprel_g1", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1, 0, 0, @@ -2819,6 +2848,7 @@ static struct reloc_table_entry reloc_table[] = { 0, 0, 0, + 0, 0}, /* 12 bit offset into the page containing GOT TLS entry for a symbol */ @@ -2826,6 +2856,7 @@ static struct reloc_table_entry reloc_table[] = { 0, /* adr_type */ 0, 0, + 0, BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC, 0, 0}, @@ -2834,6 +2865,7 @@ static struct reloc_table_entry reloc_table[] = { {"tlsgd_g0_nc", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC, 0, 0, @@ -2843,6 +2875,7 @@ static struct reloc_table_entry reloc_table[] = { {"tlsgd_g1", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_TLSGD_MOVW_G1, 0, 0, @@ -2855,6 +2888,7 @@ static struct reloc_table_entry reloc_table[] = { 0, 0, 0, + 0, BFD_RELOC_AARCH64_TLSDESC_LD_PREL19}, /* 12 bit offset into the page containing GOT TLS entry for a symbol */ @@ -2862,6 +2896,7 @@ static struct reloc_table_entry reloc_table[] = { 0, /* adr_type */ 0, 0, + 0, BFD_RELOC_AARCH64_TLSDESC_ADD_LO12, BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC, 0}, @@ -2877,6 +2912,7 @@ static struct reloc_table_entry reloc_table[] = { 0, 0, 0, + 0, 0}, /* 12 bit offset into the page containing GOT TLS entry for a symbol */ @@ -2884,6 +2920,7 @@ static struct reloc_table_entry reloc_table[] = { 0, /* adr_type */ 0, 0, + 0, BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC, 0, 0}, @@ -2893,6 +2930,7 @@ static struct reloc_table_entry reloc_table[] = { 0, /* adr_type */ 0, 0, + 0, BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12, BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12, 0}, @@ -2902,6 +2940,7 @@ static struct reloc_table_entry reloc_table[] = { 0, /* adr_type */ 0, 0, + 0, BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_LO12_NC, BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12_NC, 0}, @@ -2911,6 +2950,7 @@ static struct reloc_table_entry reloc_table[] = { 0, /* adr_type */ 0, 0, + 0, BFD_RELOC_AARCH64_TLSLD_ADD_DTPREL_HI12, 0, 0}, @@ -2919,6 +2959,7 @@ static struct reloc_table_entry reloc_table[] = { {"dtprel_g0", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0, 0, 0, @@ -2928,6 +2969,7 @@ static struct reloc_table_entry reloc_table[] = { {"dtprel_g0_nc", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G0_NC, 0, 0, @@ -2937,6 +2979,7 @@ static struct reloc_table_entry reloc_table[] = { {"dtprel_g1", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1, 0, 0, @@ -2946,6 +2989,7 @@ static struct reloc_table_entry reloc_table[] = { {"dtprel_g1_nc", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1_NC, 0, 0, @@ -2955,6 +2999,7 @@ static struct reloc_table_entry reloc_table[] = { {"dtprel_g2", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G2, 0, 0, @@ -2964,6 +3009,7 @@ static struct reloc_table_entry reloc_table[] = { {"tlsdesc_off_g0_nc", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC, 0, 0, @@ -2973,6 +3019,7 @@ static struct reloc_table_entry reloc_table[] = { {"tlsdesc_off_g1", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_TLSDESC_OFF_G1, 0, 0, @@ -2985,6 +3032,7 @@ static struct reloc_table_entry reloc_table[] = { 0, 0, 0, + 0, BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19}, /* 12 bit offset into the page containing GOT TLS entry for a symbol */ @@ -2993,6 +3041,7 @@ static struct reloc_table_entry reloc_table[] = { 0, 0, 0, + 0, BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC, 0}, @@ -3001,6 +3050,7 @@ static struct reloc_table_entry reloc_table[] = { 0, /* adr_type */ 0, 0, + 0, BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12, 0, 0}, @@ -3010,6 +3060,7 @@ static struct reloc_table_entry reloc_table[] = { 0, /* adr_type */ 0, 0, + 0, BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12, BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12, 0}, @@ -3019,6 +3070,7 @@ static struct reloc_table_entry reloc_table[] = { 0, /* adr_type */ 0, 0, + 0, BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12, 0, 0}, @@ -3028,6 +3080,7 @@ static struct reloc_table_entry reloc_table[] = { 0, /* adr_type */ 0, 0, + 0, BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC, BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12_NC, 0}, @@ -3036,6 +3089,7 @@ static struct reloc_table_entry reloc_table[] = { {"tprel_g2", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2, 0, 0, @@ -3045,6 +3099,7 @@ static struct reloc_table_entry reloc_table[] = { {"tprel_g1", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1, 0, 0, @@ -3054,6 +3109,7 @@ static struct reloc_table_entry reloc_table[] = { {"tprel_g1_nc", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC, 0, 0, @@ -3063,6 +3119,7 @@ static struct reloc_table_entry reloc_table[] = { {"tprel_g0", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0, 0, 0, @@ -3072,6 +3129,7 @@ static struct reloc_table_entry reloc_table[] = { {"tprel_g0_nc", 0, 0, /* adr_type */ 0, + 0, BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC, 0, 0, @@ -3083,6 +3141,7 @@ static struct reloc_table_entry reloc_table[] = { 0, 0, 0, + 0, BFD_RELOC_AARCH64_LD64_GOTPAGE_LO15, 0}, @@ -3092,6 +3151,7 @@ static struct reloc_table_entry reloc_table[] = { 0, 0, 0, + 0, BFD_RELOC_AARCH64_LD32_GOTPAGE_LO14, 0}, }; @@ -3952,6 +4012,7 @@ parse_adrp (char **str) if (*p == ':') { struct reloc_table_entry *entry; + bfd_reloc_code_real_type adrp_type; /* Try to parse a relocation. Anything else is an error. */ ++p; @@ -3961,17 +4022,23 @@ parse_adrp (char **str) return FALSE; } - if (entry->adrp_type == 0) + adrp_type = (AARCH64_CPU_HAS_FEATURE (cpu_variant, AARCH64_FEATURE_C64) + ? entry->c64_adrp_type : entry->adrp_type); + + if (adrp_type == 0) { set_syntax_error (_("this relocation modifier is not allowed on this instruction")); return FALSE; } - inst.reloc.type = entry->adrp_type; + inst.reloc.type = adrp_type; } else - inst.reloc.type = BFD_RELOC_AARCH64_ADR_HI21_PCREL; + inst.reloc.type = (AARCH64_CPU_HAS_FEATURE (cpu_variant, + AARCH64_FEATURE_C64) + ? BFD_RELOC_MORELLO_ADR_HI20_PCREL + : BFD_RELOC_AARCH64_ADR_HI21_PCREL); inst.reloc.pc_rel = 1; @@ -8662,6 +8729,9 @@ md_apply_fix (fixS * fixP, valueT * valP, segT seg) case BFD_RELOC_AARCH64_ADD_LO12: case BFD_RELOC_AARCH64_ADR_GOT_PAGE: + case BFD_RELOC_MORELLO_ADR_GOT_PAGE: + case BFD_RELOC_MORELLO_ADR_HI20_NC_PCREL: + case BFD_RELOC_MORELLO_ADR_HI20_PCREL: case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL: case BFD_RELOC_AARCH64_ADR_HI21_PCREL: case BFD_RELOC_AARCH64_GOT_LD_PREL19: @@ -8817,6 +8887,9 @@ aarch64_force_relocation (struct fix *fixp) case BFD_RELOC_AARCH64_ADD_LO12: case BFD_RELOC_AARCH64_ADR_GOT_PAGE: + case BFD_RELOC_MORELLO_ADR_GOT_PAGE: + case BFD_RELOC_MORELLO_ADR_HI20_NC_PCREL: + case BFD_RELOC_MORELLO_ADR_HI20_PCREL: case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL: case BFD_RELOC_AARCH64_ADR_HI21_PCREL: case BFD_RELOC_AARCH64_GOT_LD_PREL19: diff --git a/gas/testsuite/gas/aarch64/morello_insn-c64.d b/gas/testsuite/gas/aarch64/morello_insn-c64.d index 02884ac5988..a73ad9cf184 100644 --- a/gas/testsuite/gas/aarch64/morello_insn-c64.d +++ b/gas/testsuite/gas/aarch64/morello_insn-c64.d @@ -76,7 +76,7 @@ Disassembly of section \.text: .*