]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[Morello] Add Morello relocations for ADRP
authorSiddhesh Poyarekar <siddesh.poyarekar@arm.com>
Fri, 11 Sep 2020 03:48:09 +0000 (09:18 +0530)
committerLuis Machado <luis.machado@linaro.org>
Tue, 20 Oct 2020 18:03:58 +0000 (15:03 -0300)
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  <siddesh.poyarekar@arm.com>

* 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  <siddesh.poyarekar@arm.com>

* 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  <siddesh.poyarekar@arm.com>

* elf/aarch64.h: Add R_MORELLO_ADR_PREL_PG_HI20,
R_MORELLO_ADR_PREL_PG_HI20_NC and R_MORELLO_ADR_GOT_PAGE.

12 files changed:
bfd/ChangeLog
bfd/bfd-in2.h
bfd/elfnn-aarch64.c
bfd/elfxx-aarch64.c
bfd/elfxx-aarch64.h
bfd/libbfd.h
bfd/reloc.c
gas/ChangeLog
gas/config/tc-aarch64.c
gas/testsuite/gas/aarch64/morello_insn-c64.d
include/ChangeLog
include/elf/aarch64.h

index 87370d68b6242bcc7028f66045a37d870117dab8..dcec7b2f264ad602415c32a9f6bead56e5150c1b 100644 (file)
@@ -1,3 +1,24 @@
+2020-10-20  Siddhesh Poyarekar  <siddesh.poyarekar@arm.com>
+
+       * 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  <siddesh.poyarekar@arm.com>
 
        * elfnn-aarch64.c (elfNN_aarch64_howto_table): Add
index caa2265ae225a2cfe79f03bb0cdfb0e0d8439a8d..01a2dccde4c77b30b115411ae3b5dedfffcd2c09 100644 (file)
@@ -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.  */
index 1a563fa8354e9c5ed91cecef4923293342d7fb7a..0cc63cc28896e717a6d5a883def9ad54785394a2 100644 (file)
@@ -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:
index 7f5de69a0507dfced03e013e224c2933b99dff70..82e725e8c1d0e370758d0914eca4d9a53911b7e3 100644 (file)
@@ -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:
index 9d390da9c03e8618880f79c1fbaee07f35260c0b..0bb78aa896b1430f340b8d17447be43fcffa6362 100644 (file)
@@ -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,
index 38f0754f79f017b3f18656fcb0aee055f8118da1..a5e30ce2bb0e8420916cc636607da5e513a37a96 100644 (file)
@@ -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",
index 0f76fd1a40f6bc26e97c3258fa5568b15aac3063..1d2eefd02b26be08e3978d8b1dec5581e19b85e4 100644 (file)
@@ -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
index 7fdd37288835c6f6ea4a21a324702de667b1ff92..92e1bc64116c20455b351704f9cd46fefd1f4416 100644 (file)
@@ -1,3 +1,13 @@
+2020-10-20  Siddhesh Poyarekar  <siddesh.poyarekar@arm.com>
+
+       * 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  <siddesh.poyarekar@arm.com>
 
        * config/tc-aarch64.c (process_omitted_operand,
index 3c5988acfbdf9c8a9b01d908e5b5b34568ef39ac..b80573e65d747037babeebd762dc431009a6b14f 100644 (file)
@@ -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:
index 02884ac5988dd084304a57d241a6ba8fd2f7c4ee..a73ad9cf18450a2c1ed3e6e3f7a9e977e15e41ef 100644 (file)
@@ -76,7 +76,7 @@ Disassembly of section \.text:
 .* <Label>:
 .*:    10000000        adr     c0, .* <Label>
 .*:    90800000        adrp    c0, .* <.*>
-                       .*: R_AARCH64_ADR_PREL_PG_HI21  .*
+                       .*: R_MORELLO_ADR_PREL_PG_HI20  .*
 .*:    b0000000        adrdp   c0, #0x1000
 .*:    023fc135        add     c21, c9, #0xff0
 .*:    023ffd35        add     c21, c9, #0xfff
index be718a159a07c7771cf56c79c78c4ff8eff7fc96..1725e720a6c32d2c61b97b94fac0bad7e936f908 100644 (file)
@@ -1,3 +1,8 @@
+2020-10-20  Siddhesh Poyarekar  <siddesh.poyarekar@arm.com>
+
+       * elf/aarch64.h: Add R_MORELLO_ADR_PREL_PG_HI20,
+       R_MORELLO_ADR_PREL_PG_HI20_NC and R_MORELLO_ADR_GOT_PAGE.
+
 2020-10-20  Siddhesh Poyarekar  <siddesh.poyarekar@arm.com>
 
        * opcode/aarch64.h (aarch64_opnd): New operand Cat_SYS.
index f69dcbb72ab0e18e0ea7e2690f9a680469413d4a..1e77f927c270617515ddf5256a7d7d3122818d5e 100644 (file)
@@ -447,6 +447,14 @@ RELOC_NUMBER (R_AARCH64_IRELATIVE, 1032)
 /* A64C LD-lit: ((S+A-P) >> 4) & 0x1ffff */
 RELOC_NUMBER (R_MORELLO_LD_PREL_LO17, 57348)
 
+/* ADRP:   ((PG(S+A)-PG(P)) >> 12) & 0xfffff */
+RELOC_NUMBER (R_MORELLO_ADR_PREL_PG_HI20, 57349)
+
+/* ADRP:   ((PG(S+A)-PG(P)) >> 12) & 0xfffff */
+RELOC_NUMBER (R_MORELLO_ADR_PREL_PG_HI20_NC, 57350)
+
+RELOC_NUMBER (R_MORELLO_ADR_GOT_PAGE, 57351)
+
 END_RELOC_NUMBERS (R_AARCH64_end)
 
 enum aarch64_st_branch_type