[AArch64, ILP32] 3/6 Support for ELF32 relocs and refactor reloc handling
authorYufeng Zhang <yufeng.zhang@arm.com>
Wed, 26 Jun 2013 10:47:06 +0000 (10:47 +0000)
committerYufeng Zhang <yufeng.zhang@arm.com>
Wed, 26 Jun 2013 10:47:06 +0000 (10:47 +0000)
bfd/

* bfd-in2.h: Re-generated.
* elfnn-aarch64.c (HOWTO64, HOWTO32): New define.
(IS_AARCH64_TLS_RELOC): Change to be based on the
bfd reloc enumerators.
(IS_AARCH64_TLSDESC_RELOC): Likewise.
(PG, PG_OFFSET): Cast literal to bfd_vma.
(elf64_aarch64_howto_table): Removed.
(elf64_aarch64_howto_dynrelocs): Removed.
(elf64_aarch64_tls_howto_table): Removed.
(elf64_aarch64_tlsdesc_howto_table): Removed.
(elfNN_aarch64_howto_table): New table to host all howto entires..
(R_AARCH64_*): Replaced by AARCH64_R (*) and AARCH64_R_STR (*).
(elfNN_aarch64_bfd_reloc_from_howto): New function.
(elfNN_aarch64_bfd_reloc_from_type): Ditto.
(struct elf_aarch64_reloc_map): New.
(elf_aarch64_reloc_map): New table.
(elfNN_aarch64_howto_from_bfd_reloc): New function.
(elfNN_aarch64_howto_from_type): Update to look up the new table
elfNN_aarch64_howto_table.
(struct elf64_aarch64_reloc_map): Remove.
(elf64_aarch64_reloc_map): Remove.
(elfNN_aarch64_reloc_type_lookup): Change to call
elfNN_aarch64_howto_from_bfd_reloc.
(elfNN_aarch64_reloc_name_lookup): Change to look up the new table
elfNN_aarch64_howto_table.
(aarch64_resolve_relocation): Refactor to switch on the bfd
reloc enumerators.
(bfd_elf_aarch64_put_addend): Likewise.
(elfNN_aarch64_final_link_relocate): Likewise.
(aarch64_tls_transition_without_check): Likewise.
(aarch64_reloc_got_type): Likewise.
(aarch64_can_relax_tls): Likewise.
(aarch64_tls_transition): Likewise.
(elfNN_aarch64_tls_relax): Likewise.
(elfNN_aarch64_final_link_relocate): Likewise.
(elfNN_aarch64_relocate_section): Likewise.
(elfNN_aarch64_gc_sweep_hook): Likewise.
(elfNN_aarch64_check_relocs): Likewise.
(aarch64_tls_transition): Change to return a bfd reloc enumerator.
* libbfd.h: Re-generated.
* reloc.c: Re-order the AArch64 bfd reloc enumerators.
(BFD_RELOC_AARCH64_RELOC_START)
(BFD_RELOC_AARCH64_RELOC_END)
(BFD_RELOC_AARCH64_LD_GOT_LO12_NC)
(BFD_RELOC_AARCH64_LD32_GOT_LO12_NC)
(BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC)
(BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC)
(BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC)
(BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC)
(BFD_RELOC_AARCH64_IRELATIVE): New relocs.

gas/

* config/tc-aarch64.c (reloc_table): Replace
BFD_RELOC_AARCH64_LD64_GOT_LO12_NC with
BFD_RELOC_AARCH64_LD_GOT_LO12_NC; likewise to
BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC and
BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC.
(md_apply_fix): Handle BFD_RELOC_AARCH64_LD_GOT_LO12_NC,
BFD_RELOC_AARCH64_LD32_GOT_LO12_NC,
BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC,
BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC,
BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC and
BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC.
(aarch64_force_relocation): Likewise.

gas/testsuite/

* gas/aarch64/ilp32-basic.d: New file.
* gas/aarch64/ilp32-basic.s: New file.

include/elf/

* aarch64.h: Add ELF32 reloc codes and remove fake ELF64 ones.
(R_AARCH64_IRELATIVE): New reloc.

12 files changed:
bfd/ChangeLog
bfd/bfd-in2.h
bfd/elfnn-aarch64.c
bfd/libbfd.h
bfd/reloc.c
gas/ChangeLog
gas/config/tc-aarch64.c
gas/testsuite/ChangeLog
gas/testsuite/gas/aarch64/ilp32-basic.d [new file with mode: 0644]
gas/testsuite/gas/aarch64/ilp32-basic.s [new file with mode: 0644]
include/elf/ChangeLog
include/elf/aarch64.h

index 68f306fccf4e90f203cf4b99aa3fbcb42caa7917..a91efeabaf46696e08c5ea250fcc9708a2d7f879 100644 (file)
@@ -1,3 +1,56 @@
+2013-06-26  Yufeng Zhang  <yufeng.zhang@arm.com>
+
+       * bfd-in2.h: Re-generated.
+       * elfnn-aarch64.c (HOWTO64, HOWTO32): New define.
+       (IS_AARCH64_TLS_RELOC): Change to be based on the
+       bfd reloc enumerators.
+       (IS_AARCH64_TLSDESC_RELOC): Likewise.
+       (PG, PG_OFFSET): Cast literal to bfd_vma.
+       (elf64_aarch64_howto_table): Removed.
+       (elf64_aarch64_howto_dynrelocs): Removed.
+       (elf64_aarch64_tls_howto_table): Removed.
+       (elf64_aarch64_tlsdesc_howto_table): Removed.
+       (elfNN_aarch64_howto_table): New table to host all howto entires..
+       (R_AARCH64_*): Replaced by AARCH64_R (*) and AARCH64_R_STR (*).
+       (elfNN_aarch64_bfd_reloc_from_howto): New function.
+       (elfNN_aarch64_bfd_reloc_from_type): Ditto.
+       (struct elf_aarch64_reloc_map): New.
+       (elf_aarch64_reloc_map): New table.
+       (elfNN_aarch64_howto_from_bfd_reloc): New function.
+       (elfNN_aarch64_howto_from_type): Update to look up the new table
+       elfNN_aarch64_howto_table.
+       (struct elf64_aarch64_reloc_map): Remove.
+       (elf64_aarch64_reloc_map): Remove.
+       (elfNN_aarch64_reloc_type_lookup): Change to call
+       elfNN_aarch64_howto_from_bfd_reloc.
+       (elfNN_aarch64_reloc_name_lookup): Change to look up the new table
+       elfNN_aarch64_howto_table.
+       (aarch64_resolve_relocation): Refactor to switch on the bfd
+       reloc enumerators.
+       (bfd_elf_aarch64_put_addend): Likewise.
+       (elfNN_aarch64_final_link_relocate): Likewise.
+       (aarch64_tls_transition_without_check): Likewise.
+       (aarch64_reloc_got_type): Likewise.
+       (aarch64_can_relax_tls): Likewise.
+       (aarch64_tls_transition): Likewise.
+       (elfNN_aarch64_tls_relax): Likewise.
+       (elfNN_aarch64_final_link_relocate): Likewise.
+       (elfNN_aarch64_relocate_section): Likewise.
+       (elfNN_aarch64_gc_sweep_hook): Likewise.
+       (elfNN_aarch64_check_relocs): Likewise.
+       (aarch64_tls_transition): Change to return a bfd reloc enumerator.
+       * libbfd.h: Re-generated.
+       * reloc.c: Re-order the AArch64 bfd reloc enumerators.
+       (BFD_RELOC_AARCH64_RELOC_START)
+       (BFD_RELOC_AARCH64_RELOC_END)
+       (BFD_RELOC_AARCH64_LD_GOT_LO12_NC)
+       (BFD_RELOC_AARCH64_LD32_GOT_LO12_NC)
+       (BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC)
+       (BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC)
+       (BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC)
+       (BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC)
+       (BFD_RELOC_AARCH64_IRELATIVE): New relocs.
+
 2013-06-26  Yufeng Zhang  <yufeng.zhang@arm.com>
 
        * Makefile.am (BFD64_BACKENDS): Add elf32-aarch64.lo.
 2013-06-26  Yufeng Zhang  <yufeng.zhang@arm.com>
 
        * Makefile.am (BFD64_BACKENDS): Add elf32-aarch64.lo.
index e4a5dccf8ed3c378e3584e93498686eac7636167..9cbd82060dc9ad62793e6f76e0c65269c9b9ce36 100644 (file)
@@ -5240,21 +5240,78 @@ to two words (uses imm instruction).  */
 to two words (uses imm instruction).  */
   BFD_RELOC_MICROBLAZE_64_TLSTPREL,
 
 to two words (uses imm instruction).  */
   BFD_RELOC_MICROBLAZE_64_TLSTPREL,
 
-/* AArch64 ADD immediate instruction, holding bits 0 to 11 of the address.
-Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.  */
-  BFD_RELOC_AARCH64_ADD_LO12,
+/* AArch64 pseudo relocation code to mark the start of the AArch64
+relocation enumerators.  N.B. the order of the enumerators is
+important as several tables in the AArch64 bfd backend are indexed
+by these enumerators; make sure they are all synced.  */
+  BFD_RELOC_AARCH64_RELOC_START,
+
+/* AArch64 null relocation code.  */
+  BFD_RELOC_AARCH64_NONE,
+
+/* Basic absolute relocations of N bits.  These are equivalent to
+BFD_RELOC_N and they were added to assist the indexing of the howto
+table.  */
+  BFD_RELOC_AARCH64_64,
+  BFD_RELOC_AARCH64_32,
+  BFD_RELOC_AARCH64_16,
+
+/* PC-relative relocations.  These are equivalent to BFD_RELOC_N_PCREL
+and they were added to assist the indexing of the howto table.  */
+  BFD_RELOC_AARCH64_64_PCREL,
+  BFD_RELOC_AARCH64_32_PCREL,
+  BFD_RELOC_AARCH64_16_PCREL,
 
 
-/* AArch64 Load Literal instruction, holding a 19 bit PC relative word
-offset of the global offset table entry for a symbol.  The lowest two
-bits must be zero and are not stored in the instruction, giving a 21
-bit signed byte offset.  This relocation type requires signed overflow
-checking.  */
-  BFD_RELOC_AARCH64_GOT_LD_PREL19,
+/* AArch64 MOV[NZK] instruction with most significant bits 0 to 15
+of an unsigned address/value.  */
+  BFD_RELOC_AARCH64_MOVW_G0,
 
 
-/* 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.  */
-  BFD_RELOC_AARCH64_ADR_GOT_PAGE,
+/* AArch64 MOV[NZK] instruction with less significant bits 0 to 15 of
+an address/value.  No overflow checking.  */
+  BFD_RELOC_AARCH64_MOVW_G0_NC,
+
+/* AArch64 MOV[NZK] instruction with most significant bits 16 to 31
+of an unsigned address/value.  */
+  BFD_RELOC_AARCH64_MOVW_G1,
+
+/* AArch64 MOV[NZK] instruction with less significant bits 16 to 31
+of an address/value.  No overflow checking.  */
+  BFD_RELOC_AARCH64_MOVW_G1_NC,
+
+/* AArch64 MOV[NZK] instruction with most significant bits 32 to 47
+of an unsigned address/value.  */
+  BFD_RELOC_AARCH64_MOVW_G2,
+
+/* AArch64 MOV[NZK] instruction with less significant bits 32 to 47
+of an address/value.  No overflow checking.  */
+  BFD_RELOC_AARCH64_MOVW_G2_NC,
+
+/* AArch64 MOV[NZK] instruction with most signficant bits 48 to 64
+of a signed or unsigned address/value.  */
+  BFD_RELOC_AARCH64_MOVW_G3,
+
+/* AArch64 MOV[NZ] instruction with most significant bits 0 to 15
+of a signed value.  Changes instruction to MOVZ or MOVN depending on the
+value's sign.  */
+  BFD_RELOC_AARCH64_MOVW_G0_S,
+
+/* AArch64 MOV[NZ] instruction with most significant bits 16 to 31
+of a signed value.  Changes instruction to MOVZ or MOVN depending on the
+value's sign.  */
+  BFD_RELOC_AARCH64_MOVW_G1_S,
+
+/* AArch64 MOV[NZ] instruction with most significant bits 32 to 47
+of a signed value.  Changes instruction to MOVZ or MOVN depending on the
+value's sign.  */
+  BFD_RELOC_AARCH64_MOVW_G2_S,
+
+/* 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.  */
+  BFD_RELOC_AARCH64_LD_LO19_PCREL,
+
+/* AArch64 ADR instruction, holding a simple 21 bit pc-relative byte offset.  */
+  BFD_RELOC_AARCH64_ADR_LO21_PCREL,
 
 /* AArch64 ADRP instruction, with bits 12 to 32 of a pc-relative page
 offset, giving a 4KB aligned page base address.  */
 
 /* AArch64 ADRP instruction, with bits 12 to 32 of a pc-relative page
 offset, giving a 4KB aligned page base address.  */
@@ -5265,45 +5322,33 @@ offset, giving a 4KB aligned page base address, but with no overflow
 checking.  */
   BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL,
 
 checking.  */
   BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL,
 
-/* AArch64 ADR instruction, holding a simple 21 bit pc-relative byte offset.  */
-  BFD_RELOC_AARCH64_ADR_LO21_PCREL,
+/* AArch64 ADD immediate instruction, holding bits 0 to 11 of the address.
+Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.  */
+  BFD_RELOC_AARCH64_ADD_LO12,
+
+/* AArch64 8-bit load/store instruction, holding bits 0 to 11 of the
+address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.  */
+  BFD_RELOC_AARCH64_LDST8_LO12,
+
+/* AArch64 14 bit pc-relative test bit and branch.
+The lowest two bits must be zero and are not stored in the instruction,
+giving a 16 bit signed byte offset.  */
+  BFD_RELOC_AARCH64_TSTBR14,
 
 /* AArch64 19 bit pc-relative conditional branch and compare & branch.
 The lowest two bits must be zero and are not stored in the instruction,
 giving a 21 bit signed byte offset.  */
   BFD_RELOC_AARCH64_BRANCH19,
 
 
 /* AArch64 19 bit pc-relative conditional branch and compare & branch.
 The lowest two bits must be zero and are not stored in the instruction,
 giving a 21 bit signed byte offset.  */
   BFD_RELOC_AARCH64_BRANCH19,
 
-/* AArch64 26 bit pc-relative unconditional branch and link.
-The lowest two bits must be zero and are not stored in the instruction,
-giving a 28 bit signed byte offset.  */
-  BFD_RELOC_AARCH64_CALL26,
-
-/* AArch64 pseudo relocation code to be used internally by the AArch64
-assembler and not (currently) written to any object files.  */
-  BFD_RELOC_AARCH64_GAS_INTERNAL_FIXUP,
-
 /* AArch64 26 bit pc-relative unconditional branch.
 The lowest two bits must be zero and are not stored in the instruction,
 giving a 28 bit signed byte offset.  */
   BFD_RELOC_AARCH64_JUMP26,
 
 /* AArch64 26 bit pc-relative unconditional branch.
 The lowest two bits must be zero and are not stored in the instruction,
 giving a 28 bit signed byte offset.  */
   BFD_RELOC_AARCH64_JUMP26,
 
-/* 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.  */
-  BFD_RELOC_AARCH64_LD_LO19_PCREL,
-
-/* 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_GOTPAGE.  */
-  BFD_RELOC_AARCH64_LD64_GOT_LO12_NC,
-
-/* AArch64 unspecified load/store instruction, holding bits 0 to 11 of the
-address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.  */
-  BFD_RELOC_AARCH64_LDST_LO12,
-
-/* AArch64 8-bit load/store instruction, holding bits 0 to 11 of the
-address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.  */
-  BFD_RELOC_AARCH64_LDST8_LO12,
+/* AArch64 26 bit pc-relative unconditional branch and link.
+The lowest two bits must be zero and are not stored in the instruction,
+giving a 28 bit signed byte offset.  */
+  BFD_RELOC_AARCH64_CALL26,
 
 /* AArch64 16-bit load/store instruction, holding bits 0 to 11 of the
 address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.  */
 
 /* AArch64 16-bit load/store instruction, holding bits 0 to 11 of the
 address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.  */
@@ -5321,145 +5366,167 @@ address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.  */
 address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.  */
   BFD_RELOC_AARCH64_LDST128_LO12,
 
 address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.  */
   BFD_RELOC_AARCH64_LDST128_LO12,
 
-/* AArch64 MOV[NZK] instruction with most significant bits 0 to 15
-of an unsigned address/value.  */
-  BFD_RELOC_AARCH64_MOVW_G0,
+/* AArch64 Load Literal instruction, holding a 19 bit PC relative word
+offset of the global offset table entry for a symbol.  The lowest two
+bits must be zero and are not stored in the instruction, giving a 21
+bit signed byte offset.  This relocation type requires signed overflow
+checking.  */
+  BFD_RELOC_AARCH64_GOT_LD_PREL19,
 
 
-/* AArch64 MOV[NZ] instruction with most significant bits 0 to 15
-of a signed value.  Changes instruction to MOVZ or MOVN depending on the
-value's sign.  */
-  BFD_RELOC_AARCH64_MOVW_G0_S,
+/* 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.  */
+  BFD_RELOC_AARCH64_ADR_GOT_PAGE,
 
 
-/* AArch64 MOV[NZK] instruction with less significant bits 0 to 15 of
-an address/value.  No overflow checking.  */
-  BFD_RELOC_AARCH64_MOVW_G0_NC,
+/* 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_GOTPAGE.  Valid in LP64 ABI only.  */
+  BFD_RELOC_AARCH64_LD64_GOT_LO12_NC,
 
 
-/* AArch64 MOV[NZK] instruction with most significant bits 16 to 31
-of an unsigned address/value.  */
-  BFD_RELOC_AARCH64_MOVW_G1,
+/* Unsigned 12 bit byte offset for 32 bit load/store from the page of
+the GOT entry for this symbol.  Used in conjunction with
+BFD_RELOC_AARCH64_ADR_GOTPAGE.  Valid in ILP32 ABI only.  */
+  BFD_RELOC_AARCH64_LD32_GOT_LO12_NC,
 
 
-/* AArch64 MOV[NZK] instruction with less significant bits 16 to 31
-of an address/value.  No overflow checking.  */
-  BFD_RELOC_AARCH64_MOVW_G1_NC,
+/* Get to the page base of the global offset table entry for a symbols
+tls_index structure as part of an adrp instruction using a 21 bit PC
+relative value.  Used in conjunction with
+BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC.  */
+  BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21,
 
 
-/* AArch64 MOV[NZ] instruction with most significant bits 16 to 31
-of a signed value.  Changes instruction to MOVZ or MOVN depending on the
-value's sign.  */
-  BFD_RELOC_AARCH64_MOVW_G1_S,
+/* Unsigned 12 bit byte offset to global offset table entry for a symbols
+tls_index structure.  Used in conjunction with
+BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21.  */
+  BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC,
 
 
-/* AArch64 MOV[NZK] instruction with most significant bits 32 to 47
-of an unsigned address/value.  */
-  BFD_RELOC_AARCH64_MOVW_G2,
+/* AArch64 TLS INITIAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1,
 
 
-/* AArch64 MOV[NZK] instruction with less significant bits 32 to 47
-of an address/value.  No overflow checking.  */
-  BFD_RELOC_AARCH64_MOVW_G2_NC,
+/* AArch64 TLS INITIAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC,
 
 
-/* AArch64 MOV[NZ] instruction with most significant bits 32 to 47
-of a signed value.  Changes instruction to MOVZ or MOVN depending on the
-value's sign.  */
-  BFD_RELOC_AARCH64_MOVW_G2_S,
+/* AArch64 TLS INITIAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21,
 
 
-/* AArch64 MOV[NZK] instruction with most signficant bits 48 to 64
-of a signed or unsigned address/value.  */
-  BFD_RELOC_AARCH64_MOVW_G3,
+/* AArch64 TLS INITIAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC,
 
 
-/* AArch64 TLS relocation.  */
-  BFD_RELOC_AARCH64_TLSDESC,
+/* AArch64 TLS INITIAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC,
 
 
-/* AArch64 TLS DESC relocation.  */
-  BFD_RELOC_AARCH64_TLSDESC_ADD,
+/* AArch64 TLS INITIAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19,
 
 
-/* AArch64 TLS DESC relocation.  */
-  BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC,
+/* AArch64 TLS LOCAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2,
+
+/* AArch64 TLS LOCAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1,
+
+/* AArch64 TLS LOCAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC,
+
+/* AArch64 TLS LOCAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0,
+
+/* AArch64 TLS LOCAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC,
+
+/* AArch64 TLS LOCAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12,
+
+/* AArch64 TLS LOCAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12,
+
+/* AArch64 TLS LOCAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC,
 
 /* AArch64 TLS DESC relocation.  */
 
 /* AArch64 TLS DESC relocation.  */
-  BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21,
+  BFD_RELOC_AARCH64_TLSDESC_LD_PREL19,
 
 /* AArch64 TLS DESC relocation.  */
   BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21,
 
 /* AArch64 TLS DESC relocation.  */
 
 /* AArch64 TLS DESC relocation.  */
   BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21,
 
 /* AArch64 TLS DESC relocation.  */
-  BFD_RELOC_AARCH64_TLSDESC_CALL,
+  BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21,
 
 /* AArch64 TLS DESC relocation.  */
   BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC,
 
 /* AArch64 TLS DESC relocation.  */
 
 /* AArch64 TLS DESC relocation.  */
   BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC,
 
 /* AArch64 TLS DESC relocation.  */
-  BFD_RELOC_AARCH64_TLSDESC_LD_PREL19,
-
-/* AArch64 TLS DESC relocation.  */
-  BFD_RELOC_AARCH64_TLSDESC_LDR,
+  BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC,
 
 /* AArch64 TLS DESC relocation.  */
 
 /* AArch64 TLS DESC relocation.  */
-  BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC,
+  BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC,
 
 /* AArch64 TLS DESC relocation.  */
   BFD_RELOC_AARCH64_TLSDESC_OFF_G1,
 
 
 /* AArch64 TLS DESC relocation.  */
   BFD_RELOC_AARCH64_TLSDESC_OFF_G1,
 
-/* Unsigned 12 bit byte offset to global offset table entry for a symbols
-tls_index structure.  Used in conjunction with
-BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21.  */
-  BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC,
+/* AArch64 TLS DESC relocation.  */
+  BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC,
 
 
-/* Get to the page base of the global offset table entry for a symbols
-tls_index structure as part of an adrp instruction using a 21 bit PC
-relative value.  Used in conjunction with
-BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC.  */
-  BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21,
+/* AArch64 TLS DESC relocation.  */
+  BFD_RELOC_AARCH64_TLSDESC_LDR,
 
 
-/* AArch64 TLS INITIAL EXEC relocation.  */
-  BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21,
+/* AArch64 TLS DESC relocation.  */
+  BFD_RELOC_AARCH64_TLSDESC_ADD,
 
 
-/* AArch64 TLS INITIAL EXEC relocation.  */
-  BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19,
+/* AArch64 TLS DESC relocation.  */
+  BFD_RELOC_AARCH64_TLSDESC_CALL,
 
 
-/* AArch64 TLS INITIAL EXEC relocation.  */
-  BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC,
+/* AArch64 TLS relocation.  */
+  BFD_RELOC_AARCH64_COPY,
 
 
-/* AArch64 TLS INITIAL EXEC relocation.  */
-  BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC,
+/* AArch64 TLS relocation.  */
+  BFD_RELOC_AARCH64_GLOB_DAT,
 
 
-/* AArch64 TLS INITIAL EXEC relocation.  */
-  BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1,
+/* AArch64 TLS relocation.  */
+  BFD_RELOC_AARCH64_JUMP_SLOT,
 
 
-/* AArch64 TLS LOCAL EXEC relocation.  */
-  BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12,
+/* AArch64 TLS relocation.  */
+  BFD_RELOC_AARCH64_RELATIVE,
 
 
-/* AArch64 TLS LOCAL EXEC relocation.  */
-  BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12,
+/* AArch64 TLS relocation.  */
+  BFD_RELOC_AARCH64_TLS_DTPMOD,
 
 
-/* AArch64 TLS LOCAL EXEC relocation.  */
-  BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC,
+/* AArch64 TLS relocation.  */
+  BFD_RELOC_AARCH64_TLS_DTPREL,
 
 
-/* AArch64 TLS LOCAL EXEC relocation.  */
-  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0,
+/* AArch64 TLS relocation.  */
+  BFD_RELOC_AARCH64_TLS_TPREL,
 
 
-/* AArch64 TLS LOCAL EXEC relocation.  */
-  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC,
+/* AArch64 TLS relocation.  */
+  BFD_RELOC_AARCH64_TLSDESC,
 
 
-/* AArch64 TLS LOCAL EXEC relocation.  */
-  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1,
+/* AArch64 support for STT_GNU_IFUNC.  */
+  BFD_RELOC_AARCH64_IRELATIVE,
 
 
-/* AArch64 TLS LOCAL EXEC relocation.  */
-  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC,
+/* AArch64 pseudo relocation code to mark the end of the AArch64
+relocation enumerators that have direct mapping to ELF reloc codes.
+There are a few more enumerators after this one; those are mainly
+used by the AArch64 assembler for the internal fixup or to select
+one of the above enumerators.  */
+  BFD_RELOC_AARCH64_RELOC_END,
 
 
-/* AArch64 TLS LOCAL EXEC relocation.  */
-  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2,
+/* AArch64 pseudo relocation code to be used internally by the AArch64
+assembler and not (currently) written to any object files.  */
+  BFD_RELOC_AARCH64_GAS_INTERNAL_FIXUP,
 
 
-/* AArch64 TLS relocation.  */
-  BFD_RELOC_AARCH64_TLS_DTPMOD64,
+/* AArch64 unspecified load/store instruction, holding bits 0 to 11 of the
+address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.  */
+  BFD_RELOC_AARCH64_LDST_LO12,
 
 
-/* AArch64 TLS relocation.  */
-  BFD_RELOC_AARCH64_TLS_DTPREL64,
+/* AArch64 pseudo relocation code to be used internally by the AArch64
+assembler and not (currently) written to any object files.  */
+  BFD_RELOC_AARCH64_LD_GOT_LO12_NC,
 
 
-/* AArch64 TLS relocation.  */
-  BFD_RELOC_AARCH64_TLS_TPREL64,
+/* AArch64 pseudo relocation code to be used internally by the AArch64
+assembler and not (currently) written to any object files.  */
+  BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC,
 
 
-/* AArch64 14 bit pc-relative test bit and branch.
-The lowest two bits must be zero and are not stored in the instruction,
-giving a 16 bit signed byte offset.  */
-  BFD_RELOC_AARCH64_TSTBR14,
+/* AArch64 pseudo relocation code to be used internally by the AArch64
+assembler and not (currently) written to any object files.  */
+  BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC,
 
 /* Tilera TILEPro Relocations.  */
   BFD_RELOC_TILEPRO_COPY,
 
 /* Tilera TILEPro Relocations.  */
   BFD_RELOC_TILEPRO_COPY,
index 60a8558e7ee19b5901dafbaf56d9019cd0508767..27b67859cfe8dd808a80fce84a0bf1653d81a613 100644 (file)
@@ -50,7 +50,7 @@
   indicate that foo is thread local and should be accessed via the
   traditional TLS mechanims.
 
   indicate that foo is thread local and should be accessed via the
   traditional TLS mechanims.
 
-  The relocations R_AARCH64_TLSDESC_{ADR_PAGE,LD64_LO12_NC,ADD_LO12_NC}
+  The relocations R_AARCH64_TLSDESC_{ADR_PAGE21,LD64_LO12_NC,ADD_LO12_NC}
   against foo indicate that 'foo' is thread local and should be accessed
   via a TLS descriptor mechanism.
 
   against foo indicate that 'foo' is thread local and should be accessed
   via a TLS descriptor mechanism.
 
 
   In the traditional TLS mechanism, the double GOT entry is used to
   provide the tls_index structure, containing module and offset
 
   In the traditional TLS mechanism, the double GOT entry is used to
   provide the tls_index structure, containing module and offset
-  entries. The static linker places the relocation R_AARCH64_TLS_DTPMOD64
+  entries. The static linker places the relocation R_AARCH64_TLS_DTPMOD
   on the module entry. The loader will subsequently fixup this
   relocation with the module identity.
 
   For global traditional TLS symbols the static linker places an
   on the module entry. The loader will subsequently fixup this
   relocation with the module identity.
 
   For global traditional TLS symbols the static linker places an
-  R_AARCH64_TLS_DTPREL64 relocation on the offset entry. The loader
+  R_AARCH64_TLS_DTPREL relocation on the offset entry. The loader
   will subsequently fixup the offset. For local TLS symbols the static
   linker fixes up offset.
 
   will subsequently fixup the offset. For local TLS symbols the static
   linker fixes up offset.
 
@@ -97,7 +97,7 @@
   This function is invoked for each relocation.
 
   The TLS relocations R_AARCH64_TLSGD_{ADR_PREL21,ADD_LO12_NC} and
   This function is invoked for each relocation.
 
   The TLS relocations R_AARCH64_TLSGD_{ADR_PREL21,ADD_LO12_NC} and
-  R_AARCH64_TLSDESC_{ADR_PAGE,LD64_LO12_NC,ADD_LO12_NC} are
+  R_AARCH64_TLSDESC_{ADR_PAGE21,LD64_LO12_NC,ADD_LO12_NC} are
   spotted. One time creation of local symbol data structures are
   created when the first local symbol is seen.
 
   spotted. One time creation of local symbol data structures are
   created when the first local symbol is seen.
 
 #if ARCH_SIZE == 64
 #define AARCH64_R(NAME)                R_AARCH64_ ## NAME
 #define AARCH64_R_STR(NAME)    "R_AARCH64_" #NAME
 #if ARCH_SIZE == 64
 #define AARCH64_R(NAME)                R_AARCH64_ ## NAME
 #define AARCH64_R_STR(NAME)    "R_AARCH64_" #NAME
+#define HOWTO64(...)           HOWTO (__VA_ARGS__)
+#define HOWTO32(...)           EMPTY_HOWTO (0)
 #define LOG_FILE_ALIGN 3
 #endif
 
 #if ARCH_SIZE == 32
 #define AARCH64_R(NAME)                R_AARCH64_P32_ ## NAME
 #define AARCH64_R_STR(NAME)    "R_AARCH64_P32_" #NAME
 #define LOG_FILE_ALIGN 3
 #endif
 
 #if ARCH_SIZE == 32
 #define AARCH64_R(NAME)                R_AARCH64_P32_ ## NAME
 #define AARCH64_R_STR(NAME)    "R_AARCH64_P32_" #NAME
+#define HOWTO64(...)           EMPTY_HOWTO (0)
+#define HOWTO32(...)           HOWTO (__VA_ARGS__)
 #define LOG_FILE_ALIGN 2
 #endif
 
 #define LOG_FILE_ALIGN 2
 #endif
 
@@ -163,39 +167,41 @@ bfd_elf_aarch64_put_addend (bfd *abfd,
                            bfd_byte *address,
                            reloc_howto_type *howto, bfd_signed_vma addend);
 
                            bfd_byte *address,
                            reloc_howto_type *howto, bfd_signed_vma addend);
 
-#define IS_AARCH64_TLS_RELOC(R_TYPE)                   \
-  ((R_TYPE) == R_AARCH64_TLSGD_ADR_PAGE21              \
-   || (R_TYPE) == R_AARCH64_TLSGD_ADD_LO12_NC          \
-   || (R_TYPE) == R_AARCH64_TLSIE_MOVW_GOTTPREL_G1     \
-   || (R_TYPE) == R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC  \
-   || (R_TYPE) == R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21  \
-   || (R_TYPE) == R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC        \
-   || (R_TYPE) == R_AARCH64_TLSIE_LD_GOTTPREL_PREL19   \
-   || (R_TYPE) == R_AARCH64_TLSLE_ADD_TPREL_LO12       \
-   || (R_TYPE) == R_AARCH64_TLSLE_ADD_TPREL_HI12       \
-   || (R_TYPE) == R_AARCH64_TLSLE_ADD_TPREL_LO12_NC    \
-   || (R_TYPE) == R_AARCH64_TLSLE_MOVW_TPREL_G2                \
-   || (R_TYPE) == R_AARCH64_TLSLE_MOVW_TPREL_G1                \
-   || (R_TYPE) == R_AARCH64_TLSLE_MOVW_TPREL_G1_NC     \
-   || (R_TYPE) == R_AARCH64_TLSLE_MOVW_TPREL_G0                \
-   || (R_TYPE) == R_AARCH64_TLSLE_MOVW_TPREL_G0_NC     \
-   || (R_TYPE) == R_AARCH64_TLS_DTPMOD64               \
-   || (R_TYPE) == R_AARCH64_TLS_DTPREL64               \
-   || (R_TYPE) == R_AARCH64_TLS_TPREL64                        \
+#define IS_AARCH64_TLS_RELOC(R_TYPE)                           \
+  ((R_TYPE) == BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21              \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC          \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1     \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC  \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21  \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC        \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC        \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19   \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12       \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12       \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC    \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2                \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1                \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC     \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0                \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC     \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLS_DTPMOD                 \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLS_DTPREL                 \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLS_TPREL                  \
    || IS_AARCH64_TLSDESC_RELOC ((R_TYPE)))
 
    || IS_AARCH64_TLSDESC_RELOC ((R_TYPE)))
 
-#define IS_AARCH64_TLSDESC_RELOC(R_TYPE)               \
-  ((R_TYPE) == R_AARCH64_TLSDESC_LD_PREL19             \
-   || (R_TYPE) == R_AARCH64_TLSDESC_ADR_PREL21         \
-   || (R_TYPE) == R_AARCH64_TLSDESC_ADR_PAGE21         \
-   || (R_TYPE) == R_AARCH64_TLSDESC_ADD_LO12_NC                \
-   || (R_TYPE) == R_AARCH64_TLSDESC_LD64_LO12_NC       \
-   || (R_TYPE) == R_AARCH64_TLSDESC_OFF_G1             \
-   || (R_TYPE) == R_AARCH64_TLSDESC_OFF_G0_NC          \
-   || (R_TYPE) == R_AARCH64_TLSDESC_LDR                        \
-   || (R_TYPE) == R_AARCH64_TLSDESC_ADD                        \
-   || (R_TYPE) == R_AARCH64_TLSDESC_CALL               \
-   || (R_TYPE) == R_AARCH64_TLSDESC)
+#define IS_AARCH64_TLSDESC_RELOC(R_TYPE)                       \
+  ((R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_LD_PREL19             \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21         \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21         \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC                \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC       \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC       \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_OFF_G1             \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC          \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_LDR                        \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_ADD                        \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_CALL               \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC)
 
 #define ELIMINATE_COPY_RELOCS 0
 
 
 #define ELIMINATE_COPY_RELOCS 0
 
@@ -210,8 +216,8 @@ bfd_elf_aarch64_put_addend (bfd *abfd,
 #define PLT_TLSDESC_ENTRY_SIZE          (32)
 
 /* Take the PAGE component of an address or offset.  */
 #define PLT_TLSDESC_ENTRY_SIZE          (32)
 
 /* Take the PAGE component of an address or offset.  */
-#define PG(x) ((x) & ~ 0xfff)
-#define PG_OFFSET(x) ((x) & 0xfff)
+#define PG(x) ((x) & ~ (bfd_vma) 0xfff)
+#define PG_OFFSET(x) ((x) & (bfd_vma) 0xfff)
 
 /* Encoding of the nop instruction */
 #define INSN_NOP 0xd503201f
 
 /* Encoding of the nop instruction */
 #define INSN_NOP 0xd503201f
@@ -269,146 +275,32 @@ elfNN_aarch64_tlsdesc_small_plt_entry[PLT_TLSDESC_ENTRY_SIZE] =
 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value.  */
 #define ALL_ONES (~ (bfd_vma) 0)
 
 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value.  */
 #define ALL_ONES (~ (bfd_vma) 0)
 
-static reloc_howto_type elf64_aarch64_howto_none =
-  HOWTO (R_AARCH64_NONE,       /* type */
-        0,                     /* rightshift */
-        0,                     /* size (0 = byte, 1 = short, 2 = long) */
-        0,                     /* bitsize */
-        FALSE,                 /* pc_relative */
-        0,                     /* bitpos */
-        complain_overflow_dont,/* complain_on_overflow */
-        bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_NONE",      /* name */
-        FALSE,                 /* partial_inplace */
-        0,                     /* src_mask */
-        0,                     /* dst_mask */
-        FALSE);                /* pcrel_offset */
+/* Indexed by the bfd interal reloc enumerators.
+   Therefore, the table needs to be synced with BFD_RELOC_AARCH64_*
+   in reloc.c.   */
 
 
-static reloc_howto_type elf64_aarch64_howto_dynrelocs[] =
+static reloc_howto_type elfNN_aarch64_howto_table[] =
 {
 {
-  HOWTO (R_AARCH64_COPY,       /* type */
-        0,                     /* rightshift */
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
-        64,                    /* bitsize */
-        FALSE,                 /* pc_relative */
-        0,                     /* bitpos */
-        complain_overflow_bitfield,    /* complain_on_overflow */
-        bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_COPY",      /* name */
-        TRUE,                  /* partial_inplace */
-        0xffffffff,            /* src_mask */
-        0xffffffff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
-
-  HOWTO (R_AARCH64_GLOB_DAT,   /* type */
-        0,                     /* rightshift */
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
-        64,                    /* bitsize */
-        FALSE,                 /* pc_relative */
-        0,                     /* bitpos */
-        complain_overflow_bitfield,    /* complain_on_overflow */
-        bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_GLOB_DAT",  /* name */
-        TRUE,                  /* partial_inplace */
-        0xffffffff,            /* src_mask */
-        0xffffffff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
-
-  HOWTO (R_AARCH64_JUMP_SLOT,  /* type */
-        0,                     /* rightshift */
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
-        64,                    /* bitsize */
-        FALSE,                 /* pc_relative */
-        0,                     /* bitpos */
-        complain_overflow_bitfield,    /* complain_on_overflow */
-        bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_JUMP_SLOT", /* name */
-        TRUE,                  /* partial_inplace */
-        0xffffffff,            /* src_mask */
-        0xffffffff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
-
-  HOWTO (R_AARCH64_RELATIVE,   /* type */
-        0,                     /* rightshift */
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
-        64,                    /* bitsize */
-        FALSE,                 /* pc_relative */
-        0,                     /* bitpos */
-        complain_overflow_bitfield,    /* complain_on_overflow */
-        bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_RELATIVE",  /* name */
-        TRUE,                  /* partial_inplace */
-        ALL_ONES,              /* src_mask */
-        ALL_ONES,              /* dst_mask */
-        FALSE),                /* pcrel_offset */
+  EMPTY_HOWTO (0),
 
 
-  HOWTO (R_AARCH64_TLS_DTPMOD64,       /* type */
-        0,                     /* rightshift */
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
-        64,                    /* bitsize */
-        FALSE,                 /* pc_relative */
-        0,                     /* bitpos */
-        complain_overflow_dont,        /* complain_on_overflow */
-        bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLS_DTPMOD64",      /* name */
-        FALSE,                 /* partial_inplace */
-        0,                     /* src_mask */
-        ALL_ONES,              /* dst_mask */
-        FALSE),                /* pc_reloffset */
-
-  HOWTO (R_AARCH64_TLS_DTPREL64,       /* type */
-        0,                     /* rightshift */
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
-        64,                    /* bitsize */
-        FALSE,                 /* pc_relative */
-        0,                     /* bitpos */
-        complain_overflow_dont,        /* complain_on_overflow */
-        bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLS_DTPREL64",      /* name */
-        FALSE,                 /* partial_inplace */
-        0,                     /* src_mask */
-        ALL_ONES,              /* dst_mask */
-        FALSE),                /* pcrel_offset */
-
-  HOWTO (R_AARCH64_TLS_TPREL64,        /* type */
-        0,                     /* rightshift */
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
-        64,                    /* bitsize */
-        FALSE,                 /* pc_relative */
-        0,                     /* bitpos */
-        complain_overflow_dont,        /* complain_on_overflow */
-        bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLS_TPREL64",       /* name */
-        FALSE,                 /* partial_inplace */
-        0,                     /* src_mask */
-        ALL_ONES,              /* dst_mask */
-        FALSE),                /* pcrel_offset */
+  /* Basic data relocations.  */
 
 
-  HOWTO (R_AARCH64_TLSDESC,    /* type */
+#if ARCH_SIZE == 64
+  HOWTO (R_AARCH64_NULL,       /* type */
         0,                     /* rightshift */
         0,                     /* rightshift */
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
-        64,                    /* bitsize */
+        0,                     /* size (0 = byte, 1 = short, 2 = long) */
+        0,                     /* bitsize */
         FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSDESC",   /* name */
+        "R_AARCH64_NULL",      /* name */
         FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
-        ALL_ONES,              /* dst_mask */
+        0,                     /* dst_mask */
         FALSE),                /* pcrel_offset */
         FALSE),                /* pcrel_offset */
-
-};
-
-/* Note: code such as elf64_aarch64_reloc_type_lookup expect to use e.g.
-   R_AARCH64_PREL64 as an index into this, and find the R_AARCH64_PREL64 HOWTO
-   in that slot.  */
-
-static reloc_howto_type elf64_aarch64_howto_table[] =
-{
-  /* Basic data relocations.  */
-
-  HOWTO (R_AARCH64_NULL,       /* type */
+#else
+  HOWTO (R_AARCH64_NONE,       /* type */
         0,                     /* rightshift */
         0,                     /* size (0 = byte, 1 = short, 2 = long) */
         0,                     /* bitsize */
         0,                     /* rightshift */
         0,                     /* size (0 = byte, 1 = short, 2 = long) */
         0,                     /* bitsize */
@@ -416,14 +308,15 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_NULL",      /* name */
+        "R_AARCH64_NONE",      /* name */
         FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0,                     /* dst_mask */
         FALSE),                /* pcrel_offset */
         FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0,                     /* dst_mask */
         FALSE),                /* pcrel_offset */
+#endif
 
   /* .xword: (S+A) */
 
   /* .xword: (S+A) */
-  HOWTO (R_AARCH64_ABS64,      /* type */
+  HOWTO64 (AARCH64_R (ABS64),  /* type */
         0,                     /* rightshift */
         4,                     /* size (4 = long long) */
         64,                    /* bitsize */
         0,                     /* rightshift */
         4,                     /* size (4 = long long) */
         64,                    /* bitsize */
@@ -431,14 +324,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_unsigned,    /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_unsigned,    /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_ABS64",     /* name */
+        AARCH64_R_STR (ABS64), /* name */
         FALSE,                 /* partial_inplace */
         ALL_ONES,              /* src_mask */
         ALL_ONES,              /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* .word: (S+A) */
         FALSE,                 /* partial_inplace */
         ALL_ONES,              /* src_mask */
         ALL_ONES,              /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* .word: (S+A) */
-  HOWTO (R_AARCH64_ABS32,      /* type */
+  HOWTO (AARCH64_R (ABS32),    /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
@@ -446,14 +339,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_unsigned,    /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_unsigned,    /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_ABS32",     /* name */
+        AARCH64_R_STR (ABS32), /* name */
         FALSE,                 /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* .half:  (S+A) */
         FALSE,                 /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* .half:  (S+A) */
-  HOWTO (R_AARCH64_ABS16,      /* type */
+  HOWTO (AARCH64_R (ABS16),    /* type */
         0,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
         0,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
@@ -461,14 +354,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_unsigned,    /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_unsigned,    /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_ABS16",     /* name */
+        AARCH64_R_STR (ABS16), /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* .xword: (S+A-P) */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* .xword: (S+A-P) */
-  HOWTO (R_AARCH64_PREL64,     /* type */
+  HOWTO64 (AARCH64_R (PREL64), /* type */
         0,                     /* rightshift */
         4,                     /* size (4 = long long) */
         64,                    /* bitsize */
         0,                     /* rightshift */
         4,                     /* size (4 = long long) */
         64,                    /* bitsize */
@@ -476,14 +369,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_PREL64",    /* name */
+        AARCH64_R_STR (PREL64),        /* name */
         FALSE,                 /* partial_inplace */
         ALL_ONES,              /* src_mask */
         ALL_ONES,              /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
   /* .word: (S+A-P) */
         FALSE,                 /* partial_inplace */
         ALL_ONES,              /* src_mask */
         ALL_ONES,              /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
   /* .word: (S+A-P) */
-  HOWTO (R_AARCH64_PREL32,     /* type */
+  HOWTO (AARCH64_R (PREL32),   /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
@@ -491,14 +384,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_PREL32",    /* name */
+        AARCH64_R_STR (PREL32),        /* name */
         FALSE,                 /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
   /* .half: (S+A-P) */
         FALSE,                 /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
   /* .half: (S+A-P) */
-  HOWTO (R_AARCH64_PREL16,     /* type */
+  HOWTO (AARCH64_R (PREL16),   /* type */
         0,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
         0,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
@@ -506,7 +399,7 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_PREL16",    /* name */
+        AARCH64_R_STR (PREL16),        /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
@@ -516,7 +409,7 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
      unsigned data or abs address inline.  */
 
   /* MOVZ:   ((S+A) >>  0) & 0xffff */
      unsigned data or abs address inline.  */
 
   /* MOVZ:   ((S+A) >>  0) & 0xffff */
-  HOWTO (R_AARCH64_MOVW_UABS_G0,       /* type */
+  HOWTO (AARCH64_R (MOVW_UABS_G0),     /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
@@ -524,14 +417,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_unsigned,    /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_unsigned,    /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_MOVW_UABS_G0",      /* name */
+        AARCH64_R_STR (MOVW_UABS_G0),  /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* MOVK:   ((S+A) >>  0) & 0xffff [no overflow check] */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* MOVK:   ((S+A) >>  0) & 0xffff [no overflow check] */
-  HOWTO (R_AARCH64_MOVW_UABS_G0_NC,    /* type */
+  HOWTO (AARCH64_R (MOVW_UABS_G0_NC),  /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
@@ -539,14 +432,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_MOVW_UABS_G0_NC",   /* name */
+        AARCH64_R_STR (MOVW_UABS_G0_NC),       /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* MOVZ:   ((S+A) >> 16) & 0xffff */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* MOVZ:   ((S+A) >> 16) & 0xffff */
-  HOWTO (R_AARCH64_MOVW_UABS_G1,       /* type */
+  HOWTO (AARCH64_R (MOVW_UABS_G1),     /* type */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
@@ -554,14 +447,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_unsigned,    /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_unsigned,    /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_MOVW_UABS_G1",      /* name */
+        AARCH64_R_STR (MOVW_UABS_G1),  /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* MOVK:   ((S+A) >> 16) & 0xffff [no overflow check] */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* MOVK:   ((S+A) >> 16) & 0xffff [no overflow check] */
-  HOWTO (R_AARCH64_MOVW_UABS_G1_NC,    /* type */
+  HOWTO64 (AARCH64_R (MOVW_UABS_G1_NC),        /* type */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
@@ -569,14 +462,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_MOVW_UABS_G1_NC",   /* name */
+        AARCH64_R_STR (MOVW_UABS_G1_NC),       /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* MOVZ:   ((S+A) >> 32) & 0xffff */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* MOVZ:   ((S+A) >> 32) & 0xffff */
-  HOWTO (R_AARCH64_MOVW_UABS_G2,       /* type */
+  HOWTO64 (AARCH64_R (MOVW_UABS_G2),   /* type */
         32,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
         32,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
@@ -584,14 +477,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_unsigned,    /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_unsigned,    /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_MOVW_UABS_G2",      /* name */
+        AARCH64_R_STR (MOVW_UABS_G2),  /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* MOVK:   ((S+A) >> 32) & 0xffff [no overflow check] */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* MOVK:   ((S+A) >> 32) & 0xffff [no overflow check] */
-  HOWTO (R_AARCH64_MOVW_UABS_G2_NC,    /* type */
+  HOWTO64 (AARCH64_R (MOVW_UABS_G2_NC),        /* type */
         32,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
         32,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
@@ -599,14 +492,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_MOVW_UABS_G2_NC",   /* name */
+        AARCH64_R_STR (MOVW_UABS_G2_NC),       /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* MOVZ:   ((S+A) >> 48) & 0xffff */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* MOVZ:   ((S+A) >> 48) & 0xffff */
-  HOWTO (R_AARCH64_MOVW_UABS_G3,       /* type */
+  HOWTO64 (AARCH64_R (MOVW_UABS_G3),   /* type */
         48,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
         48,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
@@ -614,7 +507,7 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_unsigned,    /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_unsigned,    /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_MOVW_UABS_G3",      /* name */
+        AARCH64_R_STR (MOVW_UABS_G3),  /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
@@ -625,7 +518,7 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
      to MOVN or MOVZ depending on sign of calculated value.  */
 
   /* MOV[ZN]:   ((S+A) >>  0) & 0xffff */
      to MOVN or MOVZ depending on sign of calculated value.  */
 
   /* MOV[ZN]:   ((S+A) >>  0) & 0xffff */
-  HOWTO (R_AARCH64_MOVW_SABS_G0,       /* type */
+  HOWTO (AARCH64_R (MOVW_SABS_G0),     /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
@@ -633,14 +526,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_MOVW_SABS_G0",      /* name */
+        AARCH64_R_STR (MOVW_SABS_G0),  /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* MOV[ZN]:   ((S+A) >> 16) & 0xffff */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* MOV[ZN]:   ((S+A) >> 16) & 0xffff */
-  HOWTO (R_AARCH64_MOVW_SABS_G1,       /* type */
+  HOWTO64 (AARCH64_R (MOVW_SABS_G1),   /* type */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
@@ -648,14 +541,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_MOVW_SABS_G1",      /* name */
+        AARCH64_R_STR (MOVW_SABS_G1),  /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* MOV[ZN]:   ((S+A) >> 32) & 0xffff */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* MOV[ZN]:   ((S+A) >> 32) & 0xffff */
-  HOWTO (R_AARCH64_MOVW_SABS_G2,       /* type */
+  HOWTO64 (AARCH64_R (MOVW_SABS_G2),   /* type */
         32,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
         32,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
@@ -663,7 +556,7 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_MOVW_SABS_G2",      /* name */
+        AARCH64_R_STR (MOVW_SABS_G2),  /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
@@ -673,7 +566,7 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
    addresses: PG(x) is (x & ~0xfff).  */
 
   /* LD-lit: ((S+A-P) >> 2) & 0x7ffff */
    addresses: PG(x) is (x & ~0xfff).  */
 
   /* LD-lit: ((S+A-P) >> 2) & 0x7ffff */
-  HOWTO (R_AARCH64_LD_PREL_LO19,       /* type */
+  HOWTO (AARCH64_R (LD_PREL_LO19),     /* type */
         2,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         19,                    /* bitsize */
         2,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         19,                    /* bitsize */
@@ -681,14 +574,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_LD_PREL_LO19",      /* name */
+        AARCH64_R_STR (LD_PREL_LO19),  /* name */
         FALSE,                 /* partial_inplace */
         0x7ffff,               /* src_mask */
         0x7ffff,               /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
   /* ADR:    (S+A-P) & 0x1fffff */
         FALSE,                 /* partial_inplace */
         0x7ffff,               /* src_mask */
         0x7ffff,               /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
   /* ADR:    (S+A-P) & 0x1fffff */
-  HOWTO (R_AARCH64_ADR_PREL_LO21,      /* type */
+  HOWTO (AARCH64_R (ADR_PREL_LO21),    /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         21,                    /* bitsize */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         21,                    /* bitsize */
@@ -696,14 +589,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_ADR_PREL_LO21",     /* name */
+        AARCH64_R_STR (ADR_PREL_LO21), /* name */
         FALSE,                 /* partial_inplace */
         0x1fffff,              /* src_mask */
         0x1fffff,              /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
   /* ADRP:   ((PG(S+A)-PG(P)) >> 12) & 0x1fffff */
         FALSE,                 /* partial_inplace */
         0x1fffff,              /* src_mask */
         0x1fffff,              /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
   /* ADRP:   ((PG(S+A)-PG(P)) >> 12) & 0x1fffff */
-  HOWTO (R_AARCH64_ADR_PREL_PG_HI21,   /* type */
+  HOWTO (AARCH64_R (ADR_PREL_PG_HI21), /* type */
         12,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         21,                    /* bitsize */
         12,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         21,                    /* bitsize */
@@ -711,14 +604,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_ADR_PREL_PG_HI21",  /* name */
+        AARCH64_R_STR (ADR_PREL_PG_HI21),      /* name */
         FALSE,                 /* partial_inplace */
         0x1fffff,              /* src_mask */
         0x1fffff,              /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
   /* ADRP:   ((PG(S+A)-PG(P)) >> 12) & 0x1fffff [no overflow check] */
         FALSE,                 /* partial_inplace */
         0x1fffff,              /* src_mask */
         0x1fffff,              /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
   /* ADRP:   ((PG(S+A)-PG(P)) >> 12) & 0x1fffff [no overflow check] */
-  HOWTO (R_AARCH64_ADR_PREL_PG_HI21_NC,        /* type */
+  HOWTO64 (AARCH64_R (ADR_PREL_PG_HI21_NC),    /* type */
         12,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         21,                    /* bitsize */
         12,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         21,                    /* bitsize */
@@ -726,14 +619,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_ADR_PREL_PG_HI21_NC",       /* name */
+        AARCH64_R_STR (ADR_PREL_PG_HI21_NC),   /* name */
         FALSE,                 /* partial_inplace */
         0x1fffff,              /* src_mask */
         0x1fffff,              /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
   /* ADD:    (S+A) & 0xfff [no overflow check] */
         FALSE,                 /* partial_inplace */
         0x1fffff,              /* src_mask */
         0x1fffff,              /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
   /* ADD:    (S+A) & 0xfff [no overflow check] */
-  HOWTO (R_AARCH64_ADD_ABS_LO12_NC,    /* type */
+  HOWTO (AARCH64_R (ADD_ABS_LO12_NC),  /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -741,14 +634,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         10,                    /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         10,                    /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_ADD_ABS_LO12_NC",   /* name */
+        AARCH64_R_STR (ADD_ABS_LO12_NC),       /* name */
         FALSE,                 /* partial_inplace */
         0x3ffc00,              /* src_mask */
         0x3ffc00,              /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* LD/ST8:  (S+A) & 0xfff */
         FALSE,                 /* partial_inplace */
         0x3ffc00,              /* src_mask */
         0x3ffc00,              /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* LD/ST8:  (S+A) & 0xfff */
-  HOWTO (R_AARCH64_LDST8_ABS_LO12_NC,  /* type */
+  HOWTO (AARCH64_R (LDST8_ABS_LO12_NC),        /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -756,7 +649,7 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_LDST8_ABS_LO12_NC", /* name */
+        AARCH64_R_STR (LDST8_ABS_LO12_NC),     /* name */
         FALSE,                 /* partial_inplace */
         0xfff,                 /* src_mask */
         0xfff,                 /* dst_mask */
         FALSE,                 /* partial_inplace */
         0xfff,                 /* src_mask */
         0xfff,                 /* dst_mask */
@@ -765,7 +658,7 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
   /* Relocations for control-flow instructions.  */
 
   /* TBZ/NZ: ((S+A-P) >> 2) & 0x3fff */
   /* Relocations for control-flow instructions.  */
 
   /* TBZ/NZ: ((S+A-P) >> 2) & 0x3fff */
-  HOWTO (R_AARCH64_TSTBR14,    /* type */
+  HOWTO (AARCH64_R (TSTBR14),  /* type */
         2,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         14,                    /* bitsize */
         2,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         14,                    /* bitsize */
@@ -773,14 +666,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TSTBR14",   /* name */
+        AARCH64_R_STR (TSTBR14),       /* name */
         FALSE,                 /* partial_inplace */
         0x3fff,                /* src_mask */
         0x3fff,                /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
   /* B.cond: ((S+A-P) >> 2) & 0x7ffff */
         FALSE,                 /* partial_inplace */
         0x3fff,                /* src_mask */
         0x3fff,                /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
   /* B.cond: ((S+A-P) >> 2) & 0x7ffff */
-  HOWTO (R_AARCH64_CONDBR19,   /* type */
+  HOWTO (AARCH64_R (CONDBR19), /* type */
         2,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         19,                    /* bitsize */
         2,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         19,                    /* bitsize */
@@ -788,16 +681,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_CONDBR19",  /* name */
+        AARCH64_R_STR (CONDBR19),      /* name */
         FALSE,                 /* partial_inplace */
         0x7ffff,               /* src_mask */
         0x7ffff,               /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0x7ffff,               /* src_mask */
         0x7ffff,               /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
-  EMPTY_HOWTO (281),
-
   /* B:      ((S+A-P) >> 2) & 0x3ffffff */
   /* B:      ((S+A-P) >> 2) & 0x3ffffff */
-  HOWTO (R_AARCH64_JUMP26,     /* type */
+  HOWTO (AARCH64_R (JUMP26),   /* type */
         2,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         26,                    /* bitsize */
         2,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         26,                    /* bitsize */
@@ -805,14 +696,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_JUMP26",    /* name */
+        AARCH64_R_STR (JUMP26),        /* name */
         FALSE,                 /* partial_inplace */
         0x3ffffff,             /* src_mask */
         0x3ffffff,             /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
   /* BL:     ((S+A-P) >> 2) & 0x3ffffff */
         FALSE,                 /* partial_inplace */
         0x3ffffff,             /* src_mask */
         0x3ffffff,             /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
   /* BL:     ((S+A-P) >> 2) & 0x3ffffff */
-  HOWTO (R_AARCH64_CALL26,     /* type */
+  HOWTO (AARCH64_R (CALL26),   /* type */
         2,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         26,                    /* bitsize */
         2,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         26,                    /* bitsize */
@@ -820,14 +711,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_CALL26",    /* name */
+        AARCH64_R_STR (CALL26),        /* name */
         FALSE,                 /* partial_inplace */
         0x3ffffff,             /* src_mask */
         0x3ffffff,             /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
   /* LD/ST16:  (S+A) & 0xffe */
         FALSE,                 /* partial_inplace */
         0x3ffffff,             /* src_mask */
         0x3ffffff,             /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
   /* LD/ST16:  (S+A) & 0xffe */
-  HOWTO (R_AARCH64_LDST16_ABS_LO12_NC, /* type */
+  HOWTO (AARCH64_R (LDST16_ABS_LO12_NC),       /* type */
         1,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         1,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -835,14 +726,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_LDST16_ABS_LO12_NC",        /* name */
+        AARCH64_R_STR (LDST16_ABS_LO12_NC),    /* name */
         FALSE,                 /* partial_inplace */
         0xffe,                 /* src_mask */
         0xffe,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* LD/ST32:  (S+A) & 0xffc */
         FALSE,                 /* partial_inplace */
         0xffe,                 /* src_mask */
         0xffe,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* LD/ST32:  (S+A) & 0xffc */
-  HOWTO (R_AARCH64_LDST32_ABS_LO12_NC, /* type */
+  HOWTO (AARCH64_R (LDST32_ABS_LO12_NC),       /* type */
         2,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         2,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -850,14 +741,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_LDST32_ABS_LO12_NC",        /* name */
+        AARCH64_R_STR (LDST32_ABS_LO12_NC),    /* name */
         FALSE,                 /* partial_inplace */
         0xffc,                 /* src_mask */
         0xffc,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* LD/ST64:  (S+A) & 0xff8 */
         FALSE,                 /* partial_inplace */
         0xffc,                 /* src_mask */
         0xffc,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* LD/ST64:  (S+A) & 0xff8 */
-  HOWTO (R_AARCH64_LDST64_ABS_LO12_NC, /* type */
+  HOWTO (AARCH64_R (LDST64_ABS_LO12_NC),       /* type */
         3,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         3,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -865,27 +756,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_LDST64_ABS_LO12_NC",        /* name */
+        AARCH64_R_STR (LDST64_ABS_LO12_NC),    /* name */
         FALSE,                 /* partial_inplace */
         0xff8,                 /* src_mask */
         0xff8,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0xff8,                 /* src_mask */
         0xff8,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  EMPTY_HOWTO (287),
-  EMPTY_HOWTO (288),
-  EMPTY_HOWTO (289),
-  EMPTY_HOWTO (290),
-  EMPTY_HOWTO (291),
-  EMPTY_HOWTO (292),
-  EMPTY_HOWTO (293),
-  EMPTY_HOWTO (294),
-  EMPTY_HOWTO (295),
-  EMPTY_HOWTO (296),
-  EMPTY_HOWTO (297),
-  EMPTY_HOWTO (298),
-
   /* LD/ST128:  (S+A) & 0xff0 */
   /* LD/ST128:  (S+A) & 0xff0 */
-  HOWTO (R_AARCH64_LDST128_ABS_LO12_NC,        /* type */
+  HOWTO (AARCH64_R (LDST128_ABS_LO12_NC),      /* type */
         4,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         4,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -893,25 +771,15 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_LDST128_ABS_LO12_NC",       /* name */
+        AARCH64_R_STR (LDST128_ABS_LO12_NC),   /* name */
         FALSE,                 /* partial_inplace */
         0xff0,                 /* src_mask */
         0xff0,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0xff0,                 /* src_mask */
         0xff0,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  EMPTY_HOWTO (300),
-  EMPTY_HOWTO (301),
-  EMPTY_HOWTO (302),
-  EMPTY_HOWTO (303),
-  EMPTY_HOWTO (304),
-  EMPTY_HOWTO (305),
-  EMPTY_HOWTO (306),
-  EMPTY_HOWTO (307),
-  EMPTY_HOWTO (308),
-
   /* Set a load-literal immediate field to bits
      0x1FFFFC of G(S)-P */
   /* Set a load-literal immediate field to bits
      0x1FFFFC of G(S)-P */
-  HOWTO (R_AARCH64_GOT_LD_PREL19,      /* type */
+  HOWTO (AARCH64_R (GOT_LD_PREL19),    /* type */
         2,                             /* rightshift */
         2,                             /* size (0 = byte,1 = short,2 = long) */
         19,                            /* bitsize */
         2,                             /* rightshift */
         2,                             /* size (0 = byte,1 = short,2 = long) */
         19,                            /* bitsize */
@@ -919,17 +787,15 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                             /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc,         /* special_function */
         0,                             /* bitpos */
         complain_overflow_signed,      /* complain_on_overflow */
         bfd_elf_generic_reloc,         /* special_function */
-        "R_AARCH64_GOT_LD_PREL19",     /* name */
+        AARCH64_R_STR (GOT_LD_PREL19), /* name */
         FALSE,                         /* partial_inplace */
         0xffffe0,                      /* src_mask */
         0xffffe0,                      /* dst_mask */
         TRUE),                         /* pcrel_offset */
 
         FALSE,                         /* partial_inplace */
         0xffffe0,                      /* src_mask */
         0xffffe0,                      /* dst_mask */
         TRUE),                         /* pcrel_offset */
 
-  EMPTY_HOWTO (310),
-
   /* Get to the page for the GOT entry for the symbol
      (G(S) - P) using an ADRP instruction.  */
   /* Get to the page for the GOT entry for the symbol
      (G(S) - P) using an ADRP instruction.  */
-  HOWTO (R_AARCH64_ADR_GOT_PAGE,       /* type */
+  HOWTO (AARCH64_R (ADR_GOT_PAGE),     /* type */
         12,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         21,                    /* bitsize */
         12,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         21,                    /* bitsize */
@@ -937,14 +803,14 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_ADR_GOT_PAGE",      /* name */
+        AARCH64_R_STR (ADR_GOT_PAGE),  /* name */
         FALSE,                 /* partial_inplace */
         0x1fffff,              /* src_mask */
         0x1fffff,              /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0x1fffff,              /* src_mask */
         0x1fffff,              /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
-  /* LDNN: GOT offset G(S) & 0xff8 */
-  HOWTO (R_AARCH64_LDNN_GOT_LO12_NC,   /* type */
+  /* LD64: GOT offset G(S) & 0xff8  */
+  HOWTO64 (AARCH64_R (LD64_GOT_LO12_NC),       /* type */
         3,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         3,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -952,20 +818,30 @@ static reloc_howto_type elf64_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_LDNN_GOT_LO12_NC",  /* name */
+        AARCH64_R_STR (LD64_GOT_LO12_NC),      /* name */
         FALSE,                 /* partial_inplace */
         0xff8,                 /* src_mask */
         0xff8,                 /* dst_mask */
         FALSE,                 /* partial_inplace */
         0xff8,                 /* src_mask */
         0xff8,                 /* dst_mask */
-        FALSE)                 /* pcrel_offset */
-};
+        FALSE),                /* pcrel_offset */
 
 
-static reloc_howto_type elf64_aarch64_tls_howto_table[] =
-{
-  EMPTY_HOWTO (512),
+  /* LD32: GOT offset G(S) & 0xffc  */
+  HOWTO32 (AARCH64_R (LD32_GOT_LO12_NC),       /* type */
+        2,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        12,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_dont,        /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* special_function */
+        AARCH64_R_STR (LD32_GOT_LO12_NC),      /* name */
+        FALSE,                 /* partial_inplace */
+        0xffc,                 /* src_mask */
+        0xffc,                 /* dst_mask */
+        FALSE),                /* pcrel_offset */
 
   /* Get to the page for the GOT entry for the symbol
      (G(S) - P) using an ADRP instruction.  */
 
   /* Get to the page for the GOT entry for the symbol
      (G(S) - P) using an ADRP instruction.  */
-  HOWTO (R_AARCH64_TLSGD_ADR_PAGE21,   /* type */
+  HOWTO (AARCH64_R (TLSGD_ADR_PAGE21), /* type */
         12,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         21,                    /* bitsize */
         12,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         21,                    /* bitsize */
@@ -973,14 +849,14 @@ static reloc_howto_type elf64_aarch64_tls_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSGD_ADR_PAGE21",  /* name */
+        AARCH64_R_STR (TLSGD_ADR_PAGE21),      /* name */
         FALSE,                 /* partial_inplace */
         0x1fffff,              /* src_mask */
         0x1fffff,              /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
   /* ADD: GOT offset G(S) & 0xff8 [no overflow check] */
         FALSE,                 /* partial_inplace */
         0x1fffff,              /* src_mask */
         0x1fffff,              /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
   /* ADD: GOT offset G(S) & 0xff8 [no overflow check] */
-  HOWTO (R_AARCH64_TLSGD_ADD_LO12_NC,  /* type */
+  HOWTO (AARCH64_R (TLSGD_ADD_LO12_NC),        /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -988,38 +864,13 @@ static reloc_howto_type elf64_aarch64_tls_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSGD_ADD_LO12_NC", /* name */
+        AARCH64_R_STR (TLSGD_ADD_LO12_NC),     /* name */
         FALSE,                 /* partial_inplace */
         0xfff,                 /* src_mask */
         0xfff,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0xfff,                 /* src_mask */
         0xfff,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  EMPTY_HOWTO (515),
-  EMPTY_HOWTO (516),
-  EMPTY_HOWTO (517),
-  EMPTY_HOWTO (518),
-  EMPTY_HOWTO (519),
-  EMPTY_HOWTO (520),
-  EMPTY_HOWTO (521),
-  EMPTY_HOWTO (522),
-  EMPTY_HOWTO (523),
-  EMPTY_HOWTO (524),
-  EMPTY_HOWTO (525),
-  EMPTY_HOWTO (526),
-  EMPTY_HOWTO (527),
-  EMPTY_HOWTO (528),
-  EMPTY_HOWTO (529),
-  EMPTY_HOWTO (530),
-  EMPTY_HOWTO (531),
-  EMPTY_HOWTO (532),
-  EMPTY_HOWTO (533),
-  EMPTY_HOWTO (534),
-  EMPTY_HOWTO (535),
-  EMPTY_HOWTO (536),
-  EMPTY_HOWTO (537),
-  EMPTY_HOWTO (538),
-
-  HOWTO (R_AARCH64_TLSIE_MOVW_GOTTPREL_G1,     /* type */
+  HOWTO64 (AARCH64_R (TLSIE_MOVW_GOTTPREL_G1), /* type */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
@@ -1027,13 +878,13 @@ static reloc_howto_type elf64_aarch64_tls_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSIE_MOVW_GOTTPREL_G1",    /* name */
+        AARCH64_R_STR (TLSIE_MOVW_GOTTPREL_G1),        /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  HOWTO (R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC,  /* type */
+  HOWTO64 (AARCH64_R (TLSIE_MOVW_GOTTPREL_G0_NC),      /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
@@ -1041,13 +892,13 @@ static reloc_howto_type elf64_aarch64_tls_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC", /* name */
+        AARCH64_R_STR (TLSIE_MOVW_GOTTPREL_G0_NC),     /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  HOWTO (R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21,  /* type */
+  HOWTO (AARCH64_R (TLSIE_ADR_GOTTPREL_PAGE21),        /* type */
         12,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         21,                    /* bitsize */
         12,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         21,                    /* bitsize */
@@ -1055,13 +906,13 @@ static reloc_howto_type elf64_aarch64_tls_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21", /* name */
+        AARCH64_R_STR (TLSIE_ADR_GOTTPREL_PAGE21),     /* name */
         FALSE,                 /* partial_inplace */
         0x1fffff,              /* src_mask */
         0x1fffff,              /* dst_mask */
         FALSE),                /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0x1fffff,              /* src_mask */
         0x1fffff,              /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  HOWTO (R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC,        /* type */
+  HOWTO64 (AARCH64_R (TLSIE_LD64_GOTTPREL_LO12_NC),    /* type */
         3,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         3,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -1069,13 +920,27 @@ static reloc_howto_type elf64_aarch64_tls_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC",       /* name */
+        AARCH64_R_STR (TLSIE_LD64_GOTTPREL_LO12_NC),   /* name */
         FALSE,                 /* partial_inplace */
         0xff8,                 /* src_mask */
         0xff8,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0xff8,                 /* src_mask */
         0xff8,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  HOWTO (R_AARCH64_TLSIE_LD_GOTTPREL_PREL19,   /* type */
+  HOWTO32 (AARCH64_R (TLSIE_LD32_GOTTPREL_LO12_NC),    /* type */
+        2,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        12,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_dont,        /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* special_function */
+        AARCH64_R_STR (TLSIE_LD32_GOTTPREL_LO12_NC),   /* name */
+        FALSE,                 /* partial_inplace */
+        0xffc,                 /* src_mask */
+        0xffc,                 /* dst_mask */
+        FALSE),                /* pcrel_offset */
+
+  HOWTO (AARCH64_R (TLSIE_LD_GOTTPREL_PREL19), /* type */
         2,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         21,                    /* bitsize */
         2,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         21,                    /* bitsize */
@@ -1083,13 +948,13 @@ static reloc_howto_type elf64_aarch64_tls_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSIE_LD_GOTTPREL_PREL19",  /* name */
+        AARCH64_R_STR (TLSIE_LD_GOTTPREL_PREL19),      /* name */
         FALSE,                 /* partial_inplace */
         0x1ffffc,              /* src_mask */
         0x1ffffc,              /* dst_mask */
         FALSE),                /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0x1ffffc,              /* src_mask */
         0x1ffffc,              /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  HOWTO (R_AARCH64_TLSLE_MOVW_TPREL_G2,        /* type */
+  HOWTO64 (AARCH64_R (TLSLE_MOVW_TPREL_G2),    /* type */
         32,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         32,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -1097,13 +962,13 @@ static reloc_howto_type elf64_aarch64_tls_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSLE_MOVW_TPREL_G2",       /* name */
+        AARCH64_R_STR (TLSLE_MOVW_TPREL_G2),   /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  HOWTO (R_AARCH64_TLSLE_MOVW_TPREL_G1,        /* type */
+  HOWTO (AARCH64_R (TLSLE_MOVW_TPREL_G1),      /* type */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -1111,13 +976,13 @@ static reloc_howto_type elf64_aarch64_tls_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSLE_MOVW_TPREL_G1",       /* name */
+        AARCH64_R_STR (TLSLE_MOVW_TPREL_G1),   /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  HOWTO (R_AARCH64_TLSLE_MOVW_TPREL_G1_NC,     /* type */
+  HOWTO64 (AARCH64_R (TLSLE_MOVW_TPREL_G1_NC), /* type */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -1125,13 +990,13 @@ static reloc_howto_type elf64_aarch64_tls_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSLE_MOVW_TPREL_G1_NC",    /* name */
+        AARCH64_R_STR (TLSLE_MOVW_TPREL_G1_NC),        /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  HOWTO (R_AARCH64_TLSLE_MOVW_TPREL_G0,        /* type */
+  HOWTO (AARCH64_R (TLSLE_MOVW_TPREL_G0),      /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -1139,13 +1004,13 @@ static reloc_howto_type elf64_aarch64_tls_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSLE_MOVW_TPREL_G0",       /* name */
+        AARCH64_R_STR (TLSLE_MOVW_TPREL_G0),   /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  HOWTO (R_AARCH64_TLSLE_MOVW_TPREL_G0_NC,     /* type */
+  HOWTO (AARCH64_R (TLSLE_MOVW_TPREL_G0_NC),   /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -1153,13 +1018,13 @@ static reloc_howto_type elf64_aarch64_tls_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSLE_MOVW_TPREL_G0_NC",    /* name */
+        AARCH64_R_STR (TLSLE_MOVW_TPREL_G0_NC),        /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  HOWTO (R_AARCH64_TLSLE_ADD_TPREL_HI12,       /* type */
+  HOWTO (AARCH64_R (TLSLE_ADD_TPREL_HI12),     /* type */
         12,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         12,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -1167,13 +1032,13 @@ static reloc_howto_type elf64_aarch64_tls_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSLE_ADD_TPREL_HI12",      /* name */
+        AARCH64_R_STR (TLSLE_ADD_TPREL_HI12),  /* name */
         FALSE,                 /* partial_inplace */
         0xfff,                 /* src_mask */
         0xfff,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0xfff,                 /* src_mask */
         0xfff,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  HOWTO (R_AARCH64_TLSLE_ADD_TPREL_LO12,       /* type */
+  HOWTO (AARCH64_R (TLSLE_ADD_TPREL_LO12),     /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -1181,13 +1046,13 @@ static reloc_howto_type elf64_aarch64_tls_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSLE_ADD_TPREL_LO12",      /* name */
+        AARCH64_R_STR (TLSLE_ADD_TPREL_LO12),  /* name */
         FALSE,                 /* partial_inplace */
         0xfff,                 /* src_mask */
         0xfff,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0xfff,                 /* src_mask */
         0xfff,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  HOWTO (R_AARCH64_TLSLE_ADD_TPREL_LO12_NC,    /* type */
+  HOWTO (AARCH64_R (TLSLE_ADD_TPREL_LO12_NC),  /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -1195,16 +1060,13 @@ static reloc_howto_type elf64_aarch64_tls_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSLE_ADD_TPREL_LO12_NC",   /* name */
+        AARCH64_R_STR (TLSLE_ADD_TPREL_LO12_NC),       /* name */
         FALSE,                 /* partial_inplace */
         0xfff,                 /* src_mask */
         0xfff,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
         FALSE,                 /* partial_inplace */
         0xfff,                 /* src_mask */
         0xfff,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
-};
 
 
-static reloc_howto_type elf64_aarch64_tlsdesc_howto_table[] =
-{
-  HOWTO (R_AARCH64_TLSDESC_LD_PREL19,  /* type */
+  HOWTO (AARCH64_R (TLSDESC_LD_PREL19),        /* type */
         2,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         21,                    /* bitsize */
         2,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         21,                    /* bitsize */
@@ -1212,13 +1074,13 @@ static reloc_howto_type elf64_aarch64_tlsdesc_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSDESC_LD_PREL19", /* name */
+        AARCH64_R_STR (TLSDESC_LD_PREL19),     /* name */
         FALSE,                 /* partial_inplace */
         0x1ffffc,              /* src_mask */
         0x1ffffc,              /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0x1ffffc,              /* src_mask */
         0x1ffffc,              /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
-  HOWTO (R_AARCH64_TLSDESC_ADR_PREL21, /* type */
+  HOWTO (AARCH64_R (TLSDESC_ADR_PREL21),       /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         21,                    /* bitsize */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         21,                    /* bitsize */
@@ -1226,7 +1088,7 @@ static reloc_howto_type elf64_aarch64_tlsdesc_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSDESC_ADR_PREL21",        /* name */
+        AARCH64_R_STR (TLSDESC_ADR_PREL21),    /* name */
         FALSE,                 /* partial_inplace */
         0x1fffff,              /* src_mask */
         0x1fffff,              /* dst_mask */
         FALSE,                 /* partial_inplace */
         0x1fffff,              /* src_mask */
         0x1fffff,              /* dst_mask */
@@ -1234,7 +1096,7 @@ static reloc_howto_type elf64_aarch64_tlsdesc_howto_table[] =
 
   /* Get to the page for the GOT entry for the symbol
      (G(S) - P) using an ADRP instruction.  */
 
   /* Get to the page for the GOT entry for the symbol
      (G(S) - P) using an ADRP instruction.  */
-  HOWTO (R_AARCH64_TLSDESC_ADR_PAGE21, /* type */
+  HOWTO (AARCH64_R (TLSDESC_ADR_PAGE21),       /* type */
         12,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         21,                    /* bitsize */
         12,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         21,                    /* bitsize */
@@ -1242,14 +1104,14 @@ static reloc_howto_type elf64_aarch64_tlsdesc_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSDESC_ADR_PAGE21",        /* name */
+        AARCH64_R_STR (TLSDESC_ADR_PAGE21),    /* name */
         FALSE,                 /* partial_inplace */
         0x1fffff,              /* src_mask */
         0x1fffff,              /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0x1fffff,              /* src_mask */
         0x1fffff,              /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
-  /* LD64: GOT offset G(S) & 0xfff.  */
-  HOWTO (R_AARCH64_TLSDESC_LD64_LO12_NC,       /* type */
+  /* LD64: GOT offset G(S) & 0xff8.  */
+  HOWTO64 (AARCH64_R (TLSDESC_LD64_LO12_NC),   /* type */
         3,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         3,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -1257,14 +1119,29 @@ static reloc_howto_type elf64_aarch64_tlsdesc_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSDESC_LD64_LO12_NC",      /* name */
+        AARCH64_R_STR (TLSDESC_LD64_LO12_NC),  /* name */
         FALSE,                 /* partial_inplace */
         FALSE,                 /* partial_inplace */
-        0xfff,                 /* src_mask */
-        0xfff,                 /* dst_mask */
+        0xff8,                 /* src_mask */
+        0xff8,                 /* dst_mask */
+        FALSE),                /* pcrel_offset */
+
+  /* LD32: GOT offset G(S) & 0xffc.  */
+  HOWTO32 (AARCH64_R (TLSDESC_LD32_LO12_NC),   /* type */
+        2,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        12,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_dont,        /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* special_function */
+        AARCH64_R_STR (TLSDESC_LD32_LO12_NC),  /* name */
+        FALSE,                 /* partial_inplace */
+        0xffc,                 /* src_mask */
+        0xffc,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
 
   /* ADD: GOT offset G(S) & 0xfff.  */
         FALSE),                /* pcrel_offset */
 
   /* ADD: GOT offset G(S) & 0xfff.  */
-  HOWTO (R_AARCH64_TLSDESC_ADD_LO12_NC,        /* type */
+  HOWTO (AARCH64_R (TLSDESC_ADD_LO12_NC),      /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -1272,13 +1149,13 @@ static reloc_howto_type elf64_aarch64_tlsdesc_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSDESC_ADD_LO12_NC",       /* name */
+        AARCH64_R_STR (TLSDESC_ADD_LO12_NC),   /* name */
         FALSE,                 /* partial_inplace */
         0xfff,                 /* src_mask */
         0xfff,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0xfff,                 /* src_mask */
         0xfff,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  HOWTO (R_AARCH64_TLSDESC_OFF_G1,     /* type */
+  HOWTO64 (AARCH64_R (TLSDESC_OFF_G1), /* type */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -1286,13 +1163,13 @@ static reloc_howto_type elf64_aarch64_tlsdesc_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSDESC_OFF_G1",    /* name */
+        AARCH64_R_STR (TLSDESC_OFF_G1),        /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  HOWTO (R_AARCH64_TLSDESC_OFF_G0_NC,  /* type */
+  HOWTO64 (AARCH64_R (TLSDESC_OFF_G0_NC),      /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -1300,13 +1177,13 @@ static reloc_howto_type elf64_aarch64_tlsdesc_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSDESC_OFF_G0_NC", /* name */
+        AARCH64_R_STR (TLSDESC_OFF_G0_NC),     /* name */
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0xffff,                /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  HOWTO (R_AARCH64_TLSDESC_LDR,        /* type */
+  HOWTO64 (AARCH64_R (TLSDESC_LDR),    /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -1314,13 +1191,13 @@ static reloc_howto_type elf64_aarch64_tlsdesc_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSDESC_LDR",       /* name */
+        AARCH64_R_STR (TLSDESC_LDR),   /* name */
         FALSE,                 /* partial_inplace */
         0x0,                   /* src_mask */
         0x0,                   /* dst_mask */
         FALSE),                /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0x0,                   /* src_mask */
         0x0,                   /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  HOWTO (R_AARCH64_TLSDESC_ADD,        /* type */
+  HOWTO64 (AARCH64_R (TLSDESC_ADD),    /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -1328,13 +1205,13 @@ static reloc_howto_type elf64_aarch64_tlsdesc_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSDESC_ADD",       /* name */
+        AARCH64_R_STR (TLSDESC_ADD),   /* name */
         FALSE,                 /* partial_inplace */
         0x0,                   /* src_mask */
         0x0,                   /* dst_mask */
         FALSE),                /* pcrel_offset */
 
         FALSE,                 /* partial_inplace */
         0x0,                   /* src_mask */
         0x0,                   /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  HOWTO (R_AARCH64_TLSDESC_CALL,       /* type */
+  HOWTO (AARCH64_R (TLSDESC_CALL),     /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -1342,16 +1219,254 @@ static reloc_howto_type elf64_aarch64_tlsdesc_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        "R_AARCH64_TLSDESC_CALL",      /* name */
+        AARCH64_R_STR (TLSDESC_CALL),  /* name */
         FALSE,                 /* partial_inplace */
         0x0,                   /* src_mask */
         0x0,                   /* dst_mask */
         FALSE),                /* pcrel_offset */
         FALSE,                 /* partial_inplace */
         0x0,                   /* src_mask */
         0x0,                   /* dst_mask */
         FALSE),                /* pcrel_offset */
+
+  HOWTO (AARCH64_R (COPY),     /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        64,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_bitfield,    /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* special_function */
+        AARCH64_R_STR (COPY),  /* name */
+        TRUE,                  /* partial_inplace */
+        0xffffffff,            /* src_mask */
+        0xffffffff,            /* dst_mask */
+        FALSE),                /* pcrel_offset */
+
+  HOWTO (AARCH64_R (GLOB_DAT), /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        64,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_bitfield,    /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* special_function */
+        AARCH64_R_STR (GLOB_DAT),      /* name */
+        TRUE,                  /* partial_inplace */
+        0xffffffff,            /* src_mask */
+        0xffffffff,            /* dst_mask */
+        FALSE),                /* pcrel_offset */
+
+  HOWTO (AARCH64_R (JUMP_SLOT),        /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        64,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_bitfield,    /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* special_function */
+        AARCH64_R_STR (JUMP_SLOT),     /* name */
+        TRUE,                  /* partial_inplace */
+        0xffffffff,            /* src_mask */
+        0xffffffff,            /* dst_mask */
+        FALSE),                /* pcrel_offset */
+
+  HOWTO (AARCH64_R (RELATIVE), /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        64,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_bitfield,    /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* special_function */
+        AARCH64_R_STR (RELATIVE),      /* name */
+        TRUE,                  /* partial_inplace */
+        ALL_ONES,              /* src_mask */
+        ALL_ONES,              /* dst_mask */
+        FALSE),                /* pcrel_offset */
+
+  HOWTO (AARCH64_R (TLS_DTPMOD),       /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        64,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_dont,        /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* special_function */
+        AARCH64_R_STR (TLS_DTPMOD),    /* name */
+        FALSE,                 /* partial_inplace */
+        0,                     /* src_mask */
+        ALL_ONES,              /* dst_mask */
+        FALSE),                /* pc_reloffset */
+
+  HOWTO (AARCH64_R (TLS_DTPREL),       /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        64,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_dont,        /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* special_function */
+        AARCH64_R_STR (TLS_DTPREL),    /* name */
+        FALSE,                 /* partial_inplace */
+        0,                     /* src_mask */
+        ALL_ONES,              /* dst_mask */
+        FALSE),                /* pcrel_offset */
+
+  HOWTO (AARCH64_R (TLS_TPREL),        /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        64,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_dont,        /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* special_function */
+        AARCH64_R_STR (TLS_TPREL),     /* name */
+        FALSE,                 /* partial_inplace */
+        0,                     /* src_mask */
+        ALL_ONES,              /* dst_mask */
+        FALSE),                /* pcrel_offset */
+
+  HOWTO (AARCH64_R (TLSDESC),  /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        64,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_dont,        /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* special_function */
+        AARCH64_R_STR (TLSDESC),       /* name */
+        FALSE,                 /* partial_inplace */
+        0,                     /* src_mask */
+        ALL_ONES,              /* dst_mask */
+        FALSE),                /* pcrel_offset */
+
+  HOWTO (AARCH64_R (IRELATIVE),        /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        64,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_bitfield,    /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* special_function */
+        AARCH64_R_STR (IRELATIVE),     /* name */
+        FALSE,                 /* partial_inplace */
+        0,                     /* src_mask */
+        ALL_ONES,              /* dst_mask */
+        FALSE),                /* pcrel_offset */
+
+  EMPTY_HOWTO (0),
 };
 
 };
 
+static reloc_howto_type elfNN_aarch64_howto_none =
+  HOWTO (R_AARCH64_NONE,       /* type */
+        0,                     /* rightshift */
+        0,                     /* size (0 = byte, 1 = short, 2 = long) */
+        0,                     /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_dont,/* complain_on_overflow */
+        bfd_elf_generic_reloc, /* special_function */
+        "R_AARCH64_NONE",      /* name */
+        FALSE,                 /* partial_inplace */
+        0,                     /* src_mask */
+        0,                     /* dst_mask */
+        FALSE);                /* pcrel_offset */
+
+/* Given HOWTO, return the bfd internal relocation enumerator.  */
+
+static bfd_reloc_code_real_type
+elfNN_aarch64_bfd_reloc_from_howto (reloc_howto_type *howto)
+{
+  const int size
+    = (int) ARRAY_SIZE (elfNN_aarch64_howto_table);
+  const ptrdiff_t offset
+    = howto - elfNN_aarch64_howto_table;
+
+  if (offset > 0 && offset < size - 1)
+    return BFD_RELOC_AARCH64_RELOC_START + offset;
+
+  if (howto == &elfNN_aarch64_howto_none)
+    return BFD_RELOC_AARCH64_NONE;
+
+  return BFD_RELOC_AARCH64_RELOC_START;
+}
+
+/* Given R_TYPE, return the bfd internal relocation enumerator.  */
+
+static bfd_reloc_code_real_type
+elfNN_aarch64_bfd_reloc_from_type (unsigned int r_type)
+{
+  static bfd_boolean initialized_p = FALSE;
+  /* Indexed by R_TYPE, values are offsets in the howto_table.  */
+  static unsigned int offsets[R_AARCH64_end];
+
+  if (initialized_p == FALSE)
+    {
+      unsigned int i;
+
+      for (i = 1; i < ARRAY_SIZE (elfNN_aarch64_howto_table) - 1; ++i)
+       if (elfNN_aarch64_howto_table[i].type != 0)
+         offsets[elfNN_aarch64_howto_table[i].type] = i;
+
+      initialized_p = TRUE;
+    }
+
+  if (r_type == R_AARCH64_NONE || r_type == R_AARCH64_NULL)
+    return BFD_RELOC_AARCH64_NONE;
+
+  return BFD_RELOC_AARCH64_RELOC_START + offsets[r_type];
+}
+
+struct elf_aarch64_reloc_map
+{
+  bfd_reloc_code_real_type from;
+  bfd_reloc_code_real_type to;
+};
+
+/* Map bfd generic reloc to AArch64-specific reloc.  */
+static const struct elf_aarch64_reloc_map elf_aarch64_reloc_map[] =
+{
+  {BFD_RELOC_NONE, BFD_RELOC_AARCH64_NONE},
+
+  /* Basic data relocations.  */
+  {BFD_RELOC_CTOR, BFD_RELOC_AARCH64_NN},
+  {BFD_RELOC_64, BFD_RELOC_AARCH64_64},
+  {BFD_RELOC_32, BFD_RELOC_AARCH64_32},
+  {BFD_RELOC_16, BFD_RELOC_AARCH64_16},
+  {BFD_RELOC_64_PCREL, BFD_RELOC_AARCH64_64_PCREL},
+  {BFD_RELOC_32_PCREL, BFD_RELOC_AARCH64_32_PCREL},
+  {BFD_RELOC_16_PCREL, BFD_RELOC_AARCH64_16_PCREL},
+};
+
+/* Given the bfd internal relocation enumerator in CODE, return the
+   corresponding howto entry.  */
+
+static reloc_howto_type *
+elfNN_aarch64_howto_from_bfd_reloc (bfd_reloc_code_real_type code)
+{
+  unsigned int i;
+
+  /* Convert bfd generic reloc to AArch64-specific reloc.  */
+  if (code < BFD_RELOC_AARCH64_RELOC_START
+      || code > BFD_RELOC_AARCH64_RELOC_END)
+    for (i = 0; i < ARRAY_SIZE (elf_aarch64_reloc_map); i++)
+      if (elf_aarch64_reloc_map[i].from == code)
+       {
+         code = elf_aarch64_reloc_map[i].to;
+         break;
+       }
+
+  if (code > BFD_RELOC_AARCH64_RELOC_START
+      && code < BFD_RELOC_AARCH64_RELOC_END)
+    if (elfNN_aarch64_howto_table[code - BFD_RELOC_AARCH64_RELOC_START].type)
+      return &elfNN_aarch64_howto_table[code - BFD_RELOC_AARCH64_RELOC_START];
+
+  return NULL;
+}
+
 static reloc_howto_type *
 elfNN_aarch64_howto_from_type (unsigned int r_type)
 {
 static reloc_howto_type *
 elfNN_aarch64_howto_from_type (unsigned int r_type)
 {
+  bfd_reloc_code_real_type val;
+  reloc_howto_type *howto;
+
 #if ARCH_SIZE == 32
   if (r_type > 256)
     {
 #if ARCH_SIZE == 32
   if (r_type > 256)
     {
@@ -1360,24 +1475,15 @@ elfNN_aarch64_howto_from_type (unsigned int r_type)
     }
 #endif
 
     }
 #endif
 
-  if (r_type >= R_AARCH64_static_min && r_type < R_AARCH64_static_max)
-    return &elf64_aarch64_howto_table[r_type - R_AARCH64_static_min];
-
-  if (r_type >= R_AARCH64_tls_min && r_type < R_AARCH64_tls_max)
-    return &elf64_aarch64_tls_howto_table[r_type - R_AARCH64_tls_min];
-
-  if (r_type >= R_AARCH64_tlsdesc_min && r_type < R_AARCH64_tlsdesc_max)
-    return &elf64_aarch64_tlsdesc_howto_table[r_type - R_AARCH64_tlsdesc_min];
+  if (r_type == R_AARCH64_NONE)
+    return &elfNN_aarch64_howto_none;
 
 
-  if (r_type >= R_AARCH64_dyn_min && r_type < R_AARCH64_dyn_max)
-    return &elf64_aarch64_howto_dynrelocs[r_type - R_AARCH64_dyn_min];
+  val = elfNN_aarch64_bfd_reloc_from_type (r_type);
+  howto = elfNN_aarch64_howto_from_bfd_reloc (val);
 
 
-  switch (r_type)
-    {
-    case R_AARCH64_NONE:
-      return &elf64_aarch64_howto_none;
+  if (howto != NULL)
+    return howto;
 
 
-    }
   bfd_set_error (bfd_error_bad_value);
   return NULL;
 }
   bfd_set_error (bfd_error_bad_value);
   return NULL;
 }
@@ -1392,119 +1498,14 @@ elfNN_aarch64_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc,
   bfd_reloc->howto = elfNN_aarch64_howto_from_type (r_type);
 }
 
   bfd_reloc->howto = elfNN_aarch64_howto_from_type (r_type);
 }
 
-struct elf64_aarch64_reloc_map
-{
-  bfd_reloc_code_real_type bfd_reloc_val;
-  unsigned int elf_reloc_val;
-};
-
-/* All entries in this list must also be present in
-   elf64_aarch64_howto_table.  */
-static const struct elf64_aarch64_reloc_map elf64_aarch64_reloc_map[] =
-{
-  {BFD_RELOC_NONE, R_AARCH64_NONE},
-
-  /* Basic data relocations.  */
-  {BFD_RELOC_CTOR, R_AARCH64_ABS64},
-  {BFD_RELOC_64, R_AARCH64_ABS64},
-  {BFD_RELOC_32, R_AARCH64_ABS32},
-  {BFD_RELOC_16, R_AARCH64_ABS16},
-  {BFD_RELOC_64_PCREL, R_AARCH64_PREL64},
-  {BFD_RELOC_32_PCREL, R_AARCH64_PREL32},
-  {BFD_RELOC_16_PCREL, R_AARCH64_PREL16},
-
-  /* Group relocations to low order bits of a 16, 32, 48 or 64 bit
-     value inline.  */
-  {BFD_RELOC_AARCH64_MOVW_G0_NC, R_AARCH64_MOVW_UABS_G0_NC},
-  {BFD_RELOC_AARCH64_MOVW_G1_NC, R_AARCH64_MOVW_UABS_G1_NC},
-  {BFD_RELOC_AARCH64_MOVW_G2_NC, R_AARCH64_MOVW_UABS_G2_NC},
-
-  /* Group relocations to create high bits of a 16, 32, 48 or 64 bit
-     signed value inline.  */
-  {BFD_RELOC_AARCH64_MOVW_G0_S, R_AARCH64_MOVW_SABS_G0},
-  {BFD_RELOC_AARCH64_MOVW_G1_S, R_AARCH64_MOVW_SABS_G1},
-  {BFD_RELOC_AARCH64_MOVW_G2_S, R_AARCH64_MOVW_SABS_G2},
-
-  /* Group relocations to create high bits of a 16, 32, 48 or 64 bit
-     unsigned value inline.  */
-  {BFD_RELOC_AARCH64_MOVW_G0, R_AARCH64_MOVW_UABS_G0},
-  {BFD_RELOC_AARCH64_MOVW_G1, R_AARCH64_MOVW_UABS_G1},
-  {BFD_RELOC_AARCH64_MOVW_G2, R_AARCH64_MOVW_UABS_G2},
-  {BFD_RELOC_AARCH64_MOVW_G3, R_AARCH64_MOVW_UABS_G3},
-
-  /* Relocations to generate 19, 21 and 33 bit PC-relative load/store.  */
-  {BFD_RELOC_AARCH64_LD_LO19_PCREL, R_AARCH64_LD_PREL_LO19},
-  {BFD_RELOC_AARCH64_ADR_LO21_PCREL, R_AARCH64_ADR_PREL_LO21},
-  {BFD_RELOC_AARCH64_ADR_HI21_PCREL, R_AARCH64_ADR_PREL_PG_HI21},
-  {BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL, R_AARCH64_ADR_PREL_PG_HI21_NC},
-  {BFD_RELOC_AARCH64_ADD_LO12, R_AARCH64_ADD_ABS_LO12_NC},
-  {BFD_RELOC_AARCH64_LDST8_LO12, R_AARCH64_LDST8_ABS_LO12_NC},
-  {BFD_RELOC_AARCH64_LDST16_LO12, R_AARCH64_LDST16_ABS_LO12_NC},
-  {BFD_RELOC_AARCH64_LDST32_LO12, R_AARCH64_LDST32_ABS_LO12_NC},
-  {BFD_RELOC_AARCH64_LDST64_LO12, R_AARCH64_LDST64_ABS_LO12_NC},
-  {BFD_RELOC_AARCH64_LDST128_LO12, R_AARCH64_LDST128_ABS_LO12_NC},
-
-  /* Relocations for control-flow instructions.  */
-  {BFD_RELOC_AARCH64_TSTBR14, R_AARCH64_TSTBR14},
-  {BFD_RELOC_AARCH64_BRANCH19, R_AARCH64_CONDBR19},
-  {BFD_RELOC_AARCH64_JUMP26, R_AARCH64_JUMP26},
-  {BFD_RELOC_AARCH64_CALL26, R_AARCH64_CALL26},
-
-  /* Relocations for PIC.  */
-  {BFD_RELOC_AARCH64_GOT_LD_PREL19, R_AARCH64_GOT_LD_PREL19},
-  {BFD_RELOC_AARCH64_ADR_GOT_PAGE, R_AARCH64_ADR_GOT_PAGE},
-  {BFD_RELOC_AARCH64_LD64_GOT_LO12_NC, R_AARCH64_LD64_GOT_LO12_NC},
-
-  /* Relocations for TLS.  */
-  {BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21, R_AARCH64_TLSGD_ADR_PAGE21},
-  {BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC, R_AARCH64_TLSGD_ADD_LO12_NC},
-  {BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1,
-   R_AARCH64_TLSIE_MOVW_GOTTPREL_G1},
-  {BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC,
-   R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC},
-  {BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21,
-   R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21},
-  {BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC,
-   R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC},
-  {BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19,
-   R_AARCH64_TLSIE_LD_GOTTPREL_PREL19},
-  {BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2, R_AARCH64_TLSLE_MOVW_TPREL_G2},
-  {BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1, R_AARCH64_TLSLE_MOVW_TPREL_G1},
-  {BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC,
-   R_AARCH64_TLSLE_MOVW_TPREL_G1_NC},
-  {BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0, R_AARCH64_TLSLE_MOVW_TPREL_G0},
-  {BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC,
-   R_AARCH64_TLSLE_MOVW_TPREL_G0_NC},
-  {BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12, R_AARCH64_TLSLE_ADD_TPREL_LO12},
-  {BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12, R_AARCH64_TLSLE_ADD_TPREL_HI12},
-  {BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC,
-   R_AARCH64_TLSLE_ADD_TPREL_LO12_NC},
-  {BFD_RELOC_AARCH64_TLSDESC_LD_PREL19, R_AARCH64_TLSDESC_LD_PREL19},
-  {BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21, R_AARCH64_TLSDESC_ADR_PREL21},
-  {BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21, R_AARCH64_TLSDESC_ADR_PAGE21},
-  {BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC, R_AARCH64_TLSDESC_ADD_LO12_NC},
-  {BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC, R_AARCH64_TLSDESC_LD64_LO12_NC},
-  {BFD_RELOC_AARCH64_TLSDESC_OFF_G1, R_AARCH64_TLSDESC_OFF_G1},
-  {BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC, R_AARCH64_TLSDESC_OFF_G0_NC},
-  {BFD_RELOC_AARCH64_TLSDESC_LDR, R_AARCH64_TLSDESC_LDR},
-  {BFD_RELOC_AARCH64_TLSDESC_ADD, R_AARCH64_TLSDESC_ADD},
-  {BFD_RELOC_AARCH64_TLSDESC_CALL, R_AARCH64_TLSDESC_CALL},
-  {BFD_RELOC_AARCH64_TLS_DTPMOD64, R_AARCH64_TLS_DTPMOD64},
-  {BFD_RELOC_AARCH64_TLS_DTPREL64, R_AARCH64_TLS_DTPREL64},
-  {BFD_RELOC_AARCH64_TLS_TPREL64, R_AARCH64_TLS_TPREL64},
-  {BFD_RELOC_AARCH64_TLSDESC, R_AARCH64_TLSDESC},
-};
-
 static reloc_howto_type *
 elfNN_aarch64_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
                                 bfd_reloc_code_real_type code)
 {
 static reloc_howto_type *
 elfNN_aarch64_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
                                 bfd_reloc_code_real_type code)
 {
-  unsigned int i;
+  reloc_howto_type *howto = elfNN_aarch64_howto_from_bfd_reloc (code);
 
 
-  for (i = 0; i < ARRAY_SIZE (elf64_aarch64_reloc_map); i++)
-    if (elf64_aarch64_reloc_map[i].bfd_reloc_val == code)
-      return elf64_aarch64_howto_from_type
-       (elf64_aarch64_reloc_map[i].elf_reloc_val);
+  if (howto != NULL)
+    return howto;
 
   bfd_set_error (bfd_error_bad_value);
   return NULL;
 
   bfd_set_error (bfd_error_bad_value);
   return NULL;
@@ -1516,10 +1517,10 @@ elfNN_aarch64_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 {
   unsigned int i;
 
 {
   unsigned int i;
 
-  for (i = 0; i < ARRAY_SIZE (elf64_aarch64_howto_table); i++)
-    if (elf64_aarch64_howto_table[i].name != NULL
-       && strcasecmp (elf64_aarch64_howto_table[i].name, r_name) == 0)
-      return &elf64_aarch64_howto_table[i];
+  for (i = 1; i < ARRAY_SIZE (elfNN_aarch64_howto_table) - 1; ++i)
+    if (elfNN_aarch64_howto_table[i].name != NULL
+       && strcasecmp (elfNN_aarch64_howto_table[i].name, r_name) == 0)
+      return &elfNN_aarch64_howto_table[i];
 
   return NULL;
 }
 
   return NULL;
 }
@@ -2086,99 +2087,105 @@ static bfd_vma
 aarch64_resolve_relocation (unsigned int r_type, bfd_vma place, bfd_vma value,
                            bfd_vma addend, bfd_boolean weak_undef_p)
 {
 aarch64_resolve_relocation (unsigned int r_type, bfd_vma place, bfd_vma value,
                            bfd_vma addend, bfd_boolean weak_undef_p)
 {
-  switch (r_type)
+  switch (elfNN_aarch64_bfd_reloc_from_type (r_type))
     {
     {
-    case R_AARCH64_TLSDESC_CALL:
-    case R_AARCH64_NONE:
-    case R_AARCH64_NULL:
+    case BFD_RELOC_AARCH64_TLSDESC_CALL:
+    case BFD_RELOC_AARCH64_NONE:
       break;
 
       break;
 
-    case R_AARCH64_ADR_PREL_LO21:
-    case R_AARCH64_CONDBR19:
-    case R_AARCH64_LD_PREL_LO19:
-    case R_AARCH64_PREL16:
-    case R_AARCH64_PREL32:
-    case R_AARCH64_PREL64:
-    case R_AARCH64_TSTBR14:
+    case BFD_RELOC_AARCH64_ADR_LO21_PCREL:
+    case BFD_RELOC_AARCH64_BRANCH19:
+    case BFD_RELOC_AARCH64_LD_LO19_PCREL:
+    case BFD_RELOC_AARCH64_16_PCREL:
+    case BFD_RELOC_AARCH64_32_PCREL:
+    case BFD_RELOC_AARCH64_64_PCREL:
+    case BFD_RELOC_AARCH64_TSTBR14:
       if (weak_undef_p)
        value = place;
       value = value + addend - place;
       break;
 
       if (weak_undef_p)
        value = place;
       value = value + addend - place;
       break;
 
-    case R_AARCH64_CALL26:
-    case R_AARCH64_JUMP26:
+    case BFD_RELOC_AARCH64_CALL26:
+    case BFD_RELOC_AARCH64_JUMP26:
       value = value + addend - place;
       break;
 
       value = value + addend - place;
       break;
 
-    case R_AARCH64_ABS16:
-    case R_AARCH64_ABS32:
-    case R_AARCH64_MOVW_SABS_G0:
-    case R_AARCH64_MOVW_SABS_G1:
-    case R_AARCH64_MOVW_SABS_G2:
-    case R_AARCH64_MOVW_UABS_G0:
-    case R_AARCH64_MOVW_UABS_G0_NC:
-    case R_AARCH64_MOVW_UABS_G1:
-    case R_AARCH64_MOVW_UABS_G1_NC:
-    case R_AARCH64_MOVW_UABS_G2:
-    case R_AARCH64_MOVW_UABS_G2_NC:
-    case R_AARCH64_MOVW_UABS_G3:
+    case BFD_RELOC_AARCH64_16:
+    case BFD_RELOC_AARCH64_32:
+    case BFD_RELOC_AARCH64_MOVW_G0_S:
+    case BFD_RELOC_AARCH64_MOVW_G1_S:
+    case BFD_RELOC_AARCH64_MOVW_G2_S:
+    case BFD_RELOC_AARCH64_MOVW_G0:
+    case BFD_RELOC_AARCH64_MOVW_G0_NC:
+    case BFD_RELOC_AARCH64_MOVW_G1:
+    case BFD_RELOC_AARCH64_MOVW_G1_NC:
+    case BFD_RELOC_AARCH64_MOVW_G2:
+    case BFD_RELOC_AARCH64_MOVW_G2_NC:
+    case BFD_RELOC_AARCH64_MOVW_G3:
       value = value + addend;
       break;
 
       value = value + addend;
       break;
 
-    case R_AARCH64_ADR_PREL_PG_HI21:
-    case R_AARCH64_ADR_PREL_PG_HI21_NC:
+    case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
+    case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
       if (weak_undef_p)
        value = PG (place);
       value = PG (value + addend) - PG (place);
       break;
 
       if (weak_undef_p)
        value = PG (place);
       value = PG (value + addend) - PG (place);
       break;
 
-    case R_AARCH64_GOT_LD_PREL19:
+    case BFD_RELOC_AARCH64_GOT_LD_PREL19:
       value = value + addend - place;
       break;
 
       value = value + addend - place;
       break;
 
-    case R_AARCH64_ADR_GOT_PAGE:
-    case R_AARCH64_TLSDESC_ADR_PAGE21:
-    case R_AARCH64_TLSGD_ADR_PAGE21:
-    case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+    case BFD_RELOC_AARCH64_ADR_GOT_PAGE:
+    case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
       value = PG (value + addend) - PG (place);
       break;
 
       value = PG (value + addend) - PG (place);
       break;
 
-    case R_AARCH64_ADD_ABS_LO12_NC:
-    case R_AARCH64_LD64_GOT_LO12_NC:
-    case R_AARCH64_LDST8_ABS_LO12_NC:
-    case R_AARCH64_LDST16_ABS_LO12_NC:
-    case R_AARCH64_LDST32_ABS_LO12_NC:
-    case R_AARCH64_LDST64_ABS_LO12_NC:
-    case R_AARCH64_LDST128_ABS_LO12_NC:
-    case R_AARCH64_TLSDESC_ADD_LO12_NC:
-    case R_AARCH64_TLSDESC_ADD:
-    case R_AARCH64_TLSDESC_LD64_LO12_NC:
-    case R_AARCH64_TLSDESC_LDR:
-    case R_AARCH64_TLSGD_ADD_LO12_NC:
-    case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
-    case R_AARCH64_TLSLE_ADD_TPREL_LO12:
-    case R_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_ADD_LO12:
+    case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
+    case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC:
+    case BFD_RELOC_AARCH64_LDST8_LO12:
+    case BFD_RELOC_AARCH64_LDST16_LO12:
+    case BFD_RELOC_AARCH64_LDST32_LO12:
+    case BFD_RELOC_AARCH64_LDST64_LO12:
+    case BFD_RELOC_AARCH64_LDST128_LO12:
+    case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_ADD:
+    case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_LDR:
+    case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
       value = PG_OFFSET (value + addend);
       break;
 
       value = PG_OFFSET (value + addend);
       break;
 
-    case R_AARCH64_TLSLE_MOVW_TPREL_G1:
-    case R_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
       value = (value + addend) & (bfd_vma) 0xffff0000;
       break;
       value = (value + addend) & (bfd_vma) 0xffff0000;
       break;
-    case R_AARCH64_TLSLE_ADD_TPREL_HI12:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12:
       value = (value + addend) & (bfd_vma) 0xfff000;
       break;
 
       value = (value + addend) & (bfd_vma) 0xfff000;
       break;
 
-    case R_AARCH64_TLSLE_MOVW_TPREL_G0:
-    case R_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
       value = (value + addend) & (bfd_vma) 0xffff;
       break;
 
       value = (value + addend) & (bfd_vma) 0xffff;
       break;
 
-    case R_AARCH64_TLSLE_MOVW_TPREL_G2:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2:
       value = (value + addend) & ~(bfd_vma) 0xffffffff;
       value -= place & ~(bfd_vma) 0xffffffff;
       break;
       value = (value + addend) & ~(bfd_vma) 0xffffffff;
       value -= place & ~(bfd_vma) 0xffffffff;
       break;
+
+    default:
+      break;
     }
     }
+
   return value;
 }
 
   return value;
 }
 
@@ -2244,7 +2251,7 @@ aarch64_type_of_stub (struct bfd_link_info *info,
   /* We don't want to redirect any old unconditional jump in this way,
      only one which is being used for a sibcall, where it is
      acceptable for the IP0 and IP1 registers to be clobbered.  */
   /* We don't want to redirect any old unconditional jump in this way,
      only one which is being used for a sibcall, where it is
      acceptable for the IP0 and IP1 registers to be clobbered.  */
-  if ((r_type == R_AARCH64_CALL26 || r_type == R_AARCH64_JUMP26)
+  if ((r_type == AARCH64_R (CALL26) || r_type == AARCH64_R (JUMP26))
       && (branch_offset > AARCH64_MAX_FWD_BRANCH_OFFSET
          || branch_offset < AARCH64_MAX_BWD_BRANCH_OFFSET))
     {
       && (branch_offset > AARCH64_MAX_FWD_BRANCH_OFFSET
          || branch_offset < AARCH64_MAX_BWD_BRANCH_OFFSET))
     {
@@ -2461,14 +2468,14 @@ aarch64_build_one_stub (struct bfd_hash_entry *gen_entry,
   switch (stub_entry->stub_type)
     {
     case aarch64_stub_adrp_branch:
   switch (stub_entry->stub_type)
     {
     case aarch64_stub_adrp_branch:
-      if (aarch64_relocate (R_AARCH64_ADR_PREL_PG_HI21, stub_bfd, stub_sec,
+      if (aarch64_relocate (AARCH64_R (ADR_PREL_PG_HI21), stub_bfd, stub_sec,
                            stub_entry->stub_offset, sym_value))
        /* The stub would not have been relaxed if the offset was out
           of range.  */
        BFD_FAIL ();
 
       _bfd_final_link_relocate
                            stub_entry->stub_offset, sym_value))
        /* The stub would not have been relaxed if the offset was out
           of range.  */
        BFD_FAIL ();
 
       _bfd_final_link_relocate
-       (elfNN_aarch64_howto_from_type (R_AARCH64_ADD_ABS_LO12_NC),
+       (elfNN_aarch64_howto_from_type (AARCH64_R (ADD_ABS_LO12_NC)),
         stub_bfd,
         stub_sec,
         stub_sec->contents,
         stub_bfd,
         stub_sec,
         stub_sec->contents,
@@ -2481,7 +2488,7 @@ aarch64_build_one_stub (struct bfd_hash_entry *gen_entry,
       /* We want the value relative to the address 12 bytes back from the
          value itself.  */
       _bfd_final_link_relocate (elfNN_aarch64_howto_from_type
       /* We want the value relative to the address 12 bytes back from the
          value itself.  */
       _bfd_final_link_relocate (elfNN_aarch64_howto_from_type
-                               (R_AARCH64_PREL64), stub_bfd, stub_sec,
+                               (AARCH64_R (PRELNN)), stub_bfd, stub_sec,
                                stub_sec->contents,
                                stub_entry->stub_offset + 16,
                                sym_value + 12, 0);
                                stub_sec->contents,
                                stub_entry->stub_offset + 16,
                                sym_value + 12, 0);
@@ -2822,8 +2829,8 @@ elfNN_aarch64_size_stubs (bfd *output_bfd,
 
                  /* Only look for stubs on unconditional branch and
                     branch and link instructions.  */
 
                  /* Only look for stubs on unconditional branch and
                     branch and link instructions.  */
-                 if (r_type != (unsigned int) R_AARCH64_CALL26
-                     && r_type != (unsigned int) R_AARCH64_JUMP26)
+                 if (r_type != (unsigned int) AARCH64_R (CALL26)
+                     && r_type != (unsigned int) AARCH64_R (JUMP26))
                    continue;
 
                  /* Now determine the call target, its name, value,
                    continue;
 
                  /* Now determine the call target, its name, value,
@@ -3339,66 +3346,69 @@ bfd_elf_aarch64_put_addend (bfd *abfd,
 
   addend >>= howto->rightshift;
 
 
   addend >>= howto->rightshift;
 
-  switch (howto->type)
+  switch (elfNN_aarch64_bfd_reloc_from_howto (howto))
     {
     {
-    case R_AARCH64_JUMP26:
-    case R_AARCH64_CALL26:
+    case BFD_RELOC_AARCH64_JUMP26:
+    case BFD_RELOC_AARCH64_CALL26:
       contents = reencode_branch_ofs_26 (contents, addend);
       break;
 
       contents = reencode_branch_ofs_26 (contents, addend);
       break;
 
-    case R_AARCH64_CONDBR19:
+    case BFD_RELOC_AARCH64_BRANCH19:
       contents = reencode_cond_branch_ofs_19 (contents, addend);
       break;
 
       contents = reencode_cond_branch_ofs_19 (contents, addend);
       break;
 
-    case R_AARCH64_TSTBR14:
+    case BFD_RELOC_AARCH64_TSTBR14:
       contents = reencode_tst_branch_ofs_14 (contents, addend);
       break;
 
       contents = reencode_tst_branch_ofs_14 (contents, addend);
       break;
 
-    case R_AARCH64_LD_PREL_LO19:
-    case R_AARCH64_GOT_LD_PREL19:
+    case BFD_RELOC_AARCH64_LD_LO19_PCREL:
+    case BFD_RELOC_AARCH64_GOT_LD_PREL19:
       if (old_addend & ((1 << howto->rightshift) - 1))
        return bfd_reloc_overflow;
       contents = reencode_ld_lit_ofs_19 (contents, addend);
       break;
 
       if (old_addend & ((1 << howto->rightshift) - 1))
        return bfd_reloc_overflow;
       contents = reencode_ld_lit_ofs_19 (contents, addend);
       break;
 
-    case R_AARCH64_TLSDESC_CALL:
+    case BFD_RELOC_AARCH64_TLSDESC_CALL:
       break;
 
       break;
 
-    case R_AARCH64_TLSGD_ADR_PAGE21:
-    case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
-    case R_AARCH64_TLSDESC_ADR_PAGE21:
-    case R_AARCH64_ADR_GOT_PAGE:
-    case R_AARCH64_ADR_PREL_LO21:
-    case R_AARCH64_ADR_PREL_PG_HI21:
-    case R_AARCH64_ADR_PREL_PG_HI21_NC:
+    case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+    case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_ADR_GOT_PAGE:
+    case BFD_RELOC_AARCH64_ADR_LO21_PCREL:
+    case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
+    case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
       contents = reencode_adr_imm (contents, addend);
       break;
 
       contents = reencode_adr_imm (contents, addend);
       break;
 
-    case R_AARCH64_TLSGD_ADD_LO12_NC:
-    case R_AARCH64_TLSLE_ADD_TPREL_LO12:
-    case R_AARCH64_TLSLE_ADD_TPREL_HI12:
-    case R_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
-    case R_AARCH64_TLSDESC_ADD_LO12_NC:
-    case R_AARCH64_ADD_ABS_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_ADD_LO12:
       /* Corresponds to: add rd, rn, #uimm12 to provide the low order
          12 bits of the page offset following
       /* Corresponds to: add rd, rn, #uimm12 to provide the low order
          12 bits of the page offset following
-         R_AARCH64_ADR_PREL_PG_HI21 which computes the
+         BFD_RELOC_AARCH64_ADR_HI21_PCREL which computes the
          (pc-relative) page base.  */
       contents = reencode_add_imm (contents, addend);
       break;
 
          (pc-relative) page base.  */
       contents = reencode_add_imm (contents, addend);
       break;
 
-    case R_AARCH64_LDST8_ABS_LO12_NC:
-    case R_AARCH64_LDST16_ABS_LO12_NC:
-    case R_AARCH64_LDST32_ABS_LO12_NC:
-    case R_AARCH64_LDST64_ABS_LO12_NC:
-    case R_AARCH64_LDST128_ABS_LO12_NC:
-    case R_AARCH64_TLSDESC_LD64_LO12_NC:
-    case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
-    case R_AARCH64_LD64_GOT_LO12_NC:
+    case BFD_RELOC_AARCH64_LDST8_LO12:
+    case BFD_RELOC_AARCH64_LDST16_LO12:
+    case BFD_RELOC_AARCH64_LDST32_LO12:
+    case BFD_RELOC_AARCH64_LDST64_LO12:
+    case BFD_RELOC_AARCH64_LDST128_LO12:
+    case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
+    case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC:
       if (old_addend & ((1 << howto->rightshift) - 1))
        return bfd_reloc_overflow;
       /* Used for ldr*|str* rt, [rn, #uimm12] to provide the low order
       if (old_addend & ((1 << howto->rightshift) - 1))
        return bfd_reloc_overflow;
       /* Used for ldr*|str* rt, [rn, #uimm12] to provide the low order
-         12 bits of the page offset following R_AARCH64_ADR_PREL_PG_HI21
+         12 bits of the page offset following BFD_RELOC_AARCH64_ADR_HI21_PCREL
          which computes the (pc-relative) page base.  */
       contents = reencode_ldst_pos_imm (contents, addend);
       break;
          which computes the (pc-relative) page base.  */
       contents = reencode_ldst_pos_imm (contents, addend);
       break;
@@ -3408,14 +3418,14 @@ bfd_elf_aarch64_put_addend (bfd *abfd,
          instruction to MOVN or MOVZ depending on sign of calculated
          value.  */
 
          instruction to MOVN or MOVZ depending on sign of calculated
          value.  */
 
-    case R_AARCH64_TLSLE_MOVW_TPREL_G2:
-    case R_AARCH64_TLSLE_MOVW_TPREL_G1:
-    case R_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
-    case R_AARCH64_TLSLE_MOVW_TPREL_G0:
-    case R_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
-    case R_AARCH64_MOVW_SABS_G0:
-    case R_AARCH64_MOVW_SABS_G1:
-    case R_AARCH64_MOVW_SABS_G2:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
+    case BFD_RELOC_AARCH64_MOVW_G0_S:
+    case BFD_RELOC_AARCH64_MOVW_G1_S:
+    case BFD_RELOC_AARCH64_MOVW_G2_S:
       /* NOTE: We can only come here with movz or movn.  */
       if (addend < 0)
        {
       /* NOTE: We can only come here with movz or movn.  */
       if (addend < 0)
        {
@@ -3433,13 +3443,13 @@ bfd_elf_aarch64_put_addend (bfd *abfd,
       /* Group relocations to create a 16, 32, 48 or 64 bit unsigned
          data or abs address inline.  */
 
       /* Group relocations to create a 16, 32, 48 or 64 bit unsigned
          data or abs address inline.  */
 
-    case R_AARCH64_MOVW_UABS_G0:
-    case R_AARCH64_MOVW_UABS_G0_NC:
-    case R_AARCH64_MOVW_UABS_G1:
-    case R_AARCH64_MOVW_UABS_G1_NC:
-    case R_AARCH64_MOVW_UABS_G2:
-    case R_AARCH64_MOVW_UABS_G2_NC:
-    case R_AARCH64_MOVW_UABS_G3:
+    case BFD_RELOC_AARCH64_MOVW_G0:
+    case BFD_RELOC_AARCH64_MOVW_G0_NC:
+    case BFD_RELOC_AARCH64_MOVW_G1:
+    case BFD_RELOC_AARCH64_MOVW_G1_NC:
+    case BFD_RELOC_AARCH64_MOVW_G2:
+    case BFD_RELOC_AARCH64_MOVW_G2_NC:
+    case BFD_RELOC_AARCH64_MOVW_G3:
       contents = reencode_movw_imm (contents, addend);
       break;
 
       contents = reencode_movw_imm (contents, addend);
       break;
 
@@ -3488,6 +3498,7 @@ aarch64_calculate_got_entry_vma (struct elf_link_hash_entry *h,
 
   if (h != NULL)
     {
 
   if (h != NULL)
     {
+      BFD_ASSERT (basegot != NULL);
       off = h->got.offset;
       BFD_ASSERT (off != (bfd_vma) - 1);
       if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
       off = h->got.offset;
       BFD_ASSERT (off != (bfd_vma) - 1);
       if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
@@ -3499,8 +3510,9 @@ aarch64_calculate_got_entry_vma (struct elf_link_hash_entry *h,
          /* This is actually a static link, or it is a -Bsymbolic link
             and the symbol is defined locally.  We must initialize this
             entry in the global offset table.  Since the offset must
          /* This is actually a static link, or it is a -Bsymbolic link
             and the symbol is defined locally.  We must initialize this
             entry in the global offset table.  Since the offset must
-            always be a multiple of 8, we use the least significant bit
-            to record whether we have initialized it already.
+            always be a multiple of 8 (4 in the case of ILP32), we use
+            the least significant bit to record whether we have
+            initialized it already.
             When doing a dynamic link, we create a .rel(a).got relocation
             entry to initialize the value.  This is done in the
             finish_dynamic_symbol routine.  */
             When doing a dynamic link, we create a .rel(a).got relocation
             entry to initialize the value.  This is done in the
             finish_dynamic_symbol routine.  */
@@ -3524,72 +3536,83 @@ aarch64_calculate_got_entry_vma (struct elf_link_hash_entry *h,
 /* Change R_TYPE to a more efficient access model where possible,
    return the new reloc type.  */
 
 /* Change R_TYPE to a more efficient access model where possible,
    return the new reloc type.  */
 
-static unsigned int
-aarch64_tls_transition_without_check (unsigned int r_type,
+static bfd_reloc_code_real_type
+aarch64_tls_transition_without_check (bfd_reloc_code_real_type r_type,
                                      struct elf_link_hash_entry *h)
 {
   bfd_boolean is_local = h == NULL;
                                      struct elf_link_hash_entry *h)
 {
   bfd_boolean is_local = h == NULL;
+
   switch (r_type)
     {
   switch (r_type)
     {
-    case R_AARCH64_TLSGD_ADR_PAGE21:
-    case R_AARCH64_TLSDESC_ADR_PAGE21:
-      return is_local
-       ? R_AARCH64_TLSLE_MOVW_TPREL_G1 : R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21;
-
-    case R_AARCH64_TLSGD_ADD_LO12_NC:
-    case R_AARCH64_TLSDESC_LD64_LO12_NC:
-      return is_local
-       ? R_AARCH64_TLSLE_MOVW_TPREL_G0_NC
-       : R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC;
-
-    case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
-      return is_local ? R_AARCH64_TLSLE_MOVW_TPREL_G1 : r_type;
-
-    case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
-      return is_local ? R_AARCH64_TLSLE_MOVW_TPREL_G0_NC : r_type;
-
-    case R_AARCH64_TLSDESC_ADD_LO12_NC:
-    case R_AARCH64_TLSDESC_CALL:
+    case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
+      return (is_local
+             ? BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1
+             : BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21);
+
+    case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_LDNN_LO12_NC:
+      return (is_local
+             ? BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC
+             : BFD_RELOC_AARCH64_TLSIE_LDNN_GOTTPREL_LO12_NC);
+
+    case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+      return is_local ? BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1 : r_type;
+
+    case BFD_RELOC_AARCH64_TLSIE_LDNN_GOTTPREL_LO12_NC:
+      return is_local ? BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC : r_type;
+
+    case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_CALL:
       /* Instructions with these relocations will become NOPs.  */
       /* Instructions with these relocations will become NOPs.  */
-      return R_AARCH64_NONE;
+      return BFD_RELOC_AARCH64_NONE;
+
+    default:
+      break;
     }
 
   return r_type;
 }
 
 static unsigned int
     }
 
   return r_type;
 }
 
 static unsigned int
-aarch64_reloc_got_type (unsigned int r_type)
+aarch64_reloc_got_type (bfd_reloc_code_real_type r_type)
 {
   switch (r_type)
     {
 {
   switch (r_type)
     {
-    case R_AARCH64_LD64_GOT_LO12_NC:
-    case R_AARCH64_ADR_GOT_PAGE:
-    case R_AARCH64_GOT_LD_PREL19:
+    case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
+    case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC:
+    case BFD_RELOC_AARCH64_ADR_GOT_PAGE:
+    case BFD_RELOC_AARCH64_GOT_LD_PREL19:
       return GOT_NORMAL;
 
       return GOT_NORMAL;
 
-    case R_AARCH64_TLSGD_ADR_PAGE21:
-    case R_AARCH64_TLSGD_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
       return GOT_TLS_GD;
 
       return GOT_TLS_GD;
 
-    case R_AARCH64_TLSDESC_ADD_LO12_NC:
-    case R_AARCH64_TLSDESC_ADR_PAGE21:
-    case R_AARCH64_TLSDESC_CALL:
-    case R_AARCH64_TLSDESC_LD64_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_TLSDESC_CALL:
+    case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC:
       return GOT_TLSDESC_GD;
 
       return GOT_TLSDESC_GD;
 
-    case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
-    case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+    case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC:
       return GOT_TLS_IE;
 
       return GOT_TLS_IE;
 
-    case R_AARCH64_TLSLE_ADD_TPREL_HI12:
-    case R_AARCH64_TLSLE_ADD_TPREL_LO12:
-    case R_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
-    case R_AARCH64_TLSLE_MOVW_TPREL_G0:
-    case R_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
-    case R_AARCH64_TLSLE_MOVW_TPREL_G1:
-    case R_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
-    case R_AARCH64_TLSLE_MOVW_TPREL_G2:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2:
       return GOT_UNKNOWN;
       return GOT_UNKNOWN;
+
+    default:
+      break;
     }
   return GOT_UNKNOWN;
 }
     }
   return GOT_UNKNOWN;
 }
@@ -3597,7 +3620,7 @@ aarch64_reloc_got_type (unsigned int r_type)
 static bfd_boolean
 aarch64_can_relax_tls (bfd *input_bfd,
                       struct bfd_link_info *info,
 static bfd_boolean
 aarch64_can_relax_tls (bfd *input_bfd,
                       struct bfd_link_info *info,
-                      unsigned int r_type,
+                      bfd_reloc_code_real_type r_type,
                       struct elf_link_hash_entry *h,
                       unsigned long r_symndx)
 {
                       struct elf_link_hash_entry *h,
                       unsigned long r_symndx)
 {
@@ -3622,21 +3645,27 @@ aarch64_can_relax_tls (bfd *input_bfd,
   return TRUE;
 }
 
   return TRUE;
 }
 
-static unsigned int
+/* Given the relocation code R_TYPE, return the relaxed bfd reloc
+   enumerator.  */
+
+static bfd_reloc_code_real_type
 aarch64_tls_transition (bfd *input_bfd,
                        struct bfd_link_info *info,
                        unsigned int r_type,
                        struct elf_link_hash_entry *h,
                        unsigned long r_symndx)
 {
 aarch64_tls_transition (bfd *input_bfd,
                        struct bfd_link_info *info,
                        unsigned int r_type,
                        struct elf_link_hash_entry *h,
                        unsigned long r_symndx)
 {
-  if (! aarch64_can_relax_tls (input_bfd, info, r_type, h, r_symndx))
-    return r_type;
+  bfd_reloc_code_real_type bfd_r_type
+    = elfNN_aarch64_bfd_reloc_from_type (r_type);
 
 
-  return aarch64_tls_transition_without_check (r_type, h);
+  if (! aarch64_can_relax_tls (input_bfd, info, bfd_r_type, h, r_symndx))
+    return bfd_r_type;
+
+  return aarch64_tls_transition_without_check (bfd_r_type, h);
 }
 
 /* Return the base VMA address which should be subtracted from real addresses
 }
 
 /* Return the base VMA address which should be subtracted from real addresses
-   when resolving R_AARCH64_TLS_DTPREL64 relocation.  */
+   when resolving R_AARCH64_TLS_DTPREL relocation.  */
 
 static bfd_vma
 dtpoff_base (struct bfd_link_info *info)
 
 static bfd_vma
 dtpoff_base (struct bfd_link_info *info)
@@ -3646,7 +3675,6 @@ dtpoff_base (struct bfd_link_info *info)
   return elf_hash_table (info)->tls_sec->vma;
 }
 
   return elf_hash_table (info)->tls_sec->vma;
 }
 
-
 /* Return the base VMA address which should be subtracted from real addresses
    when resolving R_AARCH64_TLS_GOTTPREL64 relocations.  */
 
 /* Return the base VMA address which should be subtracted from real addresses
    when resolving R_AARCH64_TLS_GOTTPREL64 relocations.  */
 
@@ -3778,6 +3806,9 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
                                   bfd_vma *saved_addend)
 {
   unsigned int r_type = howto->type;
                                   bfd_vma *saved_addend)
 {
   unsigned int r_type = howto->type;
+  bfd_reloc_code_real_type bfd_r_type
+    = elfNN_aarch64_bfd_reloc_from_howto (howto);
+  bfd_reloc_code_real_type new_bfd_r_type;
   unsigned long r_symndx;
   bfd_byte *hit_data = contents + rel->r_offset;
   bfd_vma place;
   unsigned long r_symndx;
   bfd_byte *hit_data = contents + rel->r_offset;
   bfd_vma place;
@@ -3793,10 +3824,14 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
 
   /* It is possible to have linker relaxations on some TLS access
      models.  Update our information here.  */
 
   /* It is possible to have linker relaxations on some TLS access
      models.  Update our information here.  */
-  r_type = aarch64_tls_transition (input_bfd, info, r_type, h, r_symndx);
-
-  if (r_type != howto->type)
-    howto = elfNN_aarch64_howto_from_type (r_type);
+  new_bfd_r_type = aarch64_tls_transition (input_bfd, info, r_type, h, r_symndx);
+  if (new_bfd_r_type != bfd_r_type)
+    {
+      bfd_r_type = new_bfd_r_type;
+      howto = elfNN_aarch64_howto_from_bfd_reloc (bfd_r_type);
+      BFD_ASSERT (howto != NULL);
+      r_type = howto->type;
+    }
 
   place = input_section->output_section->vma
     + input_section->output_offset + rel->r_offset;
 
   place = input_section->output_section->vma
     + input_section->output_offset + rel->r_offset;
@@ -3808,15 +3843,15 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
 
   weak_undef_p = (h ? h->root.type == bfd_link_hash_undefweak
                  : bfd_is_und_section (sym_sec));
 
   weak_undef_p = (h ? h->root.type == bfd_link_hash_undefweak
                  : bfd_is_und_section (sym_sec));
-  switch (r_type)
+
+  switch (bfd_r_type)
     {
     {
-    case R_AARCH64_NONE:
-    case R_AARCH64_NULL:
-    case R_AARCH64_TLSDESC_CALL:
+    case BFD_RELOC_AARCH64_NONE:
+    case BFD_RELOC_AARCH64_TLSDESC_CALL:
       *unresolved_reloc_p = FALSE;
       return bfd_reloc_ok;
 
       *unresolved_reloc_p = FALSE;
       return bfd_reloc_ok;
 
-    case R_AARCH64_ABS64:
+    case BFD_RELOC_AARCH64_NN:
 
       /* When generating a shared object or relocatable executable, these
          relocations are copied into the output file to be resolved at
 
       /* When generating a shared object or relocatable executable, these
          relocations are copied into the output file to be resolved at
@@ -3871,7 +3906,7 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
                 relocate the text and data segments independently,
                 so the symbol does not matter.  */
              symbol = 0;
                 relocate the text and data segments independently,
                 so the symbol does not matter.  */
              symbol = 0;
-             outrel.r_info = ELFNN_R_INFO (symbol, R_AARCH64_RELATIVE);
+             outrel.r_info = ELFNN_R_INFO (symbol, AARCH64_R (RELATIVE));
              outrel.r_addend += value;
            }
 
              outrel.r_addend += value;
            }
 
@@ -3900,8 +3935,8 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
        value += signed_addend;
       break;
 
        value += signed_addend;
       break;
 
-    case R_AARCH64_JUMP26:
-    case R_AARCH64_CALL26:
+    case BFD_RELOC_AARCH64_JUMP26:
+    case BFD_RELOC_AARCH64_CALL26:
       {
        asection *splt = globals->root.splt;
        bfd_boolean via_plt_p =
       {
        asection *splt = globals->root.splt;
        bfd_boolean via_plt_p =
@@ -3954,40 +3989,43 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
                                          signed_addend, weak_undef_p);
       break;
 
                                          signed_addend, weak_undef_p);
       break;
 
-    case R_AARCH64_ABS16:
-    case R_AARCH64_ABS32:
-    case R_AARCH64_ADD_ABS_LO12_NC:
-    case R_AARCH64_ADR_PREL_LO21:
-    case R_AARCH64_ADR_PREL_PG_HI21:
-    case R_AARCH64_ADR_PREL_PG_HI21_NC:
-    case R_AARCH64_CONDBR19:
-    case R_AARCH64_LD_PREL_LO19:
-    case R_AARCH64_LDST8_ABS_LO12_NC:
-    case R_AARCH64_LDST16_ABS_LO12_NC:
-    case R_AARCH64_LDST32_ABS_LO12_NC:
-    case R_AARCH64_LDST64_ABS_LO12_NC:
-    case R_AARCH64_LDST128_ABS_LO12_NC:
-    case R_AARCH64_MOVW_SABS_G0:
-    case R_AARCH64_MOVW_SABS_G1:
-    case R_AARCH64_MOVW_SABS_G2:
-    case R_AARCH64_MOVW_UABS_G0:
-    case R_AARCH64_MOVW_UABS_G0_NC:
-    case R_AARCH64_MOVW_UABS_G1:
-    case R_AARCH64_MOVW_UABS_G1_NC:
-    case R_AARCH64_MOVW_UABS_G2:
-    case R_AARCH64_MOVW_UABS_G2_NC:
-    case R_AARCH64_MOVW_UABS_G3:
-    case R_AARCH64_PREL16:
-    case R_AARCH64_PREL32:
-    case R_AARCH64_PREL64:
-    case R_AARCH64_TSTBR14:
+    case BFD_RELOC_AARCH64_16:
+#if ARCH_SIZE == 64
+    case BFD_RELOC_AARCH64_32:
+#endif
+    case BFD_RELOC_AARCH64_ADD_LO12:
+    case BFD_RELOC_AARCH64_ADR_LO21_PCREL:
+    case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
+    case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
+    case BFD_RELOC_AARCH64_BRANCH19:
+    case BFD_RELOC_AARCH64_LD_LO19_PCREL:
+    case BFD_RELOC_AARCH64_LDST8_LO12:
+    case BFD_RELOC_AARCH64_LDST16_LO12:
+    case BFD_RELOC_AARCH64_LDST32_LO12:
+    case BFD_RELOC_AARCH64_LDST64_LO12:
+    case BFD_RELOC_AARCH64_LDST128_LO12:
+    case BFD_RELOC_AARCH64_MOVW_G0_S:
+    case BFD_RELOC_AARCH64_MOVW_G1_S:
+    case BFD_RELOC_AARCH64_MOVW_G2_S:
+    case BFD_RELOC_AARCH64_MOVW_G0:
+    case BFD_RELOC_AARCH64_MOVW_G0_NC:
+    case BFD_RELOC_AARCH64_MOVW_G1:
+    case BFD_RELOC_AARCH64_MOVW_G1_NC:
+    case BFD_RELOC_AARCH64_MOVW_G2:
+    case BFD_RELOC_AARCH64_MOVW_G2_NC:
+    case BFD_RELOC_AARCH64_MOVW_G3:
+    case BFD_RELOC_AARCH64_16_PCREL:
+    case BFD_RELOC_AARCH64_32_PCREL:
+    case BFD_RELOC_AARCH64_64_PCREL:
+    case BFD_RELOC_AARCH64_TSTBR14:
       value = aarch64_resolve_relocation (r_type, place, value,
                                          signed_addend, weak_undef_p);
       break;
 
       value = aarch64_resolve_relocation (r_type, place, value,
                                          signed_addend, weak_undef_p);
       break;
 
-    case R_AARCH64_LD64_GOT_LO12_NC:
-    case R_AARCH64_ADR_GOT_PAGE:
-    case R_AARCH64_GOT_LD_PREL19:
+    case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
+    case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC:
+    case BFD_RELOC_AARCH64_ADR_GOT_PAGE:
+    case BFD_RELOC_AARCH64_GOT_LD_PREL19:
       if (globals->root.sgot == NULL)
        BFD_ASSERT (h != NULL);
 
       if (globals->root.sgot == NULL)
        BFD_ASSERT (h != NULL);
 
@@ -4001,10 +4039,11 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
        }
       break;
 
        }
       break;
 
-    case R_AARCH64_TLSGD_ADR_PAGE21:
-    case R_AARCH64_TLSGD_ADD_LO12_NC:
-    case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
-    case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+    case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC:
       if (globals->root.sgot == NULL)
        return bfd_reloc_notsupported;
 
       if (globals->root.sgot == NULL)
        return bfd_reloc_notsupported;
 
@@ -4017,24 +4056,25 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
       *unresolved_reloc_p = FALSE;
       break;
 
       *unresolved_reloc_p = FALSE;
       break;
 
-    case R_AARCH64_TLSLE_ADD_TPREL_HI12:
-    case R_AARCH64_TLSLE_ADD_TPREL_LO12:
-    case R_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
-    case R_AARCH64_TLSLE_MOVW_TPREL_G0:
-    case R_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
-    case R_AARCH64_TLSLE_MOVW_TPREL_G1:
-    case R_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
-    case R_AARCH64_TLSLE_MOVW_TPREL_G2:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2:
       value = aarch64_resolve_relocation (r_type, place, value,
                                          signed_addend - tpoff_base (info), weak_undef_p);
       *unresolved_reloc_p = FALSE;
       break;
 
       value = aarch64_resolve_relocation (r_type, place, value,
                                          signed_addend - tpoff_base (info), weak_undef_p);
       *unresolved_reloc_p = FALSE;
       break;
 
-    case R_AARCH64_TLSDESC_ADR_PAGE21:
-    case R_AARCH64_TLSDESC_LD64_LO12_NC:
-    case R_AARCH64_TLSDESC_ADD_LO12_NC:
-    case R_AARCH64_TLSDESC_ADD:
-    case R_AARCH64_TLSDESC_LDR:
+    case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_ADD:
+    case BFD_RELOC_AARCH64_TLSDESC_LDR:
       if (globals->root.sgot == NULL)
        return bfd_reloc_notsupported;
 
       if (globals->root.sgot == NULL)
        return bfd_reloc_notsupported;
 
@@ -4081,10 +4121,10 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
 
   BFD_ASSERT (globals && input_bfd && contents && rel);
 
 
   BFD_ASSERT (globals && input_bfd && contents && rel);
 
-  switch (r_type)
+  switch (elfNN_aarch64_bfd_reloc_from_type (r_type))
     {
     {
-    case R_AARCH64_TLSGD_ADR_PAGE21:
-    case R_AARCH64_TLSDESC_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
       if (is_local)
        {
          /* GD->LE relaxation:
       if (is_local)
        {
          /* GD->LE relaxation:
@@ -4106,7 +4146,7 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
          return bfd_reloc_continue;
        }
 
          return bfd_reloc_continue;
        }
 
-    case R_AARCH64_TLSDESC_LD64_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_LDNN_LO12_NC:
       if (is_local)
        {
          /* GD->LE relaxation:
       if (is_local)
        {
          /* GD->LE relaxation:
@@ -4126,7 +4166,7 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
          return bfd_reloc_continue;
        }
 
          return bfd_reloc_continue;
        }
 
-    case R_AARCH64_TLSGD_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
       if (is_local)
        {
          /* GD->LE relaxation
       if (is_local)
        {
          /* GD->LE relaxation
@@ -4153,7 +4193,7 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
             NOP                        => add  x0, x1, x0
           */
 
             NOP                        => add  x0, x1, x0
           */
 
-         BFD_ASSERT (ELFNN_R_TYPE (rel[1].r_info) == R_AARCH64_CALL26);
+         BFD_ASSERT (ELFNN_R_TYPE (rel[1].r_info) == AARCH64_R (CALL26));
 
          /* Remove the relocation on the BL instruction.  */
          rel[1].r_info = ELFNN_R_INFO (STN_UNDEF, R_AARCH64_NONE);
 
          /* Remove the relocation on the BL instruction.  */
          rel[1].r_info = ELFNN_R_INFO (STN_UNDEF, R_AARCH64_NONE);
@@ -4168,8 +4208,8 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
          return bfd_reloc_continue;
        }
 
          return bfd_reloc_continue;
        }
 
-    case R_AARCH64_TLSDESC_ADD_LO12_NC:
-    case R_AARCH64_TLSDESC_CALL:
+    case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_CALL:
       /* GD->IE/LE relaxation:
          add x0, x0, #:tlsdesc_lo12:var   =>   nop
          blr xd                           =>   nop
       /* GD->IE/LE relaxation:
          add x0, x0, #:tlsdesc_lo12:var   =>   nop
          blr xd                           =>   nop
@@ -4177,7 +4217,7 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
       bfd_putl32 (INSN_NOP, contents + rel->r_offset);
       return bfd_reloc_ok;
 
       bfd_putl32 (INSN_NOP, contents + rel->r_offset);
       return bfd_reloc_ok;
 
-    case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+    case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
       /* IE->LE relaxation:
          adrp xd, :gottprel:var   =>   movz xd, :tprel_g1:var
        */
       /* IE->LE relaxation:
          adrp xd, :gottprel:var   =>   movz xd, :tprel_g1:var
        */
@@ -4188,7 +4228,7 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
        }
       return bfd_reloc_continue;
 
        }
       return bfd_reloc_continue;
 
-    case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSIE_LDNN_GOTTPREL_LO12_NC:
       /* IE->LE relaxation:
          ldr  xd, [xm, #:gottprel_lo12:var]   =>   movk xd, :tprel_g0_nc:var
        */
       /* IE->LE relaxation:
          ldr  xd, [xm, #:gottprel_lo12:var]   =>   movk xd, :tprel_g0_nc:var
        */
@@ -4237,7 +4277,8 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
   for (; rel < relend; rel++)
     {
       unsigned int r_type;
   for (; rel < relend; rel++)
     {
       unsigned int r_type;
-      unsigned int relaxed_r_type;
+      bfd_reloc_code_real_type bfd_r_type;
+      bfd_reloc_code_real_type relaxed_bfd_r_type;
       reloc_howto_type *howto;
       unsigned long r_symndx;
       Elf_Internal_Sym *sym;
       reloc_howto_type *howto;
       unsigned long r_symndx;
       Elf_Internal_Sym *sym;
@@ -4263,6 +4304,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
             input_bfd, input_section, r_type);
          return FALSE;
        }
             input_bfd, input_section, r_type);
          return FALSE;
        }
+      bfd_r_type = elfNN_aarch64_bfd_reloc_from_howto (howto);
 
       h = NULL;
       sym = NULL;
 
       h = NULL;
       sym = NULL;
@@ -4333,7 +4375,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
          && (h == NULL
              || h->root.type == bfd_link_hash_defined
              || h->root.type == bfd_link_hash_defweak)
          && (h == NULL
              || h->root.type == bfd_link_hash_defined
              || h->root.type == bfd_link_hash_defweak)
-         && IS_AARCH64_TLS_RELOC (r_type) != (sym_type == STT_TLS))
+         && IS_AARCH64_TLS_RELOC (bfd_r_type) != (sym_type == STT_TLS))
        {
          (*_bfd_error_handler)
            ((sym_type == STT_TLS
        {
          (*_bfd_error_handler)
            ((sym_type == STT_TLS
@@ -4343,19 +4385,19 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
             input_section, (long) rel->r_offset, howto->name, name);
        }
 
             input_section, (long) rel->r_offset, howto->name, name);
        }
 
-
       /* We relax only if we can see that there can be a valid transition
          from a reloc type to another.
          We call elfNN_aarch64_final_link_relocate unless we're completely
          done, i.e., the relaxation produced the final output we want.  */
 
       /* We relax only if we can see that there can be a valid transition
          from a reloc type to another.
          We call elfNN_aarch64_final_link_relocate unless we're completely
          done, i.e., the relaxation produced the final output we want.  */
 
-      relaxed_r_type = aarch64_tls_transition (input_bfd, info, r_type,
-                                              h, r_symndx);
-      if (relaxed_r_type != r_type)
+      relaxed_bfd_r_type = aarch64_tls_transition (input_bfd, info, r_type,
+                                                  h, r_symndx);
+      if (relaxed_bfd_r_type != bfd_r_type)
        {
        {
-         r_type = relaxed_r_type;
-         howto = elfNN_aarch64_howto_from_type (r_type);
-
+         bfd_r_type = relaxed_bfd_r_type;
+         howto = elfNN_aarch64_howto_from_bfd_reloc (bfd_r_type);
+         BFD_ASSERT (howto != NULL);
+         r_type = howto->type;
          r = elfNN_aarch64_tls_relax (globals, input_bfd, contents, rel, h);
          unresolved_reloc = 0;
        }
          r = elfNN_aarch64_tls_relax (globals, input_bfd, contents, rel, h);
          unresolved_reloc = 0;
        }
@@ -4380,10 +4422,10 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
                                               h, &unresolved_reloc,
                                               save_addend, &addend);
 
                                               h, &unresolved_reloc,
                                               save_addend, &addend);
 
-      switch (r_type)
+      switch (elfNN_aarch64_bfd_reloc_from_type (r_type))
        {
        {
-       case R_AARCH64_TLSGD_ADR_PAGE21:
-       case R_AARCH64_TLSGD_ADD_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
+       case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
          if (! symbol_got_offset_mark_p (input_bfd, h, r_symndx))
            {
              bfd_boolean need_relocs = FALSE;
          if (! symbol_got_offset_mark_p (input_bfd, h, r_symndx))
            {
              bfd_boolean need_relocs = FALSE;
@@ -4405,7 +4447,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
              if (need_relocs)
                {
                  Elf_Internal_Rela rela;
              if (need_relocs)
                {
                  Elf_Internal_Rela rela;
-                 rela.r_info = ELFNN_R_INFO (indx, R_AARCH64_TLS_DTPMOD64);
+                 rela.r_info = ELFNN_R_INFO (indx, AARCH64_R (TLS_DTPMOD));
                  rela.r_addend = 0;
                  rela.r_offset = globals->root.sgot->output_section->vma +
                    globals->root.sgot->output_offset + off;
                  rela.r_addend = 0;
                  rela.r_offset = globals->root.sgot->output_section->vma +
                    globals->root.sgot->output_offset + off;
@@ -4429,7 +4471,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
                         relocation to fixup the tls offset at load
                         time.  */
                      rela.r_info =
                         relocation to fixup the tls offset at load
                         time.  */
                      rela.r_info =
-                       ELFNN_R_INFO (indx, R_AARCH64_TLS_DTPREL64);
+                       ELFNN_R_INFO (indx, AARCH64_R (TLS_DTPREL));
                      rela.r_addend = 0;
                      rela.r_offset =
                        (globals->root.sgot->output_section->vma
                      rela.r_addend = 0;
                      rela.r_offset =
                        (globals->root.sgot->output_section->vma
@@ -4459,8 +4501,8 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
            }
          break;
 
            }
          break;
 
-       case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
-       case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+       case BFD_RELOC_AARCH64_TLSIE_LDNN_GOTTPREL_LO12_NC:
          if (! symbol_got_offset_mark_p (input_bfd, h, r_symndx))
            {
              bfd_boolean need_relocs = FALSE;
          if (! symbol_got_offset_mark_p (input_bfd, h, r_symndx))
            {
              bfd_boolean need_relocs = FALSE;
@@ -4489,7 +4531,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
                  else
                    rela.r_addend = 0;
 
                  else
                    rela.r_addend = 0;
 
-                 rela.r_info = ELFNN_R_INFO (indx, R_AARCH64_TLS_TPREL64);
+                 rela.r_info = ELFNN_R_INFO (indx, AARCH64_R (TLS_TPREL));
                  rela.r_offset = globals->root.sgot->output_section->vma +
                    globals->root.sgot->output_offset + off;
 
                  rela.r_offset = globals->root.sgot->output_section->vma +
                    globals->root.sgot->output_offset + off;
 
@@ -4510,19 +4552,19 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
            }
          break;
 
            }
          break;
 
-       case R_AARCH64_TLSLE_ADD_TPREL_LO12:
-       case R_AARCH64_TLSLE_ADD_TPREL_HI12:
-       case R_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
-       case R_AARCH64_TLSLE_MOVW_TPREL_G2:
-       case R_AARCH64_TLSLE_MOVW_TPREL_G1:
-       case R_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
-       case R_AARCH64_TLSLE_MOVW_TPREL_G0:
-       case R_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
+       case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12:
+       case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12:
+       case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2:
+       case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1:
+       case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
+       case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0:
+       case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
          break;
 
          break;
 
-       case R_AARCH64_TLSDESC_ADR_PAGE21:
-       case R_AARCH64_TLSDESC_LD64_LO12_NC:
-       case R_AARCH64_TLSDESC_ADD_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
+       case BFD_RELOC_AARCH64_TLSDESC_LDNN_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
          if (! symbol_tlsdesc_got_offset_mark_p (input_bfd, h, r_symndx))
            {
              bfd_boolean need_relocs = FALSE;
          if (! symbol_tlsdesc_got_offset_mark_p (input_bfd, h, r_symndx))
            {
              bfd_boolean need_relocs = FALSE;
@@ -4540,7 +4582,8 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
                {
                  bfd_byte *loc;
                  Elf_Internal_Rela rela;
                {
                  bfd_byte *loc;
                  Elf_Internal_Rela rela;
-                 rela.r_info = ELFNN_R_INFO (indx, R_AARCH64_TLSDESC);
+                 rela.r_info = ELFNN_R_INFO (indx, AARCH64_R (TLSDESC));
+
                  rela.r_addend = 0;
                  rela.r_offset = (globals->root.sgotplt->output_section->vma
                                   + globals->root.sgotplt->output_offset
                  rela.r_addend = 0;
                  rela.r_offset = (globals->root.sgotplt->output_section->vma
                                   + globals->root.sgotplt->output_offset
@@ -4575,6 +4618,8 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
              symbol_tlsdesc_got_offset_mark (input_bfd, h, r_symndx);
            }
          break;
              symbol_tlsdesc_got_offset_mark (input_bfd, h, r_symndx);
            }
          break;
+       default:
+         break;
        }
 
       if (!save_addend)
        }
 
       if (!save_addend)
@@ -4894,28 +4939,30 @@ elfNN_aarch64_gc_sweep_hook (bfd *abfd,
        }
 
       r_type = ELFNN_R_TYPE (rel->r_info);
        }
 
       r_type = ELFNN_R_TYPE (rel->r_info);
-      r_type = aarch64_tls_transition (abfd,info, r_type, h ,r_symndx);
-      switch (r_type)
+      switch (aarch64_tls_transition (abfd,info, r_type, h ,r_symndx))
        {
        {
-       case R_AARCH64_LD64_GOT_LO12_NC:
-       case R_AARCH64_GOT_LD_PREL19:
-       case R_AARCH64_ADR_GOT_PAGE:
-       case R_AARCH64_TLSGD_ADR_PAGE21:
-       case R_AARCH64_TLSGD_ADD_LO12_NC:
-       case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
-       case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
-       case R_AARCH64_TLSLE_ADD_TPREL_LO12:
-       case R_AARCH64_TLSLE_ADD_TPREL_HI12:
-       case R_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
-       case R_AARCH64_TLSLE_MOVW_TPREL_G2:
-       case R_AARCH64_TLSLE_MOVW_TPREL_G1:
-       case R_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
-       case R_AARCH64_TLSLE_MOVW_TPREL_G0:
-       case R_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
-       case R_AARCH64_TLSDESC_ADR_PAGE21:
-       case R_AARCH64_TLSDESC_ADD_LO12_NC:
-       case R_AARCH64_TLSDESC_LD64_LO12_NC:
-          if (h != NULL)
+       case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
+       case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC:
+       case BFD_RELOC_AARCH64_GOT_LD_PREL19:
+       case BFD_RELOC_AARCH64_ADR_GOT_PAGE:
+       case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
+       case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+       case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12:
+       case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12:
+       case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2:
+       case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1:
+       case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
+       case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0:
+       case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
+       case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
+       case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC:
+         if (h != NULL)
            {
              if (h->got.refcount > 0)
                h->got.refcount -= 1;
            {
              if (h->got.refcount > 0)
                h->got.refcount -= 1;
@@ -4927,9 +4974,9 @@ elfNN_aarch64_gc_sweep_hook (bfd *abfd,
            }
          break;
 
            }
          break;
 
-       case R_AARCH64_ADR_PREL_PG_HI21_NC:
-       case R_AARCH64_ADR_PREL_PG_HI21:
-       case R_AARCH64_ADR_PREL_LO21:
+       case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
+       case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
+       case BFD_RELOC_AARCH64_ADR_LO21_PCREL:
          if (h != NULL && info->executable)
            {
              if (h->plt.refcount > 0)
          if (h != NULL && info->executable)
            {
              if (h->plt.refcount > 0)
@@ -4937,10 +4984,10 @@ elfNN_aarch64_gc_sweep_hook (bfd *abfd,
            }
          break;
 
            }
          break;
 
-       case R_AARCH64_CALL26:
-       case R_AARCH64_JUMP26:
-          /* If this is a local symbol then we resolve it
-             directly without creating a PLT entry.  */
+       case BFD_RELOC_AARCH64_CALL26:
+       case BFD_RELOC_AARCH64_JUMP26:
+         /* If this is a local symbol then we resolve it
+            directly without creating a PLT entry.  */
          if (h == NULL)
            continue;
 
          if (h == NULL)
            continue;
 
@@ -4948,7 +4995,7 @@ elfNN_aarch64_gc_sweep_hook (bfd *abfd,
            h->plt.refcount -= 1;
          break;
 
            h->plt.refcount -= 1;
          break;
 
-       case R_AARCH64_ABS64:
+       case BFD_RELOC_AARCH64_NN:
          if (h != NULL && info->executable)
            {
              if (h->plt.refcount > 0)
          if (h != NULL && info->executable)
            {
              if (h->plt.refcount > 0)
@@ -5114,6 +5161,7 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
       struct elf_link_hash_entry *h;
       unsigned long r_symndx;
       unsigned int r_type;
       struct elf_link_hash_entry *h;
       unsigned long r_symndx;
       unsigned int r_type;
+      bfd_reloc_code_real_type bfd_r_type;
 
       r_symndx = ELFNN_R_SYM (rel->r_info);
       r_type = ELFNN_R_TYPE (rel->r_info);
 
       r_symndx = ELFNN_R_SYM (rel->r_info);
       r_type = ELFNN_R_TYPE (rel->r_info);
@@ -5140,11 +5188,11 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
        }
 
       /* Could be done earlier, if h were already available.  */
        }
 
       /* Could be done earlier, if h were already available.  */
-      r_type = aarch64_tls_transition (abfd, info, r_type, h, r_symndx);
+      bfd_r_type = aarch64_tls_transition (abfd, info, r_type, h, r_symndx);
 
 
-      switch (r_type)
+      switch (bfd_r_type)
        {
        {
-       case R_AARCH64_ABS64:
+       case BFD_RELOC_AARCH64_NN:
 
          /* We don't need to handle relocs into sections not going into
             the "real" output.  */
 
          /* We don't need to handle relocs into sections not going into
             the "real" output.  */
@@ -5237,29 +5285,32 @@ 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.  */
 
          /* RR: We probably want to keep a consistency check that
             there are no dangling GOT_PAGE relocs.  */
-       case R_AARCH64_LD64_GOT_LO12_NC:
-       case R_AARCH64_GOT_LD_PREL19:
-       case R_AARCH64_ADR_GOT_PAGE:
-       case R_AARCH64_TLSGD_ADR_PAGE21:
-       case R_AARCH64_TLSGD_ADD_LO12_NC:
-       case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
-       case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
-       case R_AARCH64_TLSLE_ADD_TPREL_LO12:
-       case R_AARCH64_TLSLE_ADD_TPREL_HI12:
-       case R_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
-       case R_AARCH64_TLSLE_MOVW_TPREL_G2:
-       case R_AARCH64_TLSLE_MOVW_TPREL_G1:
-       case R_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
-       case R_AARCH64_TLSLE_MOVW_TPREL_G0:
-       case R_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
-       case R_AARCH64_TLSDESC_ADR_PAGE21:
-       case R_AARCH64_TLSDESC_ADD_LO12_NC:
-       case R_AARCH64_TLSDESC_LD64_LO12_NC:
+       case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
+       case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC:
+       case BFD_RELOC_AARCH64_GOT_LD_PREL19:
+       case BFD_RELOC_AARCH64_ADR_GOT_PAGE:
+       case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
+       case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+       case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12:
+       case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12:
+       case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2:
+       case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1:
+       case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
+       case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0:
+       case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
+       case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
+       case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC:
          {
            unsigned got_type;
            unsigned old_got_type;
 
          {
            unsigned got_type;
            unsigned old_got_type;
 
-           got_type = aarch64_reloc_got_type (r_type);
+           got_type = aarch64_reloc_got_type (bfd_r_type);
 
            if (h)
              {
 
            if (h)
              {
@@ -5322,9 +5373,9 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
            break;
          }
 
            break;
          }
 
-       case R_AARCH64_ADR_PREL_PG_HI21_NC:
-       case R_AARCH64_ADR_PREL_PG_HI21:
-       case R_AARCH64_ADR_PREL_LO21:
+       case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
+       case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
+       case BFD_RELOC_AARCH64_ADR_LO21_PCREL:
          if (h != NULL && info->executable)
            {
              /* If this reloc is in a read-only section, we might
          if (h != NULL && info->executable)
            {
              /* If this reloc is in a read-only section, we might
@@ -5342,8 +5393,8 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
             relocations in shared libraries.  */
          break;
 
             relocations in shared libraries.  */
          break;
 
-       case R_AARCH64_CALL26:
-       case R_AARCH64_JUMP26:
+       case BFD_RELOC_AARCH64_CALL26:
+       case BFD_RELOC_AARCH64_JUMP26:
          /* If this is a local symbol then we resolve it
             directly without creating a PLT entry.  */
          if (h == NULL)
          /* If this is a local symbol then we resolve it
             directly without creating a PLT entry.  */
          if (h == NULL)
@@ -5352,8 +5403,12 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
          h->needs_plt = 1;
          h->plt.refcount += 1;
          break;
          h->needs_plt = 1;
          h->plt.refcount += 1;
          break;
+
+       default:
+         break;
        }
     }
        }
     }
+
   return TRUE;
 }
 
   return TRUE;
 }
 
@@ -5511,11 +5566,11 @@ elfNN_aarch64_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSE
 {
   switch ((int) ELFNN_R_TYPE (rela->r_info))
     {
 {
   switch ((int) ELFNN_R_TYPE (rela->r_info))
     {
-    case R_AARCH64_RELATIVE:
+    case AARCH64_R (RELATIVE):
       return reloc_class_relative;
       return reloc_class_relative;
-    case R_AARCH64_JUMP_SLOT:
+    case AARCH64_R (JUMP_SLOT):
       return reloc_class_plt;
       return reloc_class_plt;
-    case R_AARCH64_COPY:
+    case AARCH64_R (COPY):
       return reloc_class_copy;
     default:
       return reloc_class_normal;
       return reloc_class_copy;
     default:
       return reloc_class_normal;
@@ -6496,8 +6551,6 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
 #undef add_dynamic_entry
 
   return TRUE;
 #undef add_dynamic_entry
 
   return TRUE;
-
-
 }
 
 static inline void
 }
 
 static inline void
@@ -6539,18 +6592,18 @@ elfNN_aarch64_create_small_pltn_entry (struct elf_link_hash_entry *h,
 
   /* Fill in the top 21 bits for this: ADRP x16, PLT_GOT + n * 8.
      ADRP:   ((PG(S+A)-PG(P)) >> 12) & 0x1fffff */
 
   /* Fill in the top 21 bits for this: ADRP x16, PLT_GOT + n * 8.
      ADRP:   ((PG(S+A)-PG(P)) >> 12) & 0x1fffff */
-  elf64_aarch64_update_plt_entry (output_bfd, R_AARCH64_ADR_PREL_PG_HI21,
+  elf64_aarch64_update_plt_entry (output_bfd, AARCH64_R (ADR_PREL_PG_HI21),
                                  plt_entry,
                                  PG (gotplt_entry_address) -
                                  PG (plt_entry_address));
 
   /* Fill in the lo12 bits for the load from the pltgot.  */
                                  plt_entry,
                                  PG (gotplt_entry_address) -
                                  PG (plt_entry_address));
 
   /* Fill in the lo12 bits for the load from the pltgot.  */
-  elf64_aarch64_update_plt_entry (output_bfd, R_AARCH64_LDST64_ABS_LO12_NC,
+  elf64_aarch64_update_plt_entry (output_bfd, AARCH64_R (LDSTNN_ABS_LO12_NC),
                                  plt_entry + 4,
                                  PG_OFFSET (gotplt_entry_address));
 
   /* Fill in the the lo12 bits for the add from the pltgot entry.  */
                                  plt_entry + 4,
                                  PG_OFFSET (gotplt_entry_address));
 
   /* Fill in the the lo12 bits for the add from the pltgot entry.  */
-  elf64_aarch64_update_plt_entry (output_bfd, R_AARCH64_ADD_ABS_LO12_NC,
+  elf64_aarch64_update_plt_entry (output_bfd, AARCH64_R (ADD_ABS_LO12_NC),
                                  plt_entry + 8,
                                  PG_OFFSET (gotplt_entry_address));
 
                                  plt_entry + 8,
                                  PG_OFFSET (gotplt_entry_address));
 
@@ -6669,7 +6722,7 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd,
            return FALSE;
 
          BFD_ASSERT ((h->got.offset & 1) != 0);
            return FALSE;
 
          BFD_ASSERT ((h->got.offset & 1) != 0);
-         rela.r_info = ELFNN_R_INFO (0, R_AARCH64_RELATIVE);
+         rela.r_info = ELFNN_R_INFO (0, AARCH64_R (RELATIVE));
          rela.r_addend = (h->root.u.def.value
                           + h->root.u.def.section->output_section->vma
                           + h->root.u.def.section->output_offset);
          rela.r_addend = (h->root.u.def.value
                           + h->root.u.def.section->output_section->vma
                           + h->root.u.def.section->output_offset);
@@ -6679,7 +6732,7 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd,
          BFD_ASSERT ((h->got.offset & 1) == 0);
          bfd_put_NN (output_bfd, (bfd_vma) 0,
                      htab->root.sgot->contents + h->got.offset);
          BFD_ASSERT ((h->got.offset & 1) == 0);
          bfd_put_NN (output_bfd, (bfd_vma) 0,
                      htab->root.sgot->contents + h->got.offset);
-         rela.r_info = ELFNN_R_INFO (h->dynindx, R_AARCH64_GLOB_DAT);
+         rela.r_info = ELFNN_R_INFO (h->dynindx, AARCH64_R (GLOB_DAT));
          rela.r_addend = 0;
        }
 
          rela.r_addend = 0;
        }
 
@@ -6704,7 +6757,7 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd,
       rela.r_offset = (h->root.u.def.value
                       + h->root.u.def.section->output_section->vma
                       + h->root.u.def.section->output_offset);
       rela.r_offset = (h->root.u.def.value
                       + h->root.u.def.section->output_section->vma
                       + h->root.u.def.section->output_offset);
-      rela.r_info = ELFNN_R_INFO (h->dynindx, R_AARCH64_COPY);
+      rela.r_info = ELFNN_R_INFO (h->dynindx, AARCH64_R (COPY));
       rela.r_addend = 0;
       loc = htab->srelbss->contents;
       loc += htab->srelbss->reloc_count++ * RELOC_SIZE (htab);
       rela.r_addend = 0;
       loc = htab->srelbss->contents;
       loc += htab->srelbss->reloc_count++ * RELOC_SIZE (htab);
@@ -6758,15 +6811,15 @@ elfNN_aarch64_init_small_plt0_entry (bfd *output_bfd ATTRIBUTE_UNUSED,
 
   /* Fill in the top 21 bits for this: ADRP x16, PLT_GOT + n * 8.
      ADRP:   ((PG(S+A)-PG(P)) >> 12) & 0x1fffff */
 
   /* Fill in the top 21 bits for this: ADRP x16, PLT_GOT + n * 8.
      ADRP:   ((PG(S+A)-PG(P)) >> 12) & 0x1fffff */
-  elf64_aarch64_update_plt_entry (output_bfd, R_AARCH64_ADR_PREL_PG_HI21,
+  elf64_aarch64_update_plt_entry (output_bfd, AARCH64_R (ADR_PREL_PG_HI21),
                                  htab->root.splt->contents + 4,
                                  PG (plt_got_base + 16) - PG (plt_base + 4));
 
                                  htab->root.splt->contents + 4,
                                  PG (plt_got_base + 16) - PG (plt_base + 4));
 
-  elf64_aarch64_update_plt_entry (output_bfd, R_AARCH64_LDST64_ABS_LO12_NC,
+  elf64_aarch64_update_plt_entry (output_bfd, AARCH64_R (LDSTNN_ABS_LO12_NC),
                                  htab->root.splt->contents + 8,
                                  PG_OFFSET (plt_got_base + 16));
 
                                  htab->root.splt->contents + 8,
                                  PG_OFFSET (plt_got_base + 16));
 
-  elf64_aarch64_update_plt_entry (output_bfd, R_AARCH64_ADD_ABS_LO12_NC,
+  elf64_aarch64_update_plt_entry (output_bfd, AARCH64_R (ADD_ABS_LO12_NC),
                                  htab->root.splt->contents + 12,
                                  PG_OFFSET (plt_got_base + 16));
 }
                                  htab->root.splt->contents + 12,
                                  PG_OFFSET (plt_got_base + 16));
 }
index 9450729062eac4c2625a469d4b1a0ba2513e9323..274b49d8032f0aba3f4243b9aa74f7f441b26e4e 100644 (file)
@@ -2524,64 +2524,84 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
   "BFD_RELOC_MICROBLAZE_64_TLSDTPREL",
   "BFD_RELOC_MICROBLAZE_64_TLSGOTTPREL",
   "BFD_RELOC_MICROBLAZE_64_TLSTPREL",
   "BFD_RELOC_MICROBLAZE_64_TLSDTPREL",
   "BFD_RELOC_MICROBLAZE_64_TLSGOTTPREL",
   "BFD_RELOC_MICROBLAZE_64_TLSTPREL",
-  "BFD_RELOC_AARCH64_ADD_LO12",
-  "BFD_RELOC_AARCH64_GOT_LD_PREL19",
-  "BFD_RELOC_AARCH64_ADR_GOT_PAGE",
+  "BFD_RELOC_AARCH64_RELOC_START",
+  "BFD_RELOC_AARCH64_NONE",
+  "BFD_RELOC_AARCH64_64",
+  "BFD_RELOC_AARCH64_32",
+  "BFD_RELOC_AARCH64_16",
+  "BFD_RELOC_AARCH64_64_PCREL",
+  "BFD_RELOC_AARCH64_32_PCREL",
+  "BFD_RELOC_AARCH64_16_PCREL",
+  "BFD_RELOC_AARCH64_MOVW_G0",
+  "BFD_RELOC_AARCH64_MOVW_G0_NC",
+  "BFD_RELOC_AARCH64_MOVW_G1",
+  "BFD_RELOC_AARCH64_MOVW_G1_NC",
+  "BFD_RELOC_AARCH64_MOVW_G2",
+  "BFD_RELOC_AARCH64_MOVW_G2_NC",
+  "BFD_RELOC_AARCH64_MOVW_G3",
+  "BFD_RELOC_AARCH64_MOVW_G0_S",
+  "BFD_RELOC_AARCH64_MOVW_G1_S",
+  "BFD_RELOC_AARCH64_MOVW_G2_S",
+  "BFD_RELOC_AARCH64_LD_LO19_PCREL",
+  "BFD_RELOC_AARCH64_ADR_LO21_PCREL",
   "BFD_RELOC_AARCH64_ADR_HI21_PCREL",
   "BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL",
   "BFD_RELOC_AARCH64_ADR_HI21_PCREL",
   "BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL",
-  "BFD_RELOC_AARCH64_ADR_LO21_PCREL",
+  "BFD_RELOC_AARCH64_ADD_LO12",
+  "BFD_RELOC_AARCH64_LDST8_LO12",
+  "BFD_RELOC_AARCH64_TSTBR14",
   "BFD_RELOC_AARCH64_BRANCH19",
   "BFD_RELOC_AARCH64_BRANCH19",
-  "BFD_RELOC_AARCH64_CALL26",
-  "BFD_RELOC_AARCH64_GAS_INTERNAL_FIXUP",
   "BFD_RELOC_AARCH64_JUMP26",
   "BFD_RELOC_AARCH64_JUMP26",
-  "BFD_RELOC_AARCH64_LD_LO19_PCREL",
-  "BFD_RELOC_AARCH64_LD64_GOT_LO12_NC",
-  "BFD_RELOC_AARCH64_LDST_LO12",
-  "BFD_RELOC_AARCH64_LDST8_LO12",
+  "BFD_RELOC_AARCH64_CALL26",
   "BFD_RELOC_AARCH64_LDST16_LO12",
   "BFD_RELOC_AARCH64_LDST32_LO12",
   "BFD_RELOC_AARCH64_LDST64_LO12",
   "BFD_RELOC_AARCH64_LDST128_LO12",
   "BFD_RELOC_AARCH64_LDST16_LO12",
   "BFD_RELOC_AARCH64_LDST32_LO12",
   "BFD_RELOC_AARCH64_LDST64_LO12",
   "BFD_RELOC_AARCH64_LDST128_LO12",
-  "BFD_RELOC_AARCH64_MOVW_G0",
-  "BFD_RELOC_AARCH64_MOVW_G0_S",
-  "BFD_RELOC_AARCH64_MOVW_G0_NC",
-  "BFD_RELOC_AARCH64_MOVW_G1",
-  "BFD_RELOC_AARCH64_MOVW_G1_NC",
-  "BFD_RELOC_AARCH64_MOVW_G1_S",
-  "BFD_RELOC_AARCH64_MOVW_G2",
-  "BFD_RELOC_AARCH64_MOVW_G2_NC",
-  "BFD_RELOC_AARCH64_MOVW_G2_S",
-  "BFD_RELOC_AARCH64_MOVW_G3",
-  "BFD_RELOC_AARCH64_TLSDESC",
-  "BFD_RELOC_AARCH64_TLSDESC_ADD",
-  "BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC",
-  "BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21",
-  "BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21",
-  "BFD_RELOC_AARCH64_TLSDESC_CALL",
-  "BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC",
-  "BFD_RELOC_AARCH64_TLSDESC_LD_PREL19",
-  "BFD_RELOC_AARCH64_TLSDESC_LDR",
-  "BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC",
-  "BFD_RELOC_AARCH64_TLSDESC_OFF_G1",
-  "BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC",
+  "BFD_RELOC_AARCH64_GOT_LD_PREL19",
+  "BFD_RELOC_AARCH64_ADR_GOT_PAGE",
+  "BFD_RELOC_AARCH64_LD64_GOT_LO12_NC",
+  "BFD_RELOC_AARCH64_LD32_GOT_LO12_NC",
   "BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21",
   "BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21",
+  "BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC",
+  "BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1",
+  "BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC",
   "BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21",
   "BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21",
-  "BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19",
   "BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC",
   "BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC",
-  "BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC",
-  "BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1",
+  "BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC",
+  "BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19",
+  "BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2",
+  "BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1",
+  "BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC",
+  "BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0",
+  "BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC",
   "BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12",
   "BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12",
   "BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC",
   "BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12",
   "BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12",
   "BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC",
-  "BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0",
-  "BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC",
-  "BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1",
-  "BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC",
-  "BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2",
-  "BFD_RELOC_AARCH64_TLS_DTPMOD64",
-  "BFD_RELOC_AARCH64_TLS_DTPREL64",
-  "BFD_RELOC_AARCH64_TLS_TPREL64",
-  "BFD_RELOC_AARCH64_TSTBR14",
+  "BFD_RELOC_AARCH64_TLSDESC_LD_PREL19",
+  "BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21",
+  "BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21",
+  "BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC",
+  "BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC",
+  "BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC",
+  "BFD_RELOC_AARCH64_TLSDESC_OFF_G1",
+  "BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC",
+  "BFD_RELOC_AARCH64_TLSDESC_LDR",
+  "BFD_RELOC_AARCH64_TLSDESC_ADD",
+  "BFD_RELOC_AARCH64_TLSDESC_CALL",
+  "BFD_RELOC_AARCH64_COPY",
+  "BFD_RELOC_AARCH64_GLOB_DAT",
+  "BFD_RELOC_AARCH64_JUMP_SLOT",
+  "BFD_RELOC_AARCH64_RELATIVE",
+  "BFD_RELOC_AARCH64_TLS_DTPMOD",
+  "BFD_RELOC_AARCH64_TLS_DTPREL",
+  "BFD_RELOC_AARCH64_TLS_TPREL",
+  "BFD_RELOC_AARCH64_TLSDESC",
+  "BFD_RELOC_AARCH64_IRELATIVE",
+  "BFD_RELOC_AARCH64_RELOC_END",
+  "BFD_RELOC_AARCH64_GAS_INTERNAL_FIXUP",
+  "BFD_RELOC_AARCH64_LDST_LO12",
+  "BFD_RELOC_AARCH64_LD_GOT_LO12_NC",
+  "BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC",
+  "BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC",
   "BFD_RELOC_TILEPRO_COPY",
   "BFD_RELOC_TILEPRO_GLOB_DAT",
   "BFD_RELOC_TILEPRO_JMP_SLOT",
   "BFD_RELOC_TILEPRO_COPY",
   "BFD_RELOC_TILEPRO_GLOB_DAT",
   "BFD_RELOC_TILEPRO_JMP_SLOT",
index 4d57e23abc0056181178370744534a0ab19d7543..f880fd7969a1c505b0c6d84c64cb4e31850c8b16 100644 (file)
@@ -6113,62 +6113,88 @@ ENUMDOC
   to two words (uses imm instruction).
 
 ENUM
   to two words (uses imm instruction).
 
 ENUM
-  BFD_RELOC_AARCH64_ADD_LO12
+  BFD_RELOC_AARCH64_RELOC_START
 ENUMDOC
 ENUMDOC
-  AArch64 ADD immediate instruction, holding bits 0 to 11 of the address.
-  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.
+  AArch64 pseudo relocation code to mark the start of the AArch64
+  relocation enumerators.  N.B. the order of the enumerators is
+  important as several tables in the AArch64 bfd backend are indexed
+  by these enumerators; make sure they are all synced.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_GOT_LD_PREL19
+  BFD_RELOC_AARCH64_NONE
 ENUMDOC
 ENUMDOC
-  AArch64 Load Literal instruction, holding a 19 bit PC relative word
-  offset of the global offset table entry for a symbol.  The lowest two
-  bits must be zero and are not stored in the instruction, giving a 21
-  bit signed byte offset.  This relocation type requires signed overflow
-  checking.
+  AArch64 null relocation code.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_ADR_GOT_PAGE
+  BFD_RELOC_AARCH64_64
+ENUMX
+  BFD_RELOC_AARCH64_32
+ENUMX
+  BFD_RELOC_AARCH64_16
 ENUMDOC
 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.
+  Basic absolute relocations of N bits.  These are equivalent to
+BFD_RELOC_N and they were added to assist the indexing of the howto
+table.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_ADR_HI21_PCREL
+  BFD_RELOC_AARCH64_64_PCREL
+ENUMX
+  BFD_RELOC_AARCH64_32_PCREL
+ENUMX
+  BFD_RELOC_AARCH64_16_PCREL
 ENUMDOC
 ENUMDOC
-  AArch64 ADRP instruction, with bits 12 to 32 of a pc-relative page
-  offset, giving a 4KB aligned page base address.
+  PC-relative relocations.  These are equivalent to BFD_RELOC_N_PCREL
+and they were added to assist the indexing of the howto table.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL
+  BFD_RELOC_AARCH64_MOVW_G0
 ENUMDOC
 ENUMDOC
-  AArch64 ADRP instruction, with bits 12 to 32 of a pc-relative page
-  offset, giving a 4KB aligned page base address, but with no overflow
-  checking.
+  AArch64 MOV[NZK] instruction with most significant bits 0 to 15
+  of an unsigned address/value.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_ADR_LO21_PCREL
+  BFD_RELOC_AARCH64_MOVW_G0_NC
 ENUMDOC
 ENUMDOC
-  AArch64 ADR instruction, holding a simple 21 bit pc-relative byte offset.
+  AArch64 MOV[NZK] instruction with less significant bits 0 to 15 of
+  an address/value.  No overflow checking.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_BRANCH19
+  BFD_RELOC_AARCH64_MOVW_G1
 ENUMDOC
 ENUMDOC
-  AArch64 19 bit pc-relative conditional branch and compare & branch.
-  The lowest two bits must be zero and are not stored in the instruction,
-  giving a 21 bit signed byte offset.
+  AArch64 MOV[NZK] instruction with most significant bits 16 to 31
+  of an unsigned address/value.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_CALL26
+  BFD_RELOC_AARCH64_MOVW_G1_NC
 ENUMDOC
 ENUMDOC
-  AArch64 26 bit pc-relative unconditional branch and link.
-  The lowest two bits must be zero and are not stored in the instruction,
-  giving a 28 bit signed byte offset.
+  AArch64 MOV[NZK] instruction with less significant bits 16 to 31
+  of an address/value.  No overflow checking.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_GAS_INTERNAL_FIXUP
+  BFD_RELOC_AARCH64_MOVW_G2
 ENUMDOC
 ENUMDOC
-  AArch64 pseudo relocation code to be used internally by the AArch64
-  assembler and not (currently) written to any object files.
+  AArch64 MOV[NZK] instruction with most significant bits 32 to 47
+  of an unsigned address/value.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_JUMP26
+  BFD_RELOC_AARCH64_MOVW_G2_NC
 ENUMDOC
 ENUMDOC
-  AArch64 26 bit pc-relative unconditional branch.
-  The lowest two bits must be zero and are not stored in the instruction,
-  giving a 28 bit signed byte offset.
+  AArch64 MOV[NZK] instruction with less significant bits 32 to 47
+  of an address/value.  No overflow checking.
+ENUM
+  BFD_RELOC_AARCH64_MOVW_G3
+ENUMDOC
+  AArch64 MOV[NZK] instruction with most signficant bits 48 to 64
+  of a signed or unsigned address/value.
+ENUM
+  BFD_RELOC_AARCH64_MOVW_G0_S
+ENUMDOC
+  AArch64 MOV[NZ] instruction with most significant bits 0 to 15
+  of a signed value.  Changes instruction to MOVZ or MOVN depending on the
+  value's sign.
+ENUM
+  BFD_RELOC_AARCH64_MOVW_G1_S
+ENUMDOC
+  AArch64 MOV[NZ] instruction with most significant bits 16 to 31
+  of a signed value.  Changes instruction to MOVZ or MOVN depending on the
+  value's sign.
+ENUM
+  BFD_RELOC_AARCH64_MOVW_G2_S
+ENUMDOC
+  AArch64 MOV[NZ] instruction with most significant bits 32 to 47
+  of a signed value.  Changes instruction to MOVZ or MOVN depending on the
+  value's sign.
 ENUM
   BFD_RELOC_AARCH64_LD_LO19_PCREL
 ENUMDOC
 ENUM
   BFD_RELOC_AARCH64_LD_LO19_PCREL
 ENUMDOC
@@ -6176,21 +6202,54 @@ ENUMDOC
   offset.  The lowest two bits must be zero and are not stored in the
   instruction, giving a 21 bit signed byte offset.
 ENUM
   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_AARCH64_LD64_GOT_LO12_NC
+  BFD_RELOC_AARCH64_ADR_LO21_PCREL
 ENUMDOC
 ENUMDOC
-  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_GOTPAGE.
+  AArch64 ADR instruction, holding a simple 21 bit pc-relative byte offset.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_LDST_LO12
+  BFD_RELOC_AARCH64_ADR_HI21_PCREL
 ENUMDOC
 ENUMDOC
-  AArch64 unspecified load/store instruction, holding bits 0 to 11 of the
-  address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.
+  AArch64 ADRP instruction, with bits 12 to 32 of a pc-relative page
+  offset, giving a 4KB aligned page base address.
+ENUM
+  BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL
+ENUMDOC
+  AArch64 ADRP instruction, with bits 12 to 32 of a pc-relative page
+  offset, giving a 4KB aligned page base address, but with no overflow
+  checking.
+ENUM
+  BFD_RELOC_AARCH64_ADD_LO12
+ENUMDOC
+  AArch64 ADD immediate instruction, holding bits 0 to 11 of the address.
+  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.
 ENUM
   BFD_RELOC_AARCH64_LDST8_LO12
 ENUMDOC
   AArch64 8-bit load/store instruction, holding bits 0 to 11 of the
   address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.
 ENUM
   BFD_RELOC_AARCH64_LDST8_LO12
 ENUMDOC
   AArch64 8-bit load/store instruction, holding bits 0 to 11 of the
   address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.
+ENUM
+  BFD_RELOC_AARCH64_TSTBR14
+ENUMDOC
+  AArch64 14 bit pc-relative test bit and branch.
+  The lowest two bits must be zero and are not stored in the instruction,
+  giving a 16 bit signed byte offset.
+ENUM
+  BFD_RELOC_AARCH64_BRANCH19
+ENUMDOC
+  AArch64 19 bit pc-relative conditional branch and compare & branch.
+  The lowest two bits must be zero and are not stored in the instruction,
+  giving a 21 bit signed byte offset.
+ENUM
+  BFD_RELOC_AARCH64_JUMP26
+ENUMDOC
+  AArch64 26 bit pc-relative unconditional branch.
+  The lowest two bits must be zero and are not stored in the instruction,
+  giving a 28 bit signed byte offset.
+ENUM
+  BFD_RELOC_AARCH64_CALL26
+ENUMDOC
+  AArch64 26 bit pc-relative unconditional branch and link.
+  The lowest two bits must be zero and are not stored in the instruction,
+  giving a 28 bit signed byte offset.
 ENUM
   BFD_RELOC_AARCH64_LDST16_LO12
 ENUMDOC
 ENUM
   BFD_RELOC_AARCH64_LDST16_LO12
 ENUMDOC
@@ -6212,96 +6271,122 @@ ENUMDOC
   AArch64 128-bit load/store instruction, holding bits 0 to 11 of the
   address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.
 ENUM
   AArch64 128-bit load/store instruction, holding bits 0 to 11 of the
   address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.
 ENUM
-  BFD_RELOC_AARCH64_MOVW_G0
+  BFD_RELOC_AARCH64_GOT_LD_PREL19
 ENUMDOC
 ENUMDOC
-  AArch64 MOV[NZK] instruction with most significant bits 0 to 15
-  of an unsigned address/value.
+  AArch64 Load Literal instruction, holding a 19 bit PC relative word
+  offset of the global offset table entry for a symbol.  The lowest two
+  bits must be zero and are not stored in the instruction, giving a 21
+  bit signed byte offset.  This relocation type requires signed overflow
+  checking.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_MOVW_G0_S
+  BFD_RELOC_AARCH64_ADR_GOT_PAGE
 ENUMDOC
 ENUMDOC
-  AArch64 MOV[NZ] instruction with most significant bits 0 to 15
-  of a signed value.  Changes instruction to MOVZ or MOVN depending on the
-  value's sign.
+  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
 ENUM
-  BFD_RELOC_AARCH64_MOVW_G0_NC
+  BFD_RELOC_AARCH64_LD64_GOT_LO12_NC
 ENUMDOC
 ENUMDOC
-  AArch64 MOV[NZK] instruction with less significant bits 0 to 15 of
-  an address/value.  No overflow checking.
+  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_GOTPAGE.  Valid in LP64 ABI only.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_MOVW_G1
+  BFD_RELOC_AARCH64_LD32_GOT_LO12_NC
 ENUMDOC
 ENUMDOC
-  AArch64 MOV[NZK] instruction with most significant bits 16 to 31
-  of an unsigned address/value.
+  Unsigned 12 bit byte offset for 32 bit load/store from the page of
+  the GOT entry for this symbol.  Used in conjunction with
+  BFD_RELOC_AARCH64_ADR_GOTPAGE.  Valid in ILP32 ABI only.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_MOVW_G1_NC
+  BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21
 ENUMDOC
 ENUMDOC
-  AArch64 MOV[NZK] instruction with less significant bits 16 to 31
-  of an address/value.  No overflow checking.
+  Get to the page base of the global offset table entry for a symbols
+  tls_index structure as part of an adrp instruction using a 21 bit PC
+  relative value.  Used in conjunction with
+  BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_MOVW_G1_S
+  BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC
 ENUMDOC
 ENUMDOC
-  AArch64 MOV[NZ] instruction with most significant bits 16 to 31
-  of a signed value.  Changes instruction to MOVZ or MOVN depending on the
-  value's sign.
+  Unsigned 12 bit byte offset to global offset table entry for a symbols
+  tls_index structure.  Used in conjunction with
+  BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_MOVW_G2
+  BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1
 ENUMDOC
 ENUMDOC
-  AArch64 MOV[NZK] instruction with most significant bits 32 to 47
-  of an unsigned address/value.
+  AArch64 TLS INITIAL EXEC relocation.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_MOVW_G2_NC
+  BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC
 ENUMDOC
 ENUMDOC
-  AArch64 MOV[NZK] instruction with less significant bits 32 to 47
-  of an address/value.  No overflow checking.
+  AArch64 TLS INITIAL EXEC relocation.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_MOVW_G2_S
+  BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21
 ENUMDOC
 ENUMDOC
-  AArch64 MOV[NZ] instruction with most significant bits 32 to 47
-  of a signed value.  Changes instruction to MOVZ or MOVN depending on the
-  value's sign.
+  AArch64 TLS INITIAL EXEC relocation.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_MOVW_G3
+  BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC
 ENUMDOC
 ENUMDOC
-  AArch64 MOV[NZK] instruction with most signficant bits 48 to 64
-  of a signed or unsigned address/value.
+  AArch64 TLS INITIAL EXEC relocation.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLSDESC
+  BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC
 ENUMDOC
 ENUMDOC
-  AArch64 TLS relocation.
+  AArch64 TLS INITIAL EXEC relocation.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLSDESC_ADD
+  BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19
 ENUMDOC
 ENUMDOC
-  AArch64 TLS DESC relocation.
+  AArch64 TLS INITIAL EXEC relocation.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC
+  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2
 ENUMDOC
 ENUMDOC
-  AArch64 TLS DESC relocation.
+  AArch64 TLS LOCAL EXEC relocation.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21
+  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1
 ENUMDOC
 ENUMDOC
-  AArch64 TLS DESC relocation.
+  AArch64 TLS LOCAL EXEC relocation.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21
+  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC
+ENUMDOC
+  AArch64 TLS LOCAL EXEC relocation.
+ENUM
+  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0
+ENUMDOC
+  AArch64 TLS LOCAL EXEC relocation.
+ENUM
+  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC
+ENUMDOC
+  AArch64 TLS LOCAL EXEC relocation.
+ENUM
+  BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12
+ENUMDOC
+  AArch64 TLS LOCAL EXEC relocation.
+ENUM
+  BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12
+ENUMDOC
+  AArch64 TLS LOCAL EXEC relocation.
+ENUM
+  BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC
+ENUMDOC
+  AArch64 TLS LOCAL EXEC relocation.
+ENUM
+  BFD_RELOC_AARCH64_TLSDESC_LD_PREL19
 ENUMDOC
   AArch64 TLS DESC relocation.
 ENUM
 ENUMDOC
   AArch64 TLS DESC relocation.
 ENUM
-  BFD_RELOC_AARCH64_TLSDESC_CALL
+  BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21
 ENUMDOC
   AArch64 TLS DESC relocation.
 ENUM
 ENUMDOC
   AArch64 TLS DESC relocation.
 ENUM
-  BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC
+  BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21
 ENUMDOC
   AArch64 TLS DESC relocation.
 ENUM
 ENUMDOC
   AArch64 TLS DESC relocation.
 ENUM
-  BFD_RELOC_AARCH64_TLSDESC_LD_PREL19
+  BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC
 ENUMDOC
   AArch64 TLS DESC relocation.
 ENUM
 ENUMDOC
   AArch64 TLS DESC relocation.
 ENUM
-  BFD_RELOC_AARCH64_TLSDESC_LDR
+  BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC
 ENUMDOC
   AArch64 TLS DESC relocation.
 ENUM
 ENUMDOC
   AArch64 TLS DESC relocation.
 ENUM
-  BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC
+  BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC
 ENUMDOC
   AArch64 TLS DESC relocation.
 ENUM
 ENUMDOC
   AArch64 TLS DESC relocation.
 ENUM
@@ -6309,88 +6394,90 @@ ENUM
 ENUMDOC
   AArch64 TLS DESC relocation.
 ENUM
 ENUMDOC
   AArch64 TLS DESC relocation.
 ENUM
-  BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC
+  BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC
 ENUMDOC
 ENUMDOC
-  Unsigned 12 bit byte offset to global offset table entry for a symbols
-  tls_index structure.  Used in conjunction with
-  BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21.
+  AArch64 TLS DESC relocation.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21
+  BFD_RELOC_AARCH64_TLSDESC_LDR
 ENUMDOC
 ENUMDOC
-  Get to the page base of the global offset table entry for a symbols
-  tls_index structure as part of an adrp instruction using a 21 bit PC
-  relative value.  Used in conjunction with
-  BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC.
+  AArch64 TLS DESC relocation.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21
+  BFD_RELOC_AARCH64_TLSDESC_ADD
 ENUMDOC
 ENUMDOC
-  AArch64 TLS INITIAL EXEC relocation.
+  AArch64 TLS DESC relocation.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19
+  BFD_RELOC_AARCH64_TLSDESC_CALL
 ENUMDOC
 ENUMDOC
-  AArch64 TLS INITIAL EXEC relocation.
+  AArch64 TLS DESC relocation.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC
+  BFD_RELOC_AARCH64_COPY
 ENUMDOC
 ENUMDOC
-  AArch64 TLS INITIAL EXEC relocation.
+  AArch64 TLS relocation.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC
+  BFD_RELOC_AARCH64_GLOB_DAT
 ENUMDOC
 ENUMDOC
-  AArch64 TLS INITIAL EXEC relocation.
+  AArch64 TLS relocation.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1
+  BFD_RELOC_AARCH64_JUMP_SLOT
 ENUMDOC
 ENUMDOC
-  AArch64 TLS INITIAL EXEC relocation.
+  AArch64 TLS relocation.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12
+  BFD_RELOC_AARCH64_RELATIVE
 ENUMDOC
 ENUMDOC
-  AArch64 TLS LOCAL EXEC relocation.
+  AArch64 TLS relocation.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12
+  BFD_RELOC_AARCH64_TLS_DTPMOD
 ENUMDOC
 ENUMDOC
-  AArch64 TLS LOCAL EXEC relocation.
+  AArch64 TLS relocation.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC
+  BFD_RELOC_AARCH64_TLS_DTPREL
 ENUMDOC
 ENUMDOC
-  AArch64 TLS LOCAL EXEC relocation.
+  AArch64 TLS relocation.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0
+  BFD_RELOC_AARCH64_TLS_TPREL
 ENUMDOC
 ENUMDOC
-  AArch64 TLS LOCAL EXEC relocation.
+  AArch64 TLS relocation.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC
+  BFD_RELOC_AARCH64_TLSDESC
 ENUMDOC
 ENUMDOC
-  AArch64 TLS LOCAL EXEC relocation.
+  AArch64 TLS relocation.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1
+  BFD_RELOC_AARCH64_IRELATIVE
 ENUMDOC
 ENUMDOC
-  AArch64 TLS LOCAL EXEC relocation.
+  AArch64 support for STT_GNU_IFUNC.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC
+  BFD_RELOC_AARCH64_RELOC_END
 ENUMDOC
 ENUMDOC
-  AArch64 TLS LOCAL EXEC relocation.
+  AArch64 pseudo relocation code to mark the end of the AArch64
+  relocation enumerators that have direct mapping to ELF reloc codes.
+  There are a few more enumerators after this one; those are mainly
+  used by the AArch64 assembler for the internal fixup or to select
+  one of the above enumerators.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2
+  BFD_RELOC_AARCH64_GAS_INTERNAL_FIXUP
 ENUMDOC
 ENUMDOC
-  AArch64 TLS LOCAL EXEC relocation.
+  AArch64 pseudo relocation code to be used internally by the AArch64
+  assembler and not (currently) written to any object files.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLS_DTPMOD64
+  BFD_RELOC_AARCH64_LDST_LO12
 ENUMDOC
 ENUMDOC
-  AArch64 TLS relocation.
+  AArch64 unspecified load/store instruction, holding bits 0 to 11 of the
+  address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLS_DTPREL64
+  BFD_RELOC_AARCH64_LD_GOT_LO12_NC
 ENUMDOC
 ENUMDOC
-  AArch64 TLS relocation.
+  AArch64 pseudo relocation code to be used internally by the AArch64
+  assembler and not (currently) written to any object files.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TLS_TPREL64
+  BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC
 ENUMDOC
 ENUMDOC
-  AArch64 TLS relocation.
+  AArch64 pseudo relocation code to be used internally by the AArch64
+  assembler and not (currently) written to any object files.
 ENUM
 ENUM
-  BFD_RELOC_AARCH64_TSTBR14
+  BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC
 ENUMDOC
 ENUMDOC
-  AArch64 14 bit pc-relative test bit and branch.
-  The lowest two bits must be zero and are not stored in the instruction,
-  giving a 16 bit signed byte offset.
+  AArch64 pseudo relocation code to be used internally by the AArch64
+  assembler and not (currently) written to any object files.
 
 ENUM
   BFD_RELOC_TILEPRO_COPY
 
 ENUM
   BFD_RELOC_TILEPRO_COPY
index 5270688921c25043d40370f106cc1902f5694b8e..d998e3bad88e2155a1ca4a931f0f1350bba28c02 100644 (file)
@@ -1,3 +1,18 @@
+2013-06-26  Yufeng Zhang  <yufeng.zhang@arm.com>
+
+       * config/tc-aarch64.c (reloc_table): Replace
+       BFD_RELOC_AARCH64_LD64_GOT_LO12_NC with
+       BFD_RELOC_AARCH64_LD_GOT_LO12_NC; likewise to
+       BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC and
+       BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC.
+       (md_apply_fix): Handle BFD_RELOC_AARCH64_LD_GOT_LO12_NC,
+       BFD_RELOC_AARCH64_LD32_GOT_LO12_NC,
+       BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC,
+       BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC,
+       BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC and
+       BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC.
+       (aarch64_force_relocation): Likewise.
+
 2013-06-26  Yufeng Zhang  <yufeng.zhang@arm.com>
 
        * config/tc-aarch64.c (ilp32_p): New static variable.
 2013-06-26  Yufeng Zhang  <yufeng.zhang@arm.com>
 
        * config/tc-aarch64.c (ilp32_p): New static variable.
index 239b9eef6140257dd18ee501ba25ed28774cf6be..52811ef3855e3aecdb1555df33ab35c13b2b6b95 100644 (file)
@@ -2377,7 +2377,7 @@ static struct reloc_table_entry reloc_table[] = {
    0,
    0,
    0,
    0,
    0,
    0,
-   BFD_RELOC_AARCH64_LD64_GOT_LO12_NC},
+   BFD_RELOC_AARCH64_LD_GOT_LO12_NC},
 
   /* Get to the page containing GOT TLS entry for a symbol */
   {"tlsgd", 0,
 
   /* Get to the page containing GOT TLS entry for a symbol */
   {"tlsgd", 0,
@@ -2405,7 +2405,7 @@ static struct reloc_table_entry reloc_table[] = {
    0,
    0,
    BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC,
    0,
    0,
    BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC,
-   BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC},
+   BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC},
 
   /* Get to the page containing GOT TLS entry for a symbol */
   {"gottprel", 0,
 
   /* Get to the page containing GOT TLS entry for a symbol */
   {"gottprel", 0,
@@ -2419,7 +2419,7 @@ static struct reloc_table_entry reloc_table[] = {
    0,
    0,
    0,
    0,
    0,
    0,
-   BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC},
+   BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC},
 
   /* Get tp offset for a symbol.  */
   {"tprel", 0,
 
   /* Get tp offset for a symbol.  */
   {"tprel", 0,
@@ -6506,10 +6506,33 @@ md_apply_fix (fixS * fixP, valueT * valP, segT seg)
        }
       break;
 
        }
       break;
 
+    case BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC:
+      fixP->fx_r_type = (ilp32_p
+                        ? BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC
+                        : BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC);
+      S_SET_THREAD_LOCAL (fixP->fx_addsy);
+      /* Should always be exported to object file, see
+        aarch64_force_relocation().  */
+      gas_assert (!fixP->fx_done);
+      gas_assert (seg->use_rela_p);
+      break;
+
+    case BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC:
+      fixP->fx_r_type = (ilp32_p
+                        ? BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC
+                        : BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC);
+      S_SET_THREAD_LOCAL (fixP->fx_addsy);
+      /* Should always be exported to object file, see
+        aarch64_force_relocation().  */
+      gas_assert (!fixP->fx_done);
+      gas_assert (seg->use_rela_p);
+      break;
+
     case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
     case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
     case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
     case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
     case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
     case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
     case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
     case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC:
     case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12:
     case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12:
     case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
     case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12:
     case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12:
     case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
@@ -6521,6 +6544,7 @@ md_apply_fix (fixS * fixP, valueT * valP, segT seg)
     case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
     case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
     case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC:
     case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
     case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
     case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC:
       S_SET_THREAD_LOCAL (fixP->fx_addsy);
       /* Should always be exported to object file, see
         aarch64_force_relocation().  */
       S_SET_THREAD_LOCAL (fixP->fx_addsy);
       /* Should always be exported to object file, see
         aarch64_force_relocation().  */
@@ -6528,6 +6552,16 @@ md_apply_fix (fixS * fixP, valueT * valP, segT seg)
       gas_assert (seg->use_rela_p);
       break;
 
       gas_assert (seg->use_rela_p);
       break;
 
+    case BFD_RELOC_AARCH64_LD_GOT_LO12_NC:
+      /* Should always be exported to object file, see
+        aarch64_force_relocation().  */
+      fixP->fx_r_type = (ilp32_p
+                        ? BFD_RELOC_AARCH64_LD32_GOT_LO12_NC
+                        : BFD_RELOC_AARCH64_LD64_GOT_LO12_NC);
+      gas_assert (!fixP->fx_done);
+      gas_assert (seg->use_rela_p);
+      break;
+
     case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
     case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
     case BFD_RELOC_AARCH64_ADD_LO12:
     case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
     case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
     case BFD_RELOC_AARCH64_ADD_LO12:
@@ -6539,6 +6573,7 @@ md_apply_fix (fixS * fixP, valueT * valP, segT seg)
     case BFD_RELOC_AARCH64_GOT_LD_PREL19:
     case BFD_RELOC_AARCH64_ADR_GOT_PAGE:
     case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
     case BFD_RELOC_AARCH64_GOT_LD_PREL19:
     case BFD_RELOC_AARCH64_ADR_GOT_PAGE:
     case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
+    case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC:
       /* Should always be exported to object file, see
         aarch64_force_relocation().  */
       gas_assert (!fixP->fx_done);
       /* Should always be exported to object file, see
         aarch64_force_relocation().  */
       gas_assert (!fixP->fx_done);
@@ -6669,10 +6704,18 @@ aarch64_force_relocation (struct fix *fixp)
          even if the symbol is extern or weak.  */
       return 0;
 
          even if the symbol is extern or weak.  */
       return 0;
 
+    case BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC:
+    case BFD_RELOC_AARCH64_LD_GOT_LO12_NC:
+      /* Pseudo relocs that need to be fixed up according to
+        ilp32_p.  */
+      return 0;
+
     case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
     case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
     case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
     case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
     case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
     case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
     case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
     case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC:
     case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12:
     case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12:
     case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
     case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12:
     case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12:
     case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
@@ -6684,8 +6727,10 @@ aarch64_force_relocation (struct fix *fixp)
     case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
     case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
     case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC:
     case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
     case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
     case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC:
     case BFD_RELOC_AARCH64_ADR_GOT_PAGE:
     case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
     case BFD_RELOC_AARCH64_ADR_GOT_PAGE:
     case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
+    case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC:
     case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
     case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
     case BFD_RELOC_AARCH64_ADD_LO12:
     case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
     case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
     case BFD_RELOC_AARCH64_ADD_LO12:
index 6a31de76d8bd03dc03a4129e9350ae97b59c6a61..e309d0ea0bafed26e806dece96f42315e11d63f7 100644 (file)
@@ -1,3 +1,8 @@
+2013-06-26  Yufeng Zhang  <yufeng.zhang@arm.com>
+
+       * gas/aarch64/ilp32-basic.d: New file.
+       * gas/aarch64/ilp32-basic.s: New file.
+
 2013-06-25  Maciej W. Rozycki  <macro@codesourcery.com>
 
        * gas/mips/micromips-insn32.d: New test.
 2013-06-25  Maciej W. Rozycki  <macro@codesourcery.com>
 
        * gas/mips/micromips-insn32.d: New test.
diff --git a/gas/testsuite/gas/aarch64/ilp32-basic.d b/gas/testsuite/gas/aarch64/ilp32-basic.d
new file mode 100644 (file)
index 0000000..b876c7a
--- /dev/null
@@ -0,0 +1,23 @@
+#as: -milp32
+#objdump: -dr
+
+.*:     file format elf32-.*aarch64
+
+
+Disassembly of section \.text:
+
+00000000 <.*>:
+   0:  90000004        adrp    x4, c <.*>
+                       0: R_AARCH64_P32_ADR_PREL_PG_HI21       ptrs
+   4:  91000083        add     x3, x4, #0x0
+                       4: R_AARCH64_P32_ADD_ABS_LO12_NC        ptrs
+   8:  b9000080        str     w0, \[x4\]
+                       8: R_AARCH64_P32_LDST32_ABS_LO12_NC     ptrs
+   c:  b9000461        str     w1, \[x3,#4\]
+  10:  b9000862        str     w2, \[x3,#8\]
+  14:  90000004        adrp    x4, c <.*>
+                       14: R_AARCH64_P32_ADR_GOT_PAGE  ptrs
+  18:  f9400083        ldr     x3, \[x4\]
+                       18: R_AARCH64_P32_LD32_GOT_LO12_NC      ptrs
+  1c:  2a0403e0        mov     w0, w4
+  20:  d65f03c0        ret
diff --git a/gas/testsuite/gas/aarch64/ilp32-basic.s b/gas/testsuite/gas/aarch64/ilp32-basic.s
new file mode 100644 (file)
index 0000000..790dcdf
--- /dev/null
@@ -0,0 +1,17 @@
+       .cpu generic
+       .text
+       .align  2
+       .global foo
+       .type   foo, %function
+foo:
+       adrp    x4, ptrs
+       add     x3, x4, :lo12:ptrs
+       str     w0, [x4,#:lo12:ptrs]
+       str     w1, [x3,4]
+       str     w2, [x3,8]
+       adrp    x4, :got:ptrs
+       ldr     x3, [x4,#:got_lo12:ptrs]
+       mov     w0, w4
+       ret
+       .size   foo, .-foo
+       .comm   ptrs,12,8
index 20ba2297ed6d8a437225910da6ff62a391d015cc..673250dc2f2b90b2853362d55ab85549063aaa81 100644 (file)
@@ -1,3 +1,7 @@
+2013-06-26  Yufeng Zhang  <yufeng.zhang@arm.com>
+
+       * aarch64.h: Add ELF32 reloc codes and remove fake ELF64 ones.
+
 2013-06-24  Maciej W. Rozycki  <macro@codesourcery.com>
 
        * mips.h (ELF_ST_IS_MIPS_PLT): Respect STO_MIPS16 setting.
 2013-06-24  Maciej W. Rozycki  <macro@codesourcery.com>
 
        * mips.h (ELF_ST_IS_MIPS_PLT): Respect STO_MIPS16 setting.
index a7b86c10ed8f00e3b73c2e286b5399a472d0c809..41016038f166378e57661ed31a657a941a4855a7 100644 (file)
@@ -43,7 +43,126 @@ START_RELOC_NUMBERS (elf_aarch64_reloc_type)
 /* Null relocations.  */
 RELOC_NUMBER (R_AARCH64_NONE, 0) /* No reloc */
 
 /* Null relocations.  */
 RELOC_NUMBER (R_AARCH64_NONE, 0) /* No reloc */
 
-FAKE_RELOC (R_AARCH64_static_min, 256)
+/* Basic data relocations.  */
+
+/* .word:  (S+A) */
+RELOC_NUMBER (R_AARCH64_P32_ABS32, 1)
+
+/* .half: (S+A) */
+RELOC_NUMBER (R_AARCH64_P32_ABS16, 2)
+
+/* .word: (S+A-P) */
+RELOC_NUMBER (R_AARCH64_P32_PREL32, 3)
+
+/* .half:  (S+A-P) */
+RELOC_NUMBER (R_AARCH64_P32_PREL16, 4)
+
+/* Group relocations to create a 16, 32, 48 or 64 bit
+   unsigned data or abs address inline.  */
+
+/* MOV[ZK]:   ((S+A) >>  0) & 0xffff */
+RELOC_NUMBER (R_AARCH64_P32_MOVW_UABS_G0, 5)
+
+/* MOV[ZK]:   ((S+A) >>  0) & 0xffff */
+RELOC_NUMBER (R_AARCH64_P32_MOVW_UABS_G0_NC, 6)
+
+/* MOV[ZK]:   ((S+A) >> 16) & 0xffff */
+RELOC_NUMBER (R_AARCH64_P32_MOVW_UABS_G1, 7)
+
+/* Group relocations to create high part of a 16, 32, 48 or 64 bit
+   signed data or abs address inline. Will change instruction
+   to MOVN or MOVZ depending on sign of calculated value.  */
+
+/* MOV[ZN]:   ((S+A) >>  0) & 0xffff */
+RELOC_NUMBER (R_AARCH64_P32_MOVW_SABS_G0, 8)
+
+/* Relocations to generate 19, 21 and 33 bit PC-relative load/store
+   addresses: PG(x) is (x & ~0xfff).  */
+
+/* LD-lit: ((S+A-P) >> 2) & 0x7ffff */
+RELOC_NUMBER (R_AARCH64_P32_LD_PREL_LO19, 9)
+
+/* ADR:    (S+A-P) & 0x1fffff */
+RELOC_NUMBER (R_AARCH64_P32_ADR_PREL_LO21, 10)
+
+/* ADRH:   ((PG(S+A)-PG(P)) >> 12) & 0x1fffff */
+RELOC_NUMBER (R_AARCH64_P32_ADR_PREL_PG_HI21, 11)
+
+/* ADD:    (S+A) & 0xfff */
+RELOC_NUMBER (R_AARCH64_P32_ADD_ABS_LO12_NC, 12)
+
+/* LD/ST8: (S+A) & 0xfff */
+RELOC_NUMBER (R_AARCH64_P32_LDST8_ABS_LO12_NC, 13)
+
+/* LD/ST16: (S+A) & 0xffe */
+RELOC_NUMBER (R_AARCH64_P32_LDST16_ABS_LO12_NC, 14)
+
+/* LD/ST32: (S+A) & 0xffc */
+RELOC_NUMBER (R_AARCH64_P32_LDST32_ABS_LO12_NC, 15)
+
+/* LD/ST64: (S+A) & 0xff8 */
+RELOC_NUMBER (R_AARCH64_P32_LDST64_ABS_LO12_NC, 16)
+
+/* LD/ST128: (S+A) & 0xff0 */
+RELOC_NUMBER (R_AARCH64_P32_LDST128_ABS_LO12_NC, 17)
+
+/* Relocations for control-flow instructions.  */
+
+/* TBZ/NZ: ((S+A-P) >> 2) & 0x3fff.  */
+RELOC_NUMBER (R_AARCH64_P32_TSTBR14, 18)
+
+/* B.cond: ((S+A-P) >> 2) & 0x7ffff.  */
+RELOC_NUMBER (R_AARCH64_P32_CONDBR19, 19)
+
+/* B:      ((S+A-P) >> 2) & 0x3ffffff.  */
+RELOC_NUMBER (R_AARCH64_P32_JUMP26, 20)
+
+/* BL:     ((S+A-P) >> 2) & 0x3ffffff.  */
+RELOC_NUMBER (R_AARCH64_P32_CALL26, 21)
+
+
+RELOC_NUMBER (R_AARCH64_P32_GOT_LD_PREL19, 25)
+RELOC_NUMBER (R_AARCH64_P32_ADR_GOT_PAGE, 26)
+RELOC_NUMBER (R_AARCH64_P32_LD32_GOT_LO12_NC, 27)
+
+
+RELOC_NUMBER (R_AARCH64_P32_TLSGD_ADR_PAGE21, 81)
+RELOC_NUMBER (R_AARCH64_P32_TLSGD_ADD_LO12_NC, 82)
+RELOC_NUMBER (R_AARCH64_P32_TLSIE_ADR_GOTTPREL_PAGE21, 103)
+RELOC_NUMBER (R_AARCH64_P32_TLSIE_LD32_GOTTPREL_LO12_NC, 104)
+RELOC_NUMBER (R_AARCH64_P32_TLSIE_LD_GOTTPREL_PREL19, 105)
+RELOC_NUMBER (R_AARCH64_P32_TLSLE_MOVW_TPREL_G1, 106)
+RELOC_NUMBER (R_AARCH64_P32_TLSLE_MOVW_TPREL_G0, 107)
+RELOC_NUMBER (R_AARCH64_P32_TLSLE_MOVW_TPREL_G0_NC, 108)
+RELOC_NUMBER (R_AARCH64_P32_TLSLE_ADD_TPREL_HI12, 109)
+RELOC_NUMBER (R_AARCH64_P32_TLSLE_ADD_TPREL_LO12, 110)
+RELOC_NUMBER (R_AARCH64_P32_TLSLE_ADD_TPREL_LO12_NC, 111)
+
+RELOC_NUMBER (R_AARCH64_P32_TLSDESC_LD_PREL19, 122)
+RELOC_NUMBER (R_AARCH64_P32_TLSDESC_ADR_PREL21, 123)
+RELOC_NUMBER (R_AARCH64_P32_TLSDESC_ADR_PAGE21, 124)
+RELOC_NUMBER (R_AARCH64_P32_TLSDESC_LD32_LO12_NC, 125)
+RELOC_NUMBER (R_AARCH64_P32_TLSDESC_ADD_LO12_NC, 126)
+RELOC_NUMBER (R_AARCH64_P32_TLSDESC_CALL, 127)
+
+/* Dynamic relocations */
+
+/* Copy symbol at runtime.  */
+RELOC_NUMBER (R_AARCH64_P32_COPY, 180)
+
+/* Create GOT entry.  */
+RELOC_NUMBER (R_AARCH64_P32_GLOB_DAT, 181)
+
+ /* Create PLT entry.  */
+RELOC_NUMBER (R_AARCH64_P32_JUMP_SLOT, 182)
+
+/* Adjust by program base.  */
+RELOC_NUMBER (R_AARCH64_P32_RELATIVE, 183)
+RELOC_NUMBER (R_AARCH64_P32_TLS_DTPMOD, 184)
+RELOC_NUMBER (R_AARCH64_P32_TLS_DTPREL, 185)
+RELOC_NUMBER (R_AARCH64_P32_TLS_TPREL, 186)
+RELOC_NUMBER (R_AARCH64_P32_TLSDESC, 187)
+RELOC_NUMBER (R_AARCH64_P32_IRELATIVE, 188)
 
 RELOC_NUMBER (R_AARCH64_NULL, 256) /* No reloc */
 
 
 RELOC_NUMBER (R_AARCH64_NULL, 256) /* No reloc */
 
@@ -157,9 +276,6 @@ RELOC_NUMBER (R_AARCH64_GOT_LD_PREL19, 309)
 RELOC_NUMBER (R_AARCH64_ADR_GOT_PAGE, 311)
 RELOC_NUMBER (R_AARCH64_LD64_GOT_LO12_NC, 312)
 
 RELOC_NUMBER (R_AARCH64_ADR_GOT_PAGE, 311)
 RELOC_NUMBER (R_AARCH64_LD64_GOT_LO12_NC, 312)
 
-FAKE_RELOC (R_AARCH64_static_max, 313)
-
-FAKE_RELOC (R_AARCH64_tls_min, 512)
 RELOC_NUMBER (R_AARCH64_TLSGD_ADR_PAGE21, 513)
 RELOC_NUMBER (R_AARCH64_TLSGD_ADD_LO12_NC, 514)
 RELOC_NUMBER (R_AARCH64_TLSIE_MOVW_GOTTPREL_G1, 539)
 RELOC_NUMBER (R_AARCH64_TLSGD_ADR_PAGE21, 513)
 RELOC_NUMBER (R_AARCH64_TLSGD_ADD_LO12_NC, 514)
 RELOC_NUMBER (R_AARCH64_TLSIE_MOVW_GOTTPREL_G1, 539)
@@ -175,9 +291,7 @@ RELOC_NUMBER (R_AARCH64_TLSLE_MOVW_TPREL_G0_NC, 548)
 RELOC_NUMBER (R_AARCH64_TLSLE_ADD_TPREL_HI12, 549)
 RELOC_NUMBER (R_AARCH64_TLSLE_ADD_TPREL_LO12, 550)
 RELOC_NUMBER (R_AARCH64_TLSLE_ADD_TPREL_LO12_NC, 551)
 RELOC_NUMBER (R_AARCH64_TLSLE_ADD_TPREL_HI12, 549)
 RELOC_NUMBER (R_AARCH64_TLSLE_ADD_TPREL_LO12, 550)
 RELOC_NUMBER (R_AARCH64_TLSLE_ADD_TPREL_LO12_NC, 551)
-FAKE_RELOC (R_AARCH64_tls_max, 552)
 
 
-FAKE_RELOC (R_AARCH64_tlsdesc_min, 560)
 RELOC_NUMBER (R_AARCH64_TLSDESC_LD_PREL19, 560)
 RELOC_NUMBER (R_AARCH64_TLSDESC_ADR_PREL21, 561)
 RELOC_NUMBER (R_AARCH64_TLSDESC_ADR_PAGE21, 562)
 RELOC_NUMBER (R_AARCH64_TLSDESC_LD_PREL19, 560)
 RELOC_NUMBER (R_AARCH64_TLSDESC_ADR_PREL21, 561)
 RELOC_NUMBER (R_AARCH64_TLSDESC_ADR_PAGE21, 562)
@@ -188,10 +302,8 @@ RELOC_NUMBER (R_AARCH64_TLSDESC_OFF_G0_NC, 566)
 RELOC_NUMBER (R_AARCH64_TLSDESC_LDR, 567)
 RELOC_NUMBER (R_AARCH64_TLSDESC_ADD, 568)
 RELOC_NUMBER (R_AARCH64_TLSDESC_CALL, 569)
 RELOC_NUMBER (R_AARCH64_TLSDESC_LDR, 567)
 RELOC_NUMBER (R_AARCH64_TLSDESC_ADD, 568)
 RELOC_NUMBER (R_AARCH64_TLSDESC_CALL, 569)
-FAKE_RELOC (R_AARCH64_tlsdesc_max, 570)
 
 /* Dynamic relocations */
 
 /* Dynamic relocations */
-FAKE_RELOC (R_AARCH64_dyn_min, 1024)
 
 /* Copy symbol at runtime.  */
 RELOC_NUMBER (R_AARCH64_COPY, 1024)
 
 /* Copy symbol at runtime.  */
 RELOC_NUMBER (R_AARCH64_COPY, 1024)
@@ -204,11 +316,11 @@ RELOC_NUMBER (R_AARCH64_JUMP_SLOT, 1026)
 
 /* Adjust by program base.  */
 RELOC_NUMBER (R_AARCH64_RELATIVE, 1027)
 
 /* Adjust by program base.  */
 RELOC_NUMBER (R_AARCH64_RELATIVE, 1027)
-RELOC_NUMBER (R_AARCH64_TLS_DTPMOD64, 1028)
-RELOC_NUMBER (R_AARCH64_TLS_DTPREL64, 1029)
-RELOC_NUMBER (R_AARCH64_TLS_TPREL64, 1030)
+RELOC_NUMBER (R_AARCH64_TLS_DTPMOD, 1028)
+RELOC_NUMBER (R_AARCH64_TLS_DTPREL, 1029)
+RELOC_NUMBER (R_AARCH64_TLS_TPREL, 1030)
 RELOC_NUMBER (R_AARCH64_TLSDESC, 1031)
 RELOC_NUMBER (R_AARCH64_TLSDESC, 1031)
-FAKE_RELOC (R_AARCH64_dyn_max, 1032)
+RELOC_NUMBER (R_AARCH64_IRELATIVE, 1032)
 
 END_RELOC_NUMBERS (R_AARCH64_end)
 
 
 END_RELOC_NUMBERS (R_AARCH64_end)
 
This page took 0.096579 seconds and 4 git commands to generate.