[AArch64][3/3] LD support BFD_RELOC_AARCH64_TLSLD_ADR_PREL21
authorJiong Wang <jiong.wang@arm.com>
Thu, 16 Jul 2015 14:46:21 +0000 (15:46 +0100)
committerJiong Wang <jiong.wang@arm.com>
Thu, 16 Jul 2015 14:46:21 +0000 (15:46 +0100)
bfd/ChangeLog
bfd/elfnn-aarch64.c
bfd/elfxx-aarch64.c
ld/testsuite/ChangeLog
ld/testsuite/ld-aarch64/aarch64-elf.exp
ld/testsuite/ld-aarch64/tls-tiny-ld.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/tls-tiny-ld.s [new file with mode: 0644]

index ffb470f06233b89071ad24a453f956ffe8aab39e..0d99205217c973a023a83231343de0a4a30052de 100644 (file)
@@ -1,3 +1,15 @@
+2015-07-16  Jiong Wang  <jiong.wang@arm.com>
+
+       * elfnn-aarch64.c (IS_AARCH64_TLS_RELOC): Recognize
+       BFD_RELOC_AARCH64_TLSLD_ADR_PREL21.
+       (aarch64_reloc_got_type): Ditto.
+       (elfNN_aarch64_final_link_relocate): Ditto.
+       (elfNN_aarch64_relocate_section): Ditto.
+       (elfNN_aarch64_gc_sweep_hook): Ditto.
+       (elfNN_aarch64_check_relocs): Ditto.
+       * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Ditto.
+       (_bfd_aarch64_elf_resolve_relocation): Ditto.
+
 2015-07-16  Jiong Wang  <jiong.wang@arm.com>
 
        * reloc.c (BFD_RELOC_AARCH64_TLSLD_ADR_PREL21): New entry.
index a1d926f4f76ed0f54e38e144de1f974e7503726d..f18286058242740d7e7e4e1608b51885d4491e5d 100644 (file)
    || (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_TLSLD_ADR_PREL21           \
    || (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    \
@@ -4105,6 +4106,7 @@ aarch64_reloc_got_type (bfd_reloc_code_real_type r_type)
     case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
     case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
     case BFD_RELOC_AARCH64_TLSGD_ADR_PREL21:
+    case BFD_RELOC_AARCH64_TLSLD_ADR_PREL21:
       return GOT_TLS_GD;
 
     case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
@@ -5011,6 +5013,7 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
     case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC:
     case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
     case BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19:
+    case BFD_RELOC_AARCH64_TLSLD_ADR_PREL21:
       if (globals->root.sgot == NULL)
        return bfd_reloc_notsupported;
 
@@ -5495,6 +5498,7 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
        case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
        case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
        case BFD_RELOC_AARCH64_TLSGD_ADR_PREL21:
+       case BFD_RELOC_AARCH64_TLSLD_ADR_PREL21:
          if (! symbol_got_offset_mark_p (input_bfd, h, r_symndx))
            {
              bfd_boolean need_relocs = FALSE;
@@ -5527,7 +5531,17 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
                    * RELOC_SIZE (htab);
                  bfd_elfNN_swap_reloca_out (output_bfd, &rela, loc);
 
-                 if (indx == 0)
+                 if (elfNN_aarch64_bfd_reloc_from_type (r_type)
+                     == BFD_RELOC_AARCH64_TLSLD_ADR_PREL21)
+                   {
+                     /* For local dynamic, don't generate DTPREL in any case.
+                        Initialize the DTPREL slot into zero, so we get module
+                        base address when invoke runtime TLS resolver.  */
+                     bfd_put_NN (output_bfd, 0,
+                                 globals->root.sgot->contents + off
+                                 + GOT_ENTRY_SIZE);
+                   }
+                 else if (indx == 0)
                    {
                      bfd_put_NN (output_bfd,
                                  relocation - dtpoff_base (info),
@@ -6011,6 +6025,7 @@ elfNN_aarch64_gc_sweep_hook (bfd *abfd,
        case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC:
        case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
        case BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19:
+       case BFD_RELOC_AARCH64_TLSLD_ADR_PREL21:
        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:
@@ -6483,6 +6498,7 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
        case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC:
        case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
        case BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19:
+       case BFD_RELOC_AARCH64_TLSLD_ADR_PREL21:
        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:
index 7b1a3946c4929bcb441035c0f7b4219d2044db0f..5b2af2a08396cea017d1bc11ed0ffacf37422b74 100644 (file)
@@ -241,6 +241,7 @@ _bfd_aarch64_elf_put_addend (bfd *abfd,
     case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
     case BFD_RELOC_AARCH64_TLSGD_ADR_PREL21:
     case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+    case BFD_RELOC_AARCH64_TLSLD_ADR_PREL21:
       contents = _bfd_aarch64_reencode_adr_imm (contents, addend);
       break;
 
@@ -371,6 +372,7 @@ _bfd_aarch64_elf_resolve_relocation (bfd_reloc_code_real_type r_type,
     case BFD_RELOC_AARCH64_TLSDESC_LD_PREL19:
     case BFD_RELOC_AARCH64_TLSGD_ADR_PREL21:
     case BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19:
+    case BFD_RELOC_AARCH64_TLSLD_ADR_PREL21:
     case BFD_RELOC_AARCH64_TSTBR14:
       if (weak_undef_p)
        value = place;
index c279cbdec7abca81770ce77a821c49eae6b36afe..31c5e0a4a8f41b9e77fa2e3e21dc3c3e90e877e4 100644 (file)
@@ -1,3 +1,9 @@
+2015-07-16  Jiong Wang  <jiong.wang@arm.com>
+
+       * ld-aarch64/tls-tiny-ld.s: New file.
+       * ld-aarch64/tls-tiny-ld.d: Ditto.
+       * ld-aarch64/aarch64-elf.exp: Run new test.
+
 2015-07-14  H.J. Lu  <hongjiu.lu@intel.com>
 
        * ld-elf/zlibbegin.rS: Updated to .debug_.* with the
index ac21d14956c23bdb083abb68c65b47f2a5890f50..de3dcf7f02cb38f3c1c582254e3afb610f376504 100644 (file)
@@ -146,6 +146,7 @@ run_dump_test "tls-tiny-desc"
 run_dump_test "tls-tiny-desc-ie"
 run_dump_test "tls-tiny-desc-le"
 run_dump_test "tls-tiny-ie"
+run_dump_test "tls-tiny-ld"
 run_dump_test "tlsle"
 run_dump_test "tlsle-symbol-offset"
 run_dump_test "gc-got-relocs"
diff --git a/ld/testsuite/ld-aarch64/tls-tiny-ld.d b/ld/testsuite/ld-aarch64/tls-tiny-ld.d
new file mode 100644 (file)
index 0000000..f2cb60c
--- /dev/null
@@ -0,0 +1,8 @@
+#source: tls-tiny-ld.s
+#ld: -T relocs.ld -shared
+#readelf: -Wr
+
+Relocation section '\.rela\.dyn' at offset 0x10070 contains 2 entries:
+    Offset             Info             Type               Symbol's Value  Symbol's Name \+ Addend
+0000000000000000  0000000000000000 R_AARCH64_NONE                            0
+0000000000020008  0000000200000404 R_AARCH64_TLS_DTPMOD64 0000000000000000 dummy \+ 0
diff --git a/ld/testsuite/ld-aarch64/tls-tiny-ld.s b/ld/testsuite/ld-aarch64/tls-tiny-ld.s
new file mode 100644 (file)
index 0000000..c298b9d
--- /dev/null
@@ -0,0 +1,7 @@
+// Test file for AArch64 LD -- tlsldm
+
+       .text
+func:
+       add     x1, x2, x3
+       // BFD_RELOC_AARCH64_TLSLD_ADR_PREL21
+       adr     x0, :tlsldm:dummy
This page took 0.047647 seconds and 4 git commands to generate.