[AArch64][3/8] LD support BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21
authorJiong Wang <jiong.wang@arm.com>
Tue, 11 Aug 2015 16:05:34 +0000 (17:05 +0100)
committerJiong Wang <jiong.wang@arm.com>
Tue, 11 Aug 2015 20:25:04 +0000 (21:25 +0100)
2015-08-11  Jiong Wang  <jiong.wang@arm.com>

bfd/
  * elfnn-aarch64.c (IS_AARCH64_TLS_RELOC): Recognize
  BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21.
  (aarch64_reloc_got_type): Likewise.
  (elfNN_aarch64_final_link_relocate): Likewise.
  (elfNN_aarch64_relocate_section): Likewise.
  (elfNN_aarch64_gc_sweep_hook): Likewise.
  (elfNN_aarch64_check_relocs): Likewise.
  * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
  (_bfd_aarch64_elf_resolve_relocation): Likewise.

ld/testsuite/
  * ld-aarch64/tls-small-ld.s: New file.
  * ld-aarch64/tls-small-ld.d: Likewise.
  * ld-aarch64/aarch64-elf.exp: Run new test.

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-small-ld.d [new file with mode: 0644]
ld/testsuite/ld-aarch64/tls-small-ld.s [new file with mode: 0644]

index 666b3cd99d9b65e6eaa2530f7b07398434d51cdc..01a29c842254165a33f5a25782d22f06044c8b69 100644 (file)
@@ -1,3 +1,15 @@
+2015-08-11  Jiong Wang  <jiong.wang@arm.com>
+
+       * elfnn-aarch64.c (IS_AARCH64_TLS_RELOC): Recognize
+       BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21.
+       (aarch64_reloc_got_type): Likewise.
+       (elfNN_aarch64_final_link_relocate): Likewise.
+       (elfNN_aarch64_relocate_section): Likewise.
+       (elfNN_aarch64_gc_sweep_hook): Likewise.
+       (elfNN_aarch64_check_relocs): Likewise.
+       * elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Likewise.
+       (_bfd_aarch64_elf_resolve_relocation): Likewise.
+
 2015-08-11  Jiong Wang  <jiong.wang@arm.com>
 
        * reloc.c (BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21): New entry.
index 16769bc3f2464bd3957363ba3f3bd0b568610f7f..ff56701614fa6f64d20cee12e8280bf5694da883 100644 (file)
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19   \
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC  \
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1     \
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21           \
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSLD_ADR_PREL21           \
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12       \
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12       \
@@ -4122,6 +4123,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_PAGE21:
     case BFD_RELOC_AARCH64_TLSLD_ADR_PREL21:
       return GOT_TLS_GD;
 
@@ -5029,6 +5031,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_PAGE21:
     case BFD_RELOC_AARCH64_TLSLD_ADR_PREL21:
       if (globals->root.sgot == NULL)
        return bfd_reloc_notsupported;
@@ -5514,6 +5517,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_PAGE21:
        case BFD_RELOC_AARCH64_TLSLD_ADR_PREL21:
          if (! symbol_got_offset_mark_p (input_bfd, h, r_symndx))
            {
@@ -5547,8 +5551,11 @@ elfNN_aarch64_relocate_section (bfd *output_bfd,
                    * RELOC_SIZE (htab);
                  bfd_elfNN_swap_reloca_out (output_bfd, &rela, loc);
 
-                 if (elfNN_aarch64_bfd_reloc_from_type (r_type)
-                     == BFD_RELOC_AARCH64_TLSLD_ADR_PREL21)
+                 bfd_reloc_code_real_type real_type =
+                   elfNN_aarch64_bfd_reloc_from_type (r_type);
+
+                 if (real_type == BFD_RELOC_AARCH64_TLSLD_ADR_PREL21
+                     || real_type == BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21)
                    {
                      /* For local dynamic, don't generate DTPREL in any case.
                         Initialize the DTPREL slot into zero, so we get module
@@ -6041,6 +6048,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_PAGE21:
        case BFD_RELOC_AARCH64_TLSLD_ADR_PREL21:
        case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12:
        case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12:
@@ -6514,6 +6522,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_PAGE21:
        case BFD_RELOC_AARCH64_TLSLD_ADR_PREL21:
        case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12:
        case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12:
index 5b2af2a08396cea017d1bc11ed0ffacf37422b74..3186d8ed71419204fb9f1627aa7e422d17309d51 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_PAGE21:
     case BFD_RELOC_AARCH64_TLSLD_ADR_PREL21:
       contents = _bfd_aarch64_reencode_adr_imm (contents, addend);
       break;
@@ -414,6 +415,7 @@ _bfd_aarch64_elf_resolve_relocation (bfd_reloc_code_real_type r_type,
     case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
     case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
     case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+    case BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21:
       value = PG (value + addend) - PG (place);
       break;
 
index f719db730c1274a1fb4a972bc6bf97025c51598c..99e87f7df43c3d78c32a103dd8975584c7472d66 100644 (file)
@@ -1,3 +1,9 @@
+2015-08-11  Jiong Wang  <jiong.wang@arm.com>
+
+       * ld-aarch64/tls-small-ld.s: New file.
+       * ld-aarch64/tls-small-ld.d: Likewise.
+       * ld-aarch64/aarch64-elf.exp: Run new test.
+
 2015-08-11  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/18808
index ab2fa49d8158d55c9facd35bbff8a4f7d4e86db0..0c0661036d5c1356c257914f2ecff9fa091ea1d6 100644 (file)
@@ -147,6 +147,7 @@ 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 "tls-small-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-small-ld.d b/ld/testsuite/ld-aarch64/tls-small-ld.d
new file mode 100644 (file)
index 0000000..74cf256
--- /dev/null
@@ -0,0 +1,9 @@
+#source: tls-small-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-small-ld.s b/ld/testsuite/ld-aarch64/tls-small-ld.s
new file mode 100644 (file)
index 0000000..0a8b6b9
--- /dev/null
@@ -0,0 +1,7 @@
+// Test file for AArch64 LD -- reloc 518
+
+       .text
+func:
+       add     x1, x2, x3
+       // BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21
+       adrp    x0, :tlsldm:dummy