gdbarch.sh: Remove commented out TARGET_CHAR_BIT definition
[deliverable/binutils-gdb.git] / bfd / elfnn-aarch64.c
index 6ea2d355d412ec5cbbfa7aba3f1cc72926ebee5e..00f19e930dde1cd64cbce08de9207826af1d131a 100644 (file)
 #define HOWTO64(...)           HOWTO (__VA_ARGS__)
 #define HOWTO32(...)           EMPTY_HOWTO (0)
 #define LOG_FILE_ALIGN 3
+#define BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC BFD_RELOC_AARCH64_TLSDESC_LD64_LO12
 #endif
 
 #if ARCH_SIZE == 32
 #define HOWTO64(...)           EMPTY_HOWTO (0)
 #define HOWTO32(...)           HOWTO (__VA_ARGS__)
 #define LOG_FILE_ALIGN 2
+#define BFD_RELOC_AARCH64_TLSDESC_LD32_LO12     BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC
+#define R_AARCH64_P32_TLSDESC_ADD_LO12          R_AARCH64_P32_TLSDESC_ADD_LO12_NC
 #endif
 
 #define IS_AARCH64_TLS_RELOC(R_TYPE)                           \
    || IS_AARCH64_TLSDESC_RELOC ((R_TYPE)))
 
 #define IS_AARCH64_TLS_RELAX_RELOC(R_TYPE)                     \
-  ((R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_ADD           \
-   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC                \
+  ((R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_ADD                   \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_ADD_LO12           \
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21         \
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21         \
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_CALL               \
 #define IS_AARCH64_TLSDESC_RELOC(R_TYPE)                       \
   ((R_TYPE) == BFD_RELOC_AARCH64_TLSDESC                       \
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_ADD                        \
-   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC                \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_ADD_LO12           \
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21         \
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21         \
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_CALL               \
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC       \
-   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC       \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_LD64_LO12          \
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_LDR                        \
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_LD_PREL19          \
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC          \
 #define PLT_SMALL_ENTRY_SIZE            (16)
 #define PLT_TLSDESC_ENTRY_SIZE          (32)
 
-/* Encoding of the nop instruction */
+/* Encoding of the nop instruction */
 #define INSN_NOP 0xd503201f
 
 #define aarch64_compute_jump_table_size(htab)          \
@@ -1569,7 +1572,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
         TRUE),                 /* pcrel_offset */
 
   /* LD64: GOT offset G(S) & 0xff8.  */
-  HOWTO64 (AARCH64_R (TLSDESC_LD64_LO12_NC),   /* type */
+  HOWTO64 (AARCH64_R (TLSDESC_LD64_LO12),      /* type */
         3,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
@@ -1577,7 +1580,7 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
         0,                     /* bitpos */
         complain_overflow_dont,        /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        AARCH64_R_STR (TLSDESC_LD64_LO12_NC),  /* name */
+        AARCH64_R_STR (TLSDESC_LD64_LO12),     /* name */
         FALSE,                 /* partial_inplace */
         0xff8,                 /* src_mask */
         0xff8,                 /* dst_mask */
@@ -1599,15 +1602,15 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
         FALSE),                /* pcrel_offset */
 
   /* ADD: GOT offset G(S) & 0xfff.  */
-  HOWTO (AARCH64_R (TLSDESC_ADD_LO12_NC),      /* type */
+  HOWTO (AARCH64_R (TLSDESC_ADD_LO12), /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
         FALSE,                 /* pc_relative */
         0,                     /* bitpos */
-        complain_overflow_dont,        /* complain_on_overflow */
+        complain_overflow_dont,/* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
-        AARCH64_R_STR (TLSDESC_ADD_LO12_NC),   /* name */
+        AARCH64_R_STR (TLSDESC_ADD_LO12),      /* name */
         FALSE,                 /* partial_inplace */
         0xfff,                 /* src_mask */
         0xfff,                 /* dst_mask */
@@ -2708,6 +2711,22 @@ elfNN_aarch64_stub_name (const asection *input_section,
   return stub_name;
 }
 
+/* Return TRUE if symbol H should be hashed in the `.gnu.hash' section.  For
+   executable PLT slots where the executable never takes the address of those
+   functions, the function symbols are not added to the hash table.  */
+
+static bfd_boolean
+elf_aarch64_hash_symbol (struct elf_link_hash_entry *h)
+{
+  if (h->plt.offset != (bfd_vma) -1
+      && !h->def_regular
+      && !h->pointer_equality_needed)
+    return FALSE;
+
+  return _bfd_elf_hash_symbol (h);
+}
+
+
 /* Look up an entry in the stub hash.  Stub entries are cached because
    creating the stub name takes a bit of time.  */
 
@@ -2830,7 +2849,7 @@ _bfd_aarch64_add_stub_entry_in_group (const char *stub_name,
   if (stub_entry == NULL)
     {
       /* xgettext:c-format */
-      _bfd_error_handler (_("%s: cannot create stub entry %s"),
+      _bfd_error_handler (_("%B: cannot create stub entry %s"),
                          section->owner, stub_name);
       return NULL;
     }
@@ -3250,9 +3269,7 @@ group_sections (struct elf_aarch64_link_hash_table *htab,
    For scalar LD/ST instructions PAIR is FALSE, RT is returned and RT2
    is set equal to RT.
 
-   For LD/ST pair instructions PAIR is TRUE, RT and RT2 are returned.
-
- */
+   For LD/ST pair instructions PAIR is TRUE, RT and RT2 are returned.  */
 
 static bfd_boolean
 aarch64_mem_op_p (uint32_t insn, unsigned int *rt, unsigned int *rt2,
@@ -4460,7 +4477,7 @@ aarch64_tls_transition_without_check (bfd_reloc_code_real_type r_type,
              : BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19);
 
     case BFD_RELOC_AARCH64_TLSDESC_ADD:
-    case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12:
     case BFD_RELOC_AARCH64_TLSDESC_CALL:
       /* Instructions with these relocations will become NOPs.  */
       return BFD_RELOC_AARCH64_NONE;
@@ -4516,12 +4533,12 @@ aarch64_reloc_got_type (bfd_reloc_code_real_type r_type)
       return GOT_TLS_GD;
 
     case BFD_RELOC_AARCH64_TLSDESC_ADD:
-    case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12:
     case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
     case BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21:
     case BFD_RELOC_AARCH64_TLSDESC_CALL:
     case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC:
-    case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12:
     case BFD_RELOC_AARCH64_TLSDESC_LD_PREL19:
     case BFD_RELOC_AARCH64_TLSDESC_LDR:
     case BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC:
@@ -5563,11 +5580,11 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
       *unresolved_reloc_p = FALSE;
       break;
 
-    case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12:
     case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
     case BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21:
     case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC:
-    case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12:
     case BFD_RELOC_AARCH64_TLSDESC_LD_PREL19:
       if (globals->root.sgot == NULL)
        return bfd_reloc_notsupported;
@@ -5614,6 +5631,35 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
                                      howto, value);
 }
 
+/* LP64 and ILP32 operates on x- and w-registers respectively.
+   Next definitions take into account the difference between
+   corresponding machine codes. R means x-register if the target
+   arch is LP64, and w-register if the target is ILP32.  */
+
+#if ARCH_SIZE == 64
+# define add_R0_R0     (0x91000000)
+# define add_R0_R0_R1  (0x8b000020)
+# define add_R0_R1     (0x91400020)
+# define ldr_R0                (0x58000000)
+# define ldr_R0_mask(i)        (i & 0xffffffe0)
+# define ldr_R0_x0     (0xf9400000)
+# define ldr_hw_R0     (0xf2a00000)
+# define movk_R0       (0xf2800000)
+# define movz_R0       (0xd2a00000)
+# define movz_hw_R0    (0xd2c00000)
+#else /*ARCH_SIZE == 32 */
+# define add_R0_R0     (0x11000000)
+# define add_R0_R0_R1  (0x0b000020)
+# define add_R0_R1     (0x11400020)
+# define ldr_R0                (0x18000000)
+# define ldr_R0_mask(i)        (i & 0xbfffffe0)
+# define ldr_R0_x0     (0xb9400000)
+# define ldr_hw_R0     (0x72a00000)
+# define movk_R0       (0x72800000)
+# define movz_R0       (0x52a00000)
+# define movz_hw_R0    (0x52c00000)
+#endif
+
 /* Handle TLS relaxations.  Relaxing is possible for symbols that use
    R_AARCH64_TLSDESC_ADR_{PAGE, LD64_LO12_NC, ADD_LO12_NC} during a static
    link.
@@ -5640,11 +5686,12 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
       if (is_local)
        {
          /* GD->LE relaxation:
-            adrp x0, :tlsgd:var     =>   movz x0, :tprel_g1:var
+            adrp x0, :tlsgd:var     =>   movz R0, :tprel_g1:var
             or
-            adrp x0, :tlsdesc:var   =>   movz x0, :tprel_g1:var
-          */
-         bfd_putl32 (0xd2a00000, contents + rel->r_offset);
+            adrp x0, :tlsdesc:var   =>   movz R0, :tprel_g1:var
+
+            Where R is x for LP64, and w for ILP32.  */
+         bfd_putl32 (movz_R0, contents + rel->r_offset);
          return bfd_reloc_continue;
        }
       else
@@ -5665,11 +5712,12 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
       if (is_local)
        {
          /* Tiny TLSDESC->LE relaxation:
-            ldr   x1, :tlsdesc:var      =>  movz  x0, #:tprel_g1:var
-            adr   x0, :tlsdesc:var      =>  movk  x0, #:tprel_g0_nc:var
+            ldr   x1, :tlsdesc:var      =>  movz  R0, #:tprel_g1:var
+            adr   x0, :tlsdesc:var      =>  movk  R0, #:tprel_g0_nc:var
             .tlsdesccall var
             blr   x1                    =>  nop
-          */
+
+            Where R is x for LP64, and w for ILP32.  */
          BFD_ASSERT (ELFNN_R_TYPE (rel[1].r_info) == AARCH64_R (TLSDESC_ADR_PREL21));
          BFD_ASSERT (ELFNN_R_TYPE (rel[2].r_info) == AARCH64_R (TLSDESC_CALL));
 
@@ -5677,8 +5725,8 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
                                        AARCH64_R (TLSLE_MOVW_TPREL_G0_NC));
          rel[2].r_info = ELFNN_R_INFO (STN_UNDEF, R_AARCH64_NONE);
 
-         bfd_putl32 (0xd2a00000, contents + rel->r_offset);
-         bfd_putl32 (0xf2800000, contents + rel->r_offset + 4);
+         bfd_putl32 (movz_R0, contents + rel->r_offset);
+         bfd_putl32 (movk_R0, contents + rel->r_offset + 4);
          bfd_putl32 (INSN_NOP, contents + rel->r_offset + 8);
          return bfd_reloc_continue;
        }
@@ -5696,7 +5744,7 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
          rel[1].r_info = ELFNN_R_INFO (STN_UNDEF, R_AARCH64_NONE);
          rel[2].r_info = ELFNN_R_INFO (STN_UNDEF, R_AARCH64_NONE);
 
-         bfd_putl32 (0x58000000, contents + rel->r_offset);
+         bfd_putl32 (ldr_R0, contents + rel->r_offset);
          bfd_putl32 (INSN_NOP, contents + rel->r_offset + 4);
          bfd_putl32 (INSN_NOP, contents + rel->r_offset + 8);
          return bfd_reloc_continue;
@@ -5707,16 +5755,17 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
        {
          /* Tiny GD->LE relaxation:
             adr x0, :tlsgd:var      =>   mrs  x1, tpidr_el0
-             bl   __tls_get_addr     =>   add  x0, x1, #:tprel_hi12:x, lsl #12
-             nop                     =>   add  x0, x0, #:tprel_lo12_nc:x
-          */
+             bl   __tls_get_addr     =>   add  R0, R1, #:tprel_hi12:x, lsl #12
+             nop                     =>   add  R0, R0, #:tprel_lo12_nc:x
+
+            Where R is x for LP64, and x for Ilp32.  */
 
          /* First kill the tls_get_addr reloc on the bl instruction.  */
          BFD_ASSERT (rel->r_offset + 4 == rel[1].r_offset);
 
          bfd_putl32 (0xd53bd041, contents + rel->r_offset + 0);
-         bfd_putl32 (0x91400020, contents + rel->r_offset + 4);
-         bfd_putl32 (0x91000000, contents + rel->r_offset + 8);
+         bfd_putl32 (add_R0_R1, contents + rel->r_offset + 4);
+         bfd_putl32 (add_R0_R0, contents + rel->r_offset + 8);
 
          rel[1].r_info = ELFNN_R_INFO (ELFNN_R_SYM (rel->r_info),
                                        AARCH64_R (TLSLE_ADD_TPREL_LO12_NC));
@@ -5732,18 +5781,19 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
       else
        {
          /* Tiny GD->IE relaxation:
-            adr x0, :tlsgd:var      =>   ldr  x0, :gottprel:var
+            adr x0, :tlsgd:var      =>   ldr  R0, :gottprel:var
             bl   __tls_get_addr     =>   mrs  x1, tpidr_el0
-            nop                     =>   add  x0, x0, x1
-          */
+            nop                     =>   add  R0, R0, R1
+
+            Where R is x for LP64, and w for Ilp32.  */
 
          /* First kill the tls_get_addr reloc on the bl instruction.  */
          BFD_ASSERT (rel->r_offset + 4 == rel[1].r_offset);
          rel[1].r_info = ELFNN_R_INFO (STN_UNDEF, R_AARCH64_NONE);
 
-         bfd_putl32 (0x58000000, contents + rel->r_offset);
+         bfd_putl32 (ldr_R0, contents + rel->r_offset);
          bfd_putl32 (0xd53bd041, contents + rel->r_offset + 4);
-         bfd_putl32 (0x8b000020, contents + rel->r_offset + 8);
+         bfd_putl32 (add_R0_R0_R1, contents + rel->r_offset + 8);
          return bfd_reloc_continue;
        }
 
@@ -5766,11 +5816,11 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
                                        AARCH64_R (TLSLE_MOVW_TPREL_G0_NC));
          rel[2].r_offset = rel->r_offset + 8;
 
-         bfd_putl32 (0xd2c00000, contents + rel->r_offset + 0);
-         bfd_putl32 (0xf2a00000, contents + rel->r_offset + 4);
-         bfd_putl32 (0xf2800000, contents + rel->r_offset + 8);
+         bfd_putl32 (movz_hw_R0, contents + rel->r_offset + 0);
+         bfd_putl32 (ldr_hw_R0, contents + rel->r_offset + 4);
+         bfd_putl32 (movk_R0, contents + rel->r_offset + 8);
          bfd_putl32 (0xd53bd041, contents + rel->r_offset + 12);
-         bfd_putl32 (0x8b000020, contents + rel->r_offset + 16);
+         bfd_putl32 (add_R0_R0_R1, contents + rel->r_offset + 16);
        }
       else
        {
@@ -5783,9 +5833,9 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
           */
          rel[2].r_info = ELFNN_R_INFO (STN_UNDEF, R_AARCH64_NONE);
          bfd_putl32 (0xd2a80000, contents + rel->r_offset + 0);
-         bfd_putl32 (0x58000000, contents + rel->r_offset + 8);
+         bfd_putl32 (ldr_R0, contents + rel->r_offset + 8);
          bfd_putl32 (0xd53bd041, contents + rel->r_offset + 12);
-         bfd_putl32 (0x8b000020, contents + rel->r_offset + 16);
+         bfd_putl32 (add_R0_R0_R1, contents + rel->r_offset + 16);
        }
       return bfd_reloc_continue;
 
@@ -5801,18 +5851,19 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
        {
          /* GD->LE relaxation:
             ldr xd, [x0, #:tlsdesc_lo12:var]   =>   movk x0, :tprel_g0_nc:var
-          */
-         bfd_putl32 (0xf2800000, contents + rel->r_offset);
+
+            Where R is x for lp64 mode, and w for ILP32 mode.  */
+         bfd_putl32 (movk_R0, contents + rel->r_offset);
          return bfd_reloc_continue;
        }
       else
        {
          /* GD->IE relaxation:
-            ldr xd, [x0, #:tlsdesc_lo12:var] => ldr x0, [x0, #:gottprel_lo12:var]
-          */
+            ldr xd, [x0, #:tlsdesc_lo12:var] => ldr R0, [x0, #:gottprel_lo12:var]
+
+            Where R is x for lp64 mode, and w for ILP32 mode.  */
          insn = bfd_getl32 (contents + rel->r_offset);
-         insn &= 0xffffffe0;
-         bfd_putl32 (insn, contents + rel->r_offset);
+         bfd_putl32 (ldr_R0_mask (insn), contents + rel->r_offset);
          return bfd_reloc_continue;
        }
 
@@ -5820,18 +5871,19 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
       if (is_local)
        {
          /* GD->LE relaxation
-            add  x0, #:tlsgd_lo12:var  => movk x0, :tprel_g0_nc:var
+            add  x0, #:tlsgd_lo12:var  => movk R0, :tprel_g0_nc:var
             bl   __tls_get_addr        => mrs  x1, tpidr_el0
-            nop                        => add  x0, x1, x0
-          */
+            nop                        => add  R0, R1, R0
+
+            Where R is x for lp64 mode, and w for ILP32 mode.  */
 
          /* First kill the tls_get_addr reloc on the bl instruction.  */
          BFD_ASSERT (rel->r_offset + 4 == rel[1].r_offset);
          rel[1].r_info = ELFNN_R_INFO (STN_UNDEF, R_AARCH64_NONE);
 
-         bfd_putl32 (0xf2800000, contents + rel->r_offset);
+         bfd_putl32 (movk_R0, contents + rel->r_offset);
          bfd_putl32 (0xd53bd041, contents + rel->r_offset + 4);
-         bfd_putl32 (0x8b000020, contents + rel->r_offset + 8);
+         bfd_putl32 (add_R0_R0_R1, contents + rel->r_offset + 8);
          return bfd_reloc_continue;
        }
       else
@@ -5852,19 +5904,14 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
          /* We choose to fixup the BL and NOP instructions using the
             offset from the second relocation to allow flexibility in
             scheduling instructions between the ADD and BL.  */
-#if ARCH_SIZE == 32
-         bfd_putl32 (0xb9400000, contents + rel->r_offset);
-         bfd_putl32 (0x0b000020, contents + rel[1].r_offset + 4);
-#else
-         bfd_putl32 (0xf9400000, contents + rel->r_offset);
-         bfd_putl32 (0x8b000020, contents + rel[1].r_offset + 4);
-#endif
+         bfd_putl32 (ldr_R0_x0, contents + rel->r_offset);
          bfd_putl32 (0xd53bd041, contents + rel[1].r_offset);
+         bfd_putl32 (add_R0_R0_R1, contents + rel[1].r_offset + 4);
          return bfd_reloc_continue;
        }
 
     case BFD_RELOC_AARCH64_TLSDESC_ADD:
-    case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12:
     case BFD_RELOC_AARCH64_TLSDESC_CALL:
       /* GD->IE/LE relaxation:
          add x0, x0, #:tlsdesc_lo12:var   =>   nop
@@ -5877,70 +5924,76 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
       if (is_local)
        {
          /* GD->LE relaxation:
-            ldr xd, [gp, xn]   =>   movk x0, #:tprel_g0_nc:var
-          */
-         bfd_putl32 (0xf2800000, contents + rel->r_offset);
+            ldr xd, [gp, xn]   =>   movk R0, #:tprel_g0_nc:var
+
+            Where R is x for lp64 mode, and w for ILP32 mode.  */
+         bfd_putl32 (movk_R0, contents + rel->r_offset);
          return bfd_reloc_continue;
        }
       else
        {
          /* GD->IE relaxation:
-            ldr xd, [gp, xn]   =>   ldr x0, [gp, xn]
-          */
+            ldr xd, [gp, xn]   =>   ldr R0, [gp, xn]
+
+            Where R is x for lp64 mode, and w for ILP32 mode.  */
          insn = bfd_getl32 (contents + rel->r_offset);
-         insn &= 0xffffffe0;
-         bfd_putl32 (insn, contents + rel->r_offset);
+         bfd_putl32 (ldr_R0_mask (insn), contents + rel->r_offset);
          return bfd_reloc_ok;
        }
 
     case BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC:
       /* GD->LE relaxation:
-        movk xd, #:tlsdesc_off_g0_nc:var => movk x0, #:tprel_g1_nc:var, lsl #16
+        movk xd, #:tlsdesc_off_g0_nc:var => movk R0, #:tprel_g1_nc:var, lsl #16
         GD->IE relaxation:
-        movk xd, #:tlsdesc_off_g0_nc:var => movk xd, #:gottprel_g0_nc:var
-      */
+        movk xd, #:tlsdesc_off_g0_nc:var => movk Rd, #:gottprel_g0_nc:var
+
+        Where R is x for lp64 mode, and w for ILP32 mode.  */
       if (is_local)
-       bfd_putl32 (0xf2a00000, contents + rel->r_offset);
+       bfd_putl32 (ldr_hw_R0, contents + rel->r_offset);
       return bfd_reloc_continue;
 
     case BFD_RELOC_AARCH64_TLSDESC_OFF_G1:
       if (is_local)
        {
          /* GD->LE relaxation:
-            movz xd, #:tlsdesc_off_g1:var => movz x0, #:tprel_g2:var, lsl #32
-         */
-         bfd_putl32 (0xd2c00000, contents + rel->r_offset);
+            movz xd, #:tlsdesc_off_g1:var => movz R0, #:tprel_g2:var, lsl #32
+
+            Where R is x for lp64 mode, and w for ILP32 mode.  */
+         bfd_putl32 (movz_hw_R0, contents + rel->r_offset);
          return bfd_reloc_continue;
        }
       else
        {
          /*  GD->IE relaxation:
-             movz xd, #:tlsdesc_off_g1:var => movz xd, #:gottprel_g1:var, lsl #16
-         */
+             movz xd, #:tlsdesc_off_g1:var => movz Rd, #:gottprel_g1:var, lsl #16
+
+            Where R is x for lp64 mode, and w for ILP32 mode.  */
          insn = bfd_getl32 (contents + rel->r_offset);
-         bfd_putl32 (0xd2a00000 | (insn & 0x1f), contents + rel->r_offset);
+         bfd_putl32 (movz_R0 | (insn & 0x1f), contents + rel->r_offset);
          return bfd_reloc_continue;
        }
 
     case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
       /* IE->LE relaxation:
-         adrp xd, :gottprel:var   =>   movz xd, :tprel_g1:var
-       */
+         adrp xd, :gottprel:var   =>   movz Rd, :tprel_g1:var
+
+        Where R is x for lp64 mode, and w for ILP32 mode.  */
       if (is_local)
        {
          insn = bfd_getl32 (contents + rel->r_offset);
-         bfd_putl32 (0xd2a00000 | (insn & 0x1f), contents + rel->r_offset);
+         bfd_putl32 (movz_R0 | (insn & 0x1f), contents + rel->r_offset);
        }
       return bfd_reloc_continue;
 
     case BFD_RELOC_AARCH64_TLSIE_LDNN_GOTTPREL_LO12_NC:
       /* IE->LE relaxation:
-         ldr  xd, [xm, #:gottprel_lo12:var]   =>   movk xd, :tprel_g0_nc:var
-       */
+         ldr  xd, [xm, #:gottprel_lo12:var]   =>   movk Rd, :tprel_g0_nc:var
+
+        Where R is x for lp64 mode, and w for ILP32 mode.  */
       if (is_local)
        {
          insn = bfd_getl32 (contents + rel->r_offset);
-         bfd_putl32 (0xf2800000 | (insn & 0x1f), contents + rel->r_offset);
+         bfd_putl32 (movk_R0 | (insn & 0x1f), contents + rel->r_offset);
        }
       return bfd_reloc_continue;
 
@@ -5957,11 +6010,8 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
          /* No need of CALL26 relocation for tls_get_addr.  */
          rel[1].r_info = ELFNN_R_INFO (STN_UNDEF, R_AARCH64_NONE);
          bfd_putl32 (0xd53bd040, contents + rel->r_offset + 0);
-#if ARCH_SIZE == 64
-         bfd_putl32 (0x91004000, contents + rel->r_offset + 4);
-#else
-         bfd_putl32 (0x11002000, contents + rel->r_offset + 4);
-#endif
+         bfd_putl32 (add_R0_R0 | (TCB_SIZE << 10),
+                     contents + rel->r_offset + 4);
          return bfd_reloc_ok;
        }
       return bfd_reloc_continue;
@@ -5989,11 +6039,8 @@ elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
          BFD_ASSERT (ELFNN_R_TYPE (rel[1].r_info) == AARCH64_R (CALL26));
          /* No need of CALL26 relocation for tls_get_addr.  */
          rel[1].r_info = ELFNN_R_INFO (STN_UNDEF, R_AARCH64_NONE);
-#if ARCH_SIZE == 64
-         bfd_putl32 (0x91004000, contents + rel->r_offset + 0);
-#else
-         bfd_putl32 (0x11002000, contents + rel->r_offset + 0);
-#endif
+         bfd_putl32 (add_R0_R0 | (TCB_SIZE << 10),
+                     contents + rel->r_offset + 0);
          bfd_putl32 (INSN_NOP, contents + rel->r_offset + 4);
          return bfd_reloc_ok;
        }
@@ -6062,7 +6109,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
          /* xgettext:c-format */
          _bfd_error_handler
            (_("%B: unrecognized relocation (0x%x) in section `%A'"),
-            input_bfd, input_section, r_type);
+            input_bfd, r_type, input_section);
          return FALSE;
        }
       bfd_r_type = elfNN_aarch64_bfd_reloc_from_howto (howto);
@@ -6341,7 +6388,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
            }
          break;
 
-       case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12:
        case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
        case BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21:
        case BFD_RELOC_AARCH64_TLSDESC_LDNN_LO12_NC:
@@ -6748,11 +6795,11 @@ elfNN_aarch64_gc_sweep_hook (bfd *abfd,
        case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
        case BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC:
        case BFD_RELOC_AARCH64_MOVW_GOTOFF_G1:
-       case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12:
        case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
        case BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21:
        case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC:
-       case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12:
        case BFD_RELOC_AARCH64_TLSDESC_LD_PREL19:
        case BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC:
        case BFD_RELOC_AARCH64_TLSDESC_OFF_G1:
@@ -7142,7 +7189,7 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
              break;
            }
 
-         /* It is referenced by a non-shared object. */
+         /* It is referenced by a non-shared object.  */
          h->ref_regular = 1;
          h->root.non_ir_ref = 1;
        }
@@ -7250,11 +7297,11 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
        case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
        case BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC:
        case BFD_RELOC_AARCH64_MOVW_GOTOFF_G1:
-       case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12:
        case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
        case BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21:
        case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC:
-       case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC:
+       case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12:
        case BFD_RELOC_AARCH64_TLSDESC_LD_PREL19:
        case BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC:
        case BFD_RELOC_AARCH64_TLSDESC_OFF_G1:
@@ -7945,8 +7992,7 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
      because we will also be presented with the concrete instance of
      the symbol and elfNN_aarch64_copy_indirect_symbol () will have been
      called to copy all relevant data from the generic to the concrete
-     symbol instance.
-   */
+     symbol instance.  */
   if (h->root.type == bfd_link_hash_indirect)
     return TRUE;
 
@@ -8235,8 +8281,7 @@ elfNN_aarch64_allocate_ifunc_dynrelocs (struct elf_link_hash_entry *h,
      because we will also be presented with the concrete instance of
      the symbol and elfNN_aarch64_copy_indirect_symbol () will have been
      called to copy all relevant data from the generic to the concrete
-     symbol instance.
-   */
+     symbol instance.  */
   if (h->root.type == bfd_link_hash_indirect)
     return TRUE;
 
@@ -8328,6 +8373,7 @@ aarch64_readonly_dynrelocs (struct elf_link_hash_entry * h, void * inf)
 
 /* This is the most important function of all . Innocuosly named
    though !  */
+
 static bfd_boolean
 elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
                                     struct bfd_link_info *info)
@@ -8558,7 +8604,6 @@ elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
             adjust_dynamic_symbol is called, and it is that
             function which decides whether anything needs to go
             into these sections.  */
-
          s->flags |= SEC_EXCLUDE;
          continue;
        }
@@ -8798,6 +8843,7 @@ elfNN_aarch64_always_size_sections (bfd *output_bfd,
 
 /* Finish up dynamic symbol handling.  We set the contents of various
    dynamic sections here.  */
+
 static bfd_boolean
 elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd,
                                     struct bfd_link_info *info,
@@ -8838,7 +8884,7 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd,
          || plt == NULL
          || gotplt == NULL
          || relplt == NULL)
-       abort ();
+       return FALSE;
 
       elfNN_aarch64_create_small_pltn_entry (h, htab, output_bfd, info);
       if (!h->def_regular)
@@ -8934,7 +8980,6 @@ do_glob_dat:
       bfd_byte *loc;
 
       /* This symbol needs a copy reloc.  Set it up.  */
-
       if (h->dynindx == -1
          || (h->root.type != bfd_link_hash_defined
              && h->root.type != bfd_link_hash_defweak)
@@ -8946,7 +8991,7 @@ do_glob_dat:
                       + h->root.u.def.section->output_offset);
       rela.r_info = ELFNN_R_INFO (h->dynindx, AARCH64_R (COPY));
       rela.r_addend = 0;
-      if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+      if (h->root.u.def.section == htab->root.sdynrelro)
        s = htab->root.sreldynrelro;
       else
        s = htab->root.srelbss;
@@ -8997,8 +9042,7 @@ elfNN_aarch64_init_small_plt0_entry (bfd *output_bfd ATTRIBUTE_UNUSED,
                                        // GOTPLT entry for this.
      br   x17
      PLT0 will be slightly different in ELF32 due to different got entry
-     size.
-   */
+     size.  */
   bfd_vma plt_got_2nd_ent;     /* Address of GOT[2].  */
   bfd_vma plt_base;
 
@@ -9412,6 +9456,7 @@ const struct elf_size_info elfNN_aarch64_size_info =
 #define elf_backend_got_header_size (GOT_ENTRY_SIZE * 3)
 #define elf_backend_default_execstack  0
 #define elf_backend_extern_protected_data 1
+#define elf_backend_hash_symbol elf_aarch64_hash_symbol
 
 #undef  elf_backend_obj_attrs_section
 #define elf_backend_obj_attrs_section          ".ARM.attributes"
This page took 0.043883 seconds and 4 git commands to generate.