This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[2/2][LD][AARCH64]Add BFD_RELOC_AARCH64_TLSLE_LDST8/16/32/64_TPREL_LO12 support in LD.


Hi all,

This is the second patch to add the following relocation support into binutils.
BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12,
BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12_NC,
BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12,
BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12_NC,
BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12,
BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12_NC,
BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12,
BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12_NC.

Those relocations includes both ip64 and ilp32 variant.

In this patch, the relocations support in ld is added.


Regard,
Renlin


bfd/ChangeLog:

2018-03-23  Renlin Li  <renlin.li@arm.com>

        PR ld/22970
	* elfnn-aarch64.c (IS_AARCH64_TLS_RELOC): Add cases for
	BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12,
	BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12_NC,
	BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12,
	BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12_NC,
	BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12,
	BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12_NC,
	BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12,
	BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12_NC.
	(elfNN_aarch64_final_link_relocate): Support new relocations.
	* elfxx-aarch64.c (_bfd_aarch64_elf_put_addend): Support new
	relocations.
	(_bfd_aarch64_elf_resolve_relocation): Support new relocations.

ld/ChangeLog:

2018-03-23  Renlin Li  <renlin.li@arm.com>

        PR ld/22970
	* testsuite/ld-aarch64/aarch64-elf.exp: Update to run new tests.
	* testsuite/ld-aarch64/emit-relocs-552-overflow.d: New.
	* testsuite/ld-aarch64/emit-relocs-552-overflow.s: New.
	* testsuite/ld-aarch64/emit-relocs-552.d: New.
	* testsuite/ld-aarch64/emit-relocs-552.s: New.
	* testsuite/ld-aarch64/emit-relocs-553.d: New.
	* testsuite/ld-aarch64/emit-relocs-553.s: New.
	* testsuite/ld-aarch64/emit-relocs-554-overflow.d: New.
	* testsuite/ld-aarch64/emit-relocs-554-overflow.s: New.
	* testsuite/ld-aarch64/emit-relocs-554.d: New.
	* testsuite/ld-aarch64/emit-relocs-554.s: New.
	* testsuite/ld-aarch64/emit-relocs-555.d: New.
	* testsuite/ld-aarch64/emit-relocs-555.s: New.
	* testsuite/ld-aarch64/emit-relocs-556-overflow.d: New.
	* testsuite/ld-aarch64/emit-relocs-556-overflow.s: New.
	* testsuite/ld-aarch64/emit-relocs-556.d: New.
	* testsuite/ld-aarch64/emit-relocs-556.s: New.
	* testsuite/ld-aarch64/emit-relocs-557.d: New.
	* testsuite/ld-aarch64/emit-relocs-557.s: New.
	* testsuite/ld-aarch64/emit-relocs-558-overflow.d: New.
	* testsuite/ld-aarch64/emit-relocs-558-overflow.s: New.
	* testsuite/ld-aarch64/emit-relocs-558.d: New.
	* testsuite/ld-aarch64/emit-relocs-558.s: New.
	* testsuite/ld-aarch64/emit-relocs-559.d: New.
	* testsuite/ld-aarch64/emit-relocs-559.s: New.
        * testsuite/ld-aarch64/emit-relocs-112-overflow.d: New.
        * testsuite/ld-aarch64/emit-relocs-112-overflow.s: New.
        * testsuite/ld-aarch64/emit-relocs-112.d: New.
        * testsuite/ld-aarch64/emit-relocs-112.s: New.
        * testsuite/ld-aarch64/emit-relocs-113.d: New.
        * testsuite/ld-aarch64/emit-relocs-113.s: New.
        * testsuite/ld-aarch64/emit-relocs-114-overflow.d: New.
        * testsuite/ld-aarch64/emit-relocs-114-overflow.s: New.
        * testsuite/ld-aarch64/emit-relocs-114.d: New.
        * testsuite/ld-aarch64/emit-relocs-114.s: New.
        * testsuite/ld-aarch64/emit-relocs-115.d: New.
        * testsuite/ld-aarch64/emit-relocs-115.s: New.
        * testsuite/ld-aarch64/emit-relocs-116-overflow.d: New.
        * testsuite/ld-aarch64/emit-relocs-116-overflow.s: New.
        * testsuite/ld-aarch64/emit-relocs-116.d: New.
        * testsuite/ld-aarch64/emit-relocs-116.s: New.
        * testsuite/ld-aarch64/emit-relocs-117.d: New.
        * testsuite/ld-aarch64/emit-relocs-117.s: New.
        * testsuite/ld-aarch64/emit-relocs-118-overflow.d: New.
        * testsuite/ld-aarch64/emit-relocs-118-overflow.s: New.
        * testsuite/ld-aarch64/emit-relocs-118.d: New.
        * testsuite/ld-aarch64/emit-relocs-118.s: New.
        * testsuite/ld-aarch64/emit-relocs-119.d: New.
        * testsuite/ld-aarch64/emit-relocs-119.s: New.

On 28/03/18 15:52, Renlin Li wrote:
Hi all,

This patch is to add the following relocation support into binutils:
BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12,
BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12_NC.
BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12,
BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12_NC,
BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12,
BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12_NC,
BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12,
BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12_NC,

Those relocations includes both ip64 and ilp32 variant.
Test cases are added.

This patch will resolve PR22970: https://sourceware.org/bugzilla/show_bug.cgi?id=22970

Binutils test Okay, Okay to commit?

Regards,
Renlin
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index d6a215e8e3643e0a63c6f9cc525d8d00e968fd4e..3ccca779ff79cb83d3f2fc7de50bb258a55f94bb 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -201,6 +201,14 @@
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12	\
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12	\
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12_NC	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12_NC	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12_NC	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12_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_TLSLE_MOVW_TPREL_G1		\
@@ -5830,6 +5838,14 @@ bad_ifunc_reloc:
     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_LDST16_TPREL_LO12:
+    case BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12:
+    case BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12:
+    case BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12:
+    case BFD_RELOC_AARCH64_TLSLE_LDST8_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:
diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c
index 4fa5682e0d0a41a3832d59b215b2fe0aa46fc68e..08e7cd9684cf4621ac6c2843d8bc82a3d21b4a6a 100644
--- a/bfd/elfxx-aarch64.c
+++ b/bfd/elfxx-aarch64.c
@@ -285,11 +285,18 @@ _bfd_aarch64_elf_put_addend (bfd *abfd,
     case BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC:
     case BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12:
     case BFD_RELOC_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12:
+    case BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12:
+    case BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12:
+    case BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12:
+    case BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_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
-	 12 bits of the page offset following BFD_RELOC_AARCH64_ADR_HI21_PCREL
-	 which computes the (pc-relative) page base.  */
+	 12 bits address offset.  */
       contents = reencode_ldst_pos_imm (contents, addend);
       break;
 
@@ -457,6 +464,14 @@ _bfd_aarch64_elf_resolve_relocation (bfd_reloc_code_real_type r_type,
     case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1:
     case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1_NC:
     case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G2:
+    case BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12:
+    case BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12:
+    case BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12:
+    case BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12:
+    case BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12_NC:
       value = value + addend;
       break;
 
diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp
index de99a8b233bbb7f06fe70f5771f23a682d8f9fcb..1bbc0648578cbf283a80f80a155ce92d1384923d 100644
--- a/ld/testsuite/ld-aarch64/aarch64-elf.exp
+++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp
@@ -99,8 +99,22 @@ run_dump_test "emit-relocs-89"
 run_dump_test "emit-relocs-90"
 run_dump_test "emit-relocs-90-overflow"
 run_dump_test "emit-relocs-92"
-run_dump_test_lp64 "emit-relocs-257"
-run_dump_test_lp64 "emit-relocs-257-be"
+
+run_dump_test "emit-relocs-112"
+run_dump_test "emit-relocs-112-overflow"
+run_dump_test "emit-relocs-113"
+run_dump_test "emit-relocs-114"
+run_dump_test "emit-relocs-114-overflow"
+run_dump_test "emit-relocs-115"
+run_dump_test "emit-relocs-116"
+run_dump_test "emit-relocs-116-overflow"
+run_dump_test "emit-relocs-117"
+run_dump_test "emit-relocs-118"
+run_dump_test "emit-relocs-118-overflow"
+run_dump_test "emit-relocs-119"
+
+run_dump_test "emit-relocs-257"
+run_dump_test "emit-relocs-257-be"
 # 258 is tested in 257
 # 259 is tested in 257
 run_dump_test_lp64 "emit-relocs-258-dyn-bad"
@@ -197,6 +211,18 @@ run_dump_test_lp64 "emit-relocs-536"
 run_dump_test_lp64 "emit-relocs-537"
 run_dump_test_lp64 "emit-relocs-537-overflow"
 run_dump_test_lp64 "emit-relocs-538"
+run_dump_test_lp64 "emit-relocs-552"
+run_dump_test_lp64 "emit-relocs-552-overflow"
+run_dump_test_lp64 "emit-relocs-553"
+run_dump_test_lp64 "emit-relocs-554"
+run_dump_test_lp64 "emit-relocs-554-overflow"
+run_dump_test_lp64 "emit-relocs-555"
+run_dump_test_lp64 "emit-relocs-556"
+run_dump_test_lp64 "emit-relocs-556-overflow"
+run_dump_test_lp64 "emit-relocs-557"
+run_dump_test_lp64 "emit-relocs-558"
+run_dump_test_lp64 "emit-relocs-558-overflow"
+run_dump_test_lp64 "emit-relocs-559"
 
 run_dump_test "reloc-overflow-bad"
 
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-112-overflow.d b/ld/testsuite/ld-aarch64/emit-relocs-112-overflow.d
new file mode 100644
index 0000000000000000000000000000000000000000..b66812b740e0c1f7d11740327002f61b3de9af67
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-112-overflow.d
@@ -0,0 +1,5 @@
+#source: emit-relocs-552-overflow.s
+#as: -mabi=ilp32
+#ld: -m [aarch64_choose_ilp32_emul] -T relocs-ilp32.ld -e0 --emit-relocs
+#objdump: -dr
+#error: .*\(.text\+0x\d+\): relocation truncated to fit: R_AARCH64_P32_TLSLE_LDST8_TPREL_LO12 against symbol `v2' .*
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-112-overflow.s b/ld/testsuite/ld-aarch64/emit-relocs-112-overflow.s
new file mode 100644
index 0000000000000000000000000000000000000000..904ab2fa813bd4cd5d7f545ccb763d7c79f49ea7
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-112-overflow.s
@@ -0,0 +1,11 @@
+	.global	v1
+	.size	v1, 4096
+	.global	v2
+	.section	.tdata,"awT",%progbits
+v1:
+	.zero	4096
+v2:
+	.word	0xcafecafe
+
+	.text
+	ldrsb	x22, [x1, #:tprel_lo12:v2]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-112.d b/ld/testsuite/ld-aarch64/emit-relocs-112.d
new file mode 100644
index 0000000000000000000000000000000000000000..8379cf211fe5fb63d3e2f2380231b52d17fd6468
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-112.d
@@ -0,0 +1,8 @@
+#source: emit-relocs-552.s
+#as: -mabi=ilp32
+#ld: -m [aarch64_choose_ilp32_emul] -T relocs-ilp32.ld -e0 --emit-relocs
+#objdump: -dr
+#...
+00010000 <.text>:
+   10000:	39803115 	ldrsb	x21, \[x8, #12\]
+			10000: R_AARCH64_P32_TLSLE_LDST8_TPREL_LO12	v2
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-112.s b/ld/testsuite/ld-aarch64/emit-relocs-112.s
new file mode 100644
index 0000000000000000000000000000000000000000..6575db34975493aaecc1420986c8065e7f1f3181
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-112.s
@@ -0,0 +1,10 @@
+	.global	v1
+	.global	v2
+	.section	.tdata,"awT",%progbits
+v1:
+	.word	0xdeaddead
+v2:
+	.word	0xcafecafe
+
+	.text
+	ldrsb	x21, [x8, #:tprel_lo12:v2]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-113.d b/ld/testsuite/ld-aarch64/emit-relocs-113.d
new file mode 100644
index 0000000000000000000000000000000000000000..60e40e6ba2b21f577e02678c9e7d3f7766824f5f
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-113.d
@@ -0,0 +1,10 @@
+#source: emit-relocs-553.s
+#as: -mabi=ilp32
+#ld: -m [aarch64_choose_ilp32_emul] -T relocs-ilp32.ld -e0 --emit-relocs
+#objdump: -dr
+#...
+00010000 <.text>:
+   10000:	3980309d 	ldrsb	x29, \[x4, #12\]
+			10000: R_AARCH64_P32_TLSLE_LDST8_TPREL_LO12_NC	v2
+   10004:	398040f2 	ldrsb	x18, \[x7, #16\]
+			10004: R_AARCH64_P32_TLSLE_LDST8_TPREL_LO12_NC	v3
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-113.s b/ld/testsuite/ld-aarch64/emit-relocs-113.s
new file mode 100644
index 0000000000000000000000000000000000000000..f910cdbb52a4da9b00e841de679fbc3e15415c0e
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-113.s
@@ -0,0 +1,17 @@
+	.global	v1
+	.global	v2
+	.size	v2, 4100
+	.global	v3
+	.section	.tdata,"awT",%progbits
+v1:
+	.word	0xdeaddead
+v2:
+	.zero	4100
+v3:
+	.word	0xcafecafe
+
+	.text
+	ldrsb	x29, [x4, #:tprel_lo12_nc:v2]
+
+	# should not issue overflow error.
+	ldrsb	x18, [x7, #:tprel_lo12_nc:v3]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-114-overflow.d b/ld/testsuite/ld-aarch64/emit-relocs-114-overflow.d
new file mode 100644
index 0000000000000000000000000000000000000000..59261734dc249d75294dd0336401310c0331eae2
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-114-overflow.d
@@ -0,0 +1,5 @@
+#source: emit-relocs-554-overflow.s
+#as: -mabi=ilp32
+#ld: -m [aarch64_choose_ilp32_emul] -T relocs-ilp32.ld -e0 --emit-relocs
+#objdump: -dr
+#error: .*\(.text\+0x\d+\): relocation truncated to fit: R_AARCH64_P32_TLSLE_LDST16_TPREL_LO12 against symbol `v2' .*
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-114-overflow.s b/ld/testsuite/ld-aarch64/emit-relocs-114-overflow.s
new file mode 100644
index 0000000000000000000000000000000000000000..83ca3af1cd794bc4407e1ddff581a9d3f5e6a2fd
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-114-overflow.s
@@ -0,0 +1,11 @@
+	.global	v1
+	.size	v1, 4096
+	.global	v2
+	.section	.tdata,"awT",%progbits
+v1:
+	.zero	4096
+v2:
+	.word	0xcafecafe
+
+	.text
+	ldrsh	x2, [x17, #:tprel_lo12:v2]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-114.d b/ld/testsuite/ld-aarch64/emit-relocs-114.d
new file mode 100644
index 0000000000000000000000000000000000000000..96a2501d0581dcb4414643e06b068b9bafb6c7b1
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-114.d
@@ -0,0 +1,8 @@
+#source: emit-relocs-554.s
+#as: -mabi=ilp32
+#ld: -m [aarch64_choose_ilp32_emul] -T relocs-ilp32.ld -e0 --emit-relocs
+#objdump: -dr
+#...
+00010000 <.text>:
+   10000:	798018eb 	ldrsh	x11, \[x7, #12\]
+			10000: R_AARCH64_P32_TLSLE_LDST16_TPREL_LO12	v2
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-114.s b/ld/testsuite/ld-aarch64/emit-relocs-114.s
new file mode 100644
index 0000000000000000000000000000000000000000..8ad7afbc2a4be3bec9a293b0012fc27653443c94
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-114.s
@@ -0,0 +1,10 @@
+	.global	v1
+	.global	v2
+	.section	.tdata,"awT",%progbits
+v1:
+	.word	0xdeaddead
+v2:
+	.word	0xcafecafe
+
+	.text
+	ldrsh	x11, [x7, #:tprel_lo12:v2]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-115.d b/ld/testsuite/ld-aarch64/emit-relocs-115.d
new file mode 100644
index 0000000000000000000000000000000000000000..f436d32c61fca5abf7b1b59fa822fbc086dc9722
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-115.d
@@ -0,0 +1,10 @@
+#source: emit-relocs-555.s
+#as: -mabi=ilp32
+#ld: -m [aarch64_choose_ilp32_emul] -T relocs-ilp32.ld -e0 --emit-relocs
+#objdump: -dr
+#...
+00010000 <.text>:
+   10000:	798019d6 	ldrsh	x22, \[x14, #12\]
+			10000: R_AARCH64_P32_TLSLE_LDST16_TPREL_LO12_NC	v2
+   10004:	79a72a28 	ldrsh	x8, \[x17, #5012\]
+			10004: R_AARCH64_P32_TLSLE_LDST16_TPREL_LO12_NC	v3
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-115.s b/ld/testsuite/ld-aarch64/emit-relocs-115.s
new file mode 100644
index 0000000000000000000000000000000000000000..b21e6ce4f9e3a37ef14abfd4f6ad76c48fdc3937
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-115.s
@@ -0,0 +1,17 @@
+	.global	v1
+	.global	v2
+	.size	v2, 5000
+	.global	v3
+	.section	.tdata,"awT",%progbits
+v1:
+	.word	0xdeaddead
+v2:
+	.zero	5000
+v3:
+	.word	0xcafecafe
+
+	.text
+	ldrsh	x22, [x14, #:tprel_lo12_nc:v2]
+
+	# should not issue overflow error.
+	ldrsh	x8, [x17, #:tprel_lo12_nc:v3]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-116-overflow.d b/ld/testsuite/ld-aarch64/emit-relocs-116-overflow.d
new file mode 100644
index 0000000000000000000000000000000000000000..f060c1731e1d651bd891ab049d410e9a80999ae1
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-116-overflow.d
@@ -0,0 +1,5 @@
+#source: emit-relocs-556-overflow.s
+#as: -mabi=ilp32
+#ld: -m [aarch64_choose_ilp32_emul] -T relocs-ilp32.ld -e0 --emit-relocs
+#objdump: -dr
+#error: .*\(.text\+0x\d+\): relocation truncated to fit: R_AARCH64_P32_TLSLE_LDST32_TPREL_LO12 against symbol `v2' .*
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-116-overflow.s b/ld/testsuite/ld-aarch64/emit-relocs-116-overflow.s
new file mode 100644
index 0000000000000000000000000000000000000000..9b8e5d778cd124d3a9ab0db3a9c5f0c6c6be2777
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-116-overflow.s
@@ -0,0 +1,11 @@
+	.global	v1
+	.size	v1, 4096
+	.global	v2
+	.section	.tdata,"awT",%progbits
+v1:
+	.zero	4096
+v2:
+	.word	0xcafecafe
+
+	.text
+	ldrsw  x2, [x17, #:tprel_lo12:v2]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-116.d b/ld/testsuite/ld-aarch64/emit-relocs-116.d
new file mode 100644
index 0000000000000000000000000000000000000000..bd2d6aabf4830eb64c2dbfa3453c564c7a5ec583
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-116.d
@@ -0,0 +1,8 @@
+#source: emit-relocs-556.s
+#as: -mabi=ilp32
+#ld: -m [aarch64_choose_ilp32_emul] -T relocs-ilp32.ld -e0 --emit-relocs
+#objdump: -dr
+#...
+00010000 <.text>:
+   10000:	b9800e61 	ldrsw	x1, \[x19, #12\]
+			10000: R_AARCH64_P32_TLSLE_LDST32_TPREL_LO12	v2
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-116.s b/ld/testsuite/ld-aarch64/emit-relocs-116.s
new file mode 100644
index 0000000000000000000000000000000000000000..bb083154fd6554a456fd3dfe412fe997e59f4c57
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-116.s
@@ -0,0 +1,10 @@
+	.global	v1
+	.global	v2
+	.section	.tdata,"awT",%progbits
+v1:
+	.word	0xdeaddead
+v2:
+	.word	0xcafecafe
+
+	.text
+	ldrsw	x1, [x19, #:tprel_lo12:v2]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-117.d b/ld/testsuite/ld-aarch64/emit-relocs-117.d
new file mode 100644
index 0000000000000000000000000000000000000000..a3bb606bf597a88c0e6b4f085d703e6ef88ab54b
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-117.d
@@ -0,0 +1,10 @@
+#source: emit-relocs-557.s
+#as: -mabi=ilp32
+#ld: -m [aarch64_choose_ilp32_emul] -T relocs-ilp32.ld -e0 --emit-relocs
+#objdump: -dr
+#...
+00010000 <.text>:
+   10000:	b9800dd6 	ldrsw	x22, \[x14, #12\]
+			10000: R_AARCH64_P32_TLSLE_LDST32_TPREL_LO12_NC	v2
+   10004:	b9800e28 	ldrsw	x8, \[x17, #12\]
+			10004: R_AARCH64_P32_TLSLE_LDST32_TPREL_LO12_NC	v3
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-117.s b/ld/testsuite/ld-aarch64/emit-relocs-117.s
new file mode 100644
index 0000000000000000000000000000000000000000..88dcdfad38b2841c1d5d8c3c0fdb713f0b06409a
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-117.s
@@ -0,0 +1,17 @@
+	.global	v1
+	.global	v2
+	.size	v2, 16384
+	.global	v3
+	.section	.tdata,"awT",%progbits
+v1:
+	.word	0xdeaddead
+v2:
+	.zero	16384
+v3:
+	.word	0xcafecafe
+
+	.text
+	ldrsw	x22, [x14, #:tprel_lo12_nc:v2]
+
+	# should not issue overflow error.
+	ldrsw	x8, [x17, #:tprel_lo12_nc:v3]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-118-overflow.d b/ld/testsuite/ld-aarch64/emit-relocs-118-overflow.d
new file mode 100644
index 0000000000000000000000000000000000000000..1eedac19d29c250c63afc7b8d9bd79b142adbb59
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-118-overflow.d
@@ -0,0 +1,5 @@
+#source: emit-relocs-558-overflow.s
+#as: -mabi=ilp32
+#ld: -m [aarch64_choose_ilp32_emul] -T relocs-ilp32.ld -e0 --emit-relocs
+#objdump: -dr
+#error: .*\(.text\+0x\d+\): relocation truncated to fit: R_AARCH64_P32_TLSLE_LDST64_TPREL_LO12 against symbol `v2' .*
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-118-overflow.s b/ld/testsuite/ld-aarch64/emit-relocs-118-overflow.s
new file mode 100644
index 0000000000000000000000000000000000000000..82dfef67077d5ce307df53a3a31685be1fa214aa
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-118-overflow.s
@@ -0,0 +1,11 @@
+	.global	v1
+	.size	v1, 4096
+	.global	v2
+	.section	.tdata,"awT",%progbits
+v1:
+	.zero	4096
+v2:
+	.word	0xcafecafe
+
+	.text
+	ldr	x12, [x13, #:tprel_lo12:v2]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-118.d b/ld/testsuite/ld-aarch64/emit-relocs-118.d
new file mode 100644
index 0000000000000000000000000000000000000000..90619742850ec8f5c4e44198171d1f87c5387ca4
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-118.d
@@ -0,0 +1,8 @@
+#source: emit-relocs-558.s
+#as: -mabi=ilp32
+#ld: -m [aarch64_choose_ilp32_emul] -T relocs-ilp32.ld -e0 --emit-relocs
+#objdump: -dr
+#...
+00010000 <.text>:
+   10000:	f9400920 	ldr	x0, \[x9, #16\]
+			10000: R_AARCH64_P32_TLSLE_LDST64_TPREL_LO12	v2
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-118.s b/ld/testsuite/ld-aarch64/emit-relocs-118.s
new file mode 100644
index 0000000000000000000000000000000000000000..0fe7593f9c35efc719164fd4cfad00cc2dca439e
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-118.s
@@ -0,0 +1,12 @@
+	.global	v1
+	.global	v2
+	.section	.tdata,"awT",%progbits
+v1:
+	.word	0xdeaddead
+	.word	0xdeaddead
+v2:
+	.word	0xcafecafe
+	.word	0xcafecafe
+
+	.text
+	ldr	x0, [x9, #:tprel_lo12:v2]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-119.d b/ld/testsuite/ld-aarch64/emit-relocs-119.d
new file mode 100644
index 0000000000000000000000000000000000000000..20e05eb81bfd8d15e5f35e99afa916f0be6bedbd
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-119.d
@@ -0,0 +1,10 @@
+#source: emit-relocs-559.s
+#as: -mabi=ilp32
+#ld: -m [aarch64_choose_ilp32_emul] -T relocs-ilp32.ld -e0 --emit-relocs
+#objdump: -dr
+#...
+00010000 <.text>:
+   10000:	f9400882 	ldr	x2, \[x4, #16\]
+			10000: R_AARCH64_P32_TLSLE_LDST64_TPREL_LO12_NC	v2
+   10004:	f9400a2e 	ldr	x14, \[x17, #16\]
+			10004: R_AARCH64_P32_TLSLE_LDST64_TPREL_LO12_NC	v3
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-119.s b/ld/testsuite/ld-aarch64/emit-relocs-119.s
new file mode 100644
index 0000000000000000000000000000000000000000..3548d79f935ca3ce2c31237447ebdb71c458e9ce
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-119.s
@@ -0,0 +1,19 @@
+	.global	v1
+	.global	v2
+	.size	v2, 32768
+	.global	v3
+	.section	.tdata,"awT",%progbits
+v1:
+	.word	0xdeaddead
+	.word	0xdeaddead
+v2:
+	.zero	32768
+v3:
+	.word	0xcafecafe
+	.word	0xcafecafe
+
+	.text
+	ldr	x2, [x4, #:tprel_lo12_nc:v2]
+
+	# should not issue overflow error.
+	ldr	x14, [x17, #:tprel_lo12_nc:v3]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-552-overflow.d b/ld/testsuite/ld-aarch64/emit-relocs-552-overflow.d
new file mode 100644
index 0000000000000000000000000000000000000000..91e70359739e955123cf1b995659faa41f2614e1
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-552-overflow.d
@@ -0,0 +1,4 @@
+#source: emit-relocs-552-overflow.s
+#ld: -T relocs.ld -e0 --emit-relocs
+#objdump: -dr
+#error: .*\(.text\+0x\d+\): relocation truncated to fit: R_AARCH64_TLSLE_LDST8_TPREL_LO12 against symbol `v2' .*
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-552-overflow.s b/ld/testsuite/ld-aarch64/emit-relocs-552-overflow.s
new file mode 100644
index 0000000000000000000000000000000000000000..904ab2fa813bd4cd5d7f545ccb763d7c79f49ea7
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-552-overflow.s
@@ -0,0 +1,11 @@
+	.global	v1
+	.size	v1, 4096
+	.global	v2
+	.section	.tdata,"awT",%progbits
+v1:
+	.zero	4096
+v2:
+	.word	0xcafecafe
+
+	.text
+	ldrsb	x22, [x1, #:tprel_lo12:v2]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-552.d b/ld/testsuite/ld-aarch64/emit-relocs-552.d
new file mode 100644
index 0000000000000000000000000000000000000000..3c39139fdaef214336d5de67abd482db269806ae
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-552.d
@@ -0,0 +1,7 @@
+#source: emit-relocs-552.s
+#ld: -T relocs.ld -e0 --emit-relocs
+#objdump: -dr
+#...
+0000000000010000 <.text>:
+   10000:	39805115 	ldrsb	x21, \[x8, #20\]
+			10000: R_AARCH64_TLSLE_LDST8_TPREL_LO12	v2
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-552.s b/ld/testsuite/ld-aarch64/emit-relocs-552.s
new file mode 100644
index 0000000000000000000000000000000000000000..6575db34975493aaecc1420986c8065e7f1f3181
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-552.s
@@ -0,0 +1,10 @@
+	.global	v1
+	.global	v2
+	.section	.tdata,"awT",%progbits
+v1:
+	.word	0xdeaddead
+v2:
+	.word	0xcafecafe
+
+	.text
+	ldrsb	x21, [x8, #:tprel_lo12:v2]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-553.d b/ld/testsuite/ld-aarch64/emit-relocs-553.d
new file mode 100644
index 0000000000000000000000000000000000000000..08d1672ac4d6b549885308e80cf507028e6eae34
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-553.d
@@ -0,0 +1,9 @@
+#source: emit-relocs-553.s
+#ld: -T relocs.ld -e0 --emit-relocs
+#objdump: -dr
+#...
+0000000000010000 <.text>:
+   10000:	3980509d 	ldrsb	x29, \[x4, #20\]
+			10000: R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC	v2
+   10004:	398060f2 	ldrsb	x18, \[x7, #24\]
+			10004: R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC	v3
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-553.s b/ld/testsuite/ld-aarch64/emit-relocs-553.s
new file mode 100644
index 0000000000000000000000000000000000000000..f910cdbb52a4da9b00e841de679fbc3e15415c0e
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-553.s
@@ -0,0 +1,17 @@
+	.global	v1
+	.global	v2
+	.size	v2, 4100
+	.global	v3
+	.section	.tdata,"awT",%progbits
+v1:
+	.word	0xdeaddead
+v2:
+	.zero	4100
+v3:
+	.word	0xcafecafe
+
+	.text
+	ldrsb	x29, [x4, #:tprel_lo12_nc:v2]
+
+	# should not issue overflow error.
+	ldrsb	x18, [x7, #:tprel_lo12_nc:v3]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-554-overflow.d b/ld/testsuite/ld-aarch64/emit-relocs-554-overflow.d
new file mode 100644
index 0000000000000000000000000000000000000000..fb520e75aeaf4cee5ad954a3c12f897b18820088
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-554-overflow.d
@@ -0,0 +1,4 @@
+#source: emit-relocs-554-overflow.s
+#ld: -T relocs.ld -e0 --emit-relocs
+#objdump: -dr
+#error: .*\(.text\+0x\d+\): relocation truncated to fit: R_AARCH64_TLSLE_LDST16_TPREL_LO12 against symbol `v2' .*
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-554-overflow.s b/ld/testsuite/ld-aarch64/emit-relocs-554-overflow.s
new file mode 100644
index 0000000000000000000000000000000000000000..83ca3af1cd794bc4407e1ddff581a9d3f5e6a2fd
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-554-overflow.s
@@ -0,0 +1,11 @@
+	.global	v1
+	.size	v1, 4096
+	.global	v2
+	.section	.tdata,"awT",%progbits
+v1:
+	.zero	4096
+v2:
+	.word	0xcafecafe
+
+	.text
+	ldrsh	x2, [x17, #:tprel_lo12:v2]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-554.d b/ld/testsuite/ld-aarch64/emit-relocs-554.d
new file mode 100644
index 0000000000000000000000000000000000000000..d53338b61e3d722494d9f98e74d7a417a2503567
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-554.d
@@ -0,0 +1,7 @@
+#source: emit-relocs-554.s
+#ld: -T relocs.ld -e0 --emit-relocs
+#objdump: -dr
+#...
+0000000000010000 <.text>:
+   10000:	798028eb 	ldrsh	x11, \[x7, #20\]
+			10000: R_AARCH64_TLSLE_LDST16_TPREL_LO12	v2
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-554.s b/ld/testsuite/ld-aarch64/emit-relocs-554.s
new file mode 100644
index 0000000000000000000000000000000000000000..8ad7afbc2a4be3bec9a293b0012fc27653443c94
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-554.s
@@ -0,0 +1,10 @@
+	.global	v1
+	.global	v2
+	.section	.tdata,"awT",%progbits
+v1:
+	.word	0xdeaddead
+v2:
+	.word	0xcafecafe
+
+	.text
+	ldrsh	x11, [x7, #:tprel_lo12:v2]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-555.d b/ld/testsuite/ld-aarch64/emit-relocs-555.d
new file mode 100644
index 0000000000000000000000000000000000000000..e866b6034c4405edaf4459f2b0aa22697458075a
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-555.d
@@ -0,0 +1,9 @@
+#source: emit-relocs-555.s
+#ld: -T relocs.ld -e0 --emit-relocs
+#objdump: -dr
+#...
+0000000000010000 <.text>:
+   10000:	798029d6 	ldrsh	x22, \[x14, #20\]
+			10000: R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC	v2
+   10004:	79a73a28 	ldrsh	x8, \[x17, #5020\]
+			10004: R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC	v3
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-555.s b/ld/testsuite/ld-aarch64/emit-relocs-555.s
new file mode 100644
index 0000000000000000000000000000000000000000..b21e6ce4f9e3a37ef14abfd4f6ad76c48fdc3937
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-555.s
@@ -0,0 +1,17 @@
+	.global	v1
+	.global	v2
+	.size	v2, 5000
+	.global	v3
+	.section	.tdata,"awT",%progbits
+v1:
+	.word	0xdeaddead
+v2:
+	.zero	5000
+v3:
+	.word	0xcafecafe
+
+	.text
+	ldrsh	x22, [x14, #:tprel_lo12_nc:v2]
+
+	# should not issue overflow error.
+	ldrsh	x8, [x17, #:tprel_lo12_nc:v3]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-556-overflow.d b/ld/testsuite/ld-aarch64/emit-relocs-556-overflow.d
new file mode 100644
index 0000000000000000000000000000000000000000..2c789c1012f2916a3199af8c7b33c9dae976785c
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-556-overflow.d
@@ -0,0 +1,4 @@
+#source: emit-relocs-556-overflow.s
+#ld: -T relocs.ld -e0 --emit-relocs
+#objdump: -dr
+#error: .*\(.text\+0x\d+\): relocation truncated to fit: R_AARCH64_TLSLE_LDST32_TPREL_LO12 against symbol `v2' .*
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-556-overflow.s b/ld/testsuite/ld-aarch64/emit-relocs-556-overflow.s
new file mode 100644
index 0000000000000000000000000000000000000000..9b8e5d778cd124d3a9ab0db3a9c5f0c6c6be2777
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-556-overflow.s
@@ -0,0 +1,11 @@
+	.global	v1
+	.size	v1, 4096
+	.global	v2
+	.section	.tdata,"awT",%progbits
+v1:
+	.zero	4096
+v2:
+	.word	0xcafecafe
+
+	.text
+	ldrsw  x2, [x17, #:tprel_lo12:v2]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-556.d b/ld/testsuite/ld-aarch64/emit-relocs-556.d
new file mode 100644
index 0000000000000000000000000000000000000000..9a35dcff8ff0d8fad2acc872c5c062643b8710a1
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-556.d
@@ -0,0 +1,7 @@
+#source: emit-relocs-556.s
+#ld: -T relocs.ld -e0 --emit-relocs
+#objdump: -dr
+#...
+0000000000010000 <.text>:
+   10000:	b9801661 	ldrsw	x1, \[x19, #20\]
+			10000: R_AARCH64_TLSLE_LDST32_TPREL_LO12	v2
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-556.s b/ld/testsuite/ld-aarch64/emit-relocs-556.s
new file mode 100644
index 0000000000000000000000000000000000000000..bb083154fd6554a456fd3dfe412fe997e59f4c57
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-556.s
@@ -0,0 +1,10 @@
+	.global	v1
+	.global	v2
+	.section	.tdata,"awT",%progbits
+v1:
+	.word	0xdeaddead
+v2:
+	.word	0xcafecafe
+
+	.text
+	ldrsw	x1, [x19, #:tprel_lo12:v2]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-557.d b/ld/testsuite/ld-aarch64/emit-relocs-557.d
new file mode 100644
index 0000000000000000000000000000000000000000..286f44895e955a502f42f9a8e35903da2f7986f9
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-557.d
@@ -0,0 +1,9 @@
+#source: emit-relocs-557.s
+#ld: -T relocs.ld -e0 --emit-relocs
+#objdump: -dr
+#...
+0000000000010000 <.text>:
+   10000:	b98015d6 	ldrsw	x22, \[x14, #20\]
+			10000: R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC	v2
+   10004:	b9801628 	ldrsw	x8, \[x17, #20\]
+			10004: R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC	v3
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-557.s b/ld/testsuite/ld-aarch64/emit-relocs-557.s
new file mode 100644
index 0000000000000000000000000000000000000000..88dcdfad38b2841c1d5d8c3c0fdb713f0b06409a
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-557.s
@@ -0,0 +1,17 @@
+	.global	v1
+	.global	v2
+	.size	v2, 16384
+	.global	v3
+	.section	.tdata,"awT",%progbits
+v1:
+	.word	0xdeaddead
+v2:
+	.zero	16384
+v3:
+	.word	0xcafecafe
+
+	.text
+	ldrsw	x22, [x14, #:tprel_lo12_nc:v2]
+
+	# should not issue overflow error.
+	ldrsw	x8, [x17, #:tprel_lo12_nc:v3]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-558-overflow.d b/ld/testsuite/ld-aarch64/emit-relocs-558-overflow.d
new file mode 100644
index 0000000000000000000000000000000000000000..1746b629d8a4021e5080bfdd4ebede5e2ba61928
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-558-overflow.d
@@ -0,0 +1,4 @@
+#source: emit-relocs-558-overflow.s
+#ld: -T relocs.ld -e0 --emit-relocs
+#objdump: -dr
+#error: .*\(.text\+0x\d+\): relocation truncated to fit: R_AARCH64_TLSLE_LDST64_TPREL_LO12 against symbol `v2' .*
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-558-overflow.s b/ld/testsuite/ld-aarch64/emit-relocs-558-overflow.s
new file mode 100644
index 0000000000000000000000000000000000000000..82dfef67077d5ce307df53a3a31685be1fa214aa
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-558-overflow.s
@@ -0,0 +1,11 @@
+	.global	v1
+	.size	v1, 4096
+	.global	v2
+	.section	.tdata,"awT",%progbits
+v1:
+	.zero	4096
+v2:
+	.word	0xcafecafe
+
+	.text
+	ldr	x12, [x13, #:tprel_lo12:v2]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-558.d b/ld/testsuite/ld-aarch64/emit-relocs-558.d
new file mode 100644
index 0000000000000000000000000000000000000000..5bbee74271069a24b22be375895d494bf677345f
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-558.d
@@ -0,0 +1,7 @@
+#source: emit-relocs-558.s
+#ld: -T relocs.ld -e0 --emit-relocs
+#objdump: -dr
+#...
+0000000000010000 <.text>:
+   10000:	f9400d20 	ldr	x0, \[x9, #24\]
+			10000: R_AARCH64_TLSLE_LDST64_TPREL_LO12	v2
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-558.s b/ld/testsuite/ld-aarch64/emit-relocs-558.s
new file mode 100644
index 0000000000000000000000000000000000000000..0fe7593f9c35efc719164fd4cfad00cc2dca439e
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-558.s
@@ -0,0 +1,12 @@
+	.global	v1
+	.global	v2
+	.section	.tdata,"awT",%progbits
+v1:
+	.word	0xdeaddead
+	.word	0xdeaddead
+v2:
+	.word	0xcafecafe
+	.word	0xcafecafe
+
+	.text
+	ldr	x0, [x9, #:tprel_lo12:v2]
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-559.d b/ld/testsuite/ld-aarch64/emit-relocs-559.d
new file mode 100644
index 0000000000000000000000000000000000000000..b44d1b3ece2cd6724943063b6ed21f06af00926e
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-559.d
@@ -0,0 +1,9 @@
+#source: emit-relocs-559.s
+#ld: -T relocs.ld -e0 --emit-relocs
+#objdump: -dr
+#...
+0000000000010000 <.text>:
+   10000:	f9400c82 	ldr	x2, \[x4, #24\]
+			10000: R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC	v2
+   10004:	f9400e2e 	ldr	x14, \[x17, #24\]
+			10004: R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC	v3
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-559.s b/ld/testsuite/ld-aarch64/emit-relocs-559.s
new file mode 100644
index 0000000000000000000000000000000000000000..3548d79f935ca3ce2c31237447ebdb71c458e9ce
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/emit-relocs-559.s
@@ -0,0 +1,19 @@
+	.global	v1
+	.global	v2
+	.size	v2, 32768
+	.global	v3
+	.section	.tdata,"awT",%progbits
+v1:
+	.word	0xdeaddead
+	.word	0xdeaddead
+v2:
+	.zero	32768
+v3:
+	.word	0xcafecafe
+	.word	0xcafecafe
+
+	.text
+	ldr	x2, [x4, #:tprel_lo12_nc:v2]
+
+	# should not issue overflow error.
+	ldr	x14, [x17, #:tprel_lo12_nc:v3]

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]