aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorMatthew Malcomson <hardenedapple@gmail.com>2022-08-02 12:10:01 +0100
committerMatthew Malcomson <hardenedapple@gmail.com>2022-08-02 12:10:01 +0100
commit976f16630b1f7421d6693011333cf0f51417c498 (patch)
treed364d4f02f24f64f63d7421370d8a7f4c4bd202e /ld
parentb90e0b2f1b516ea32789ae3877830b518cb8ed60 (diff)
downloadgdb-976f16630b1f7421d6693011333cf0f51417c498.zip
gdb-976f16630b1f7421d6693011333cf0f51417c498.tar.gz
gdb-976f16630b1f7421d6693011333cf0f51417c498.tar.bz2
ld: aarch64: Adjust TLS relaxation condition
In aarch64_tls_transition_without_check and elfNN_aarch64_tls_relax we choose whether to perform a relaxation to an IE access model or an LE access model based on whether the symbol itself is marked as local (i.e. `h == NULL`). This is problematic in two ways. The first is that sometimes a global dynamic access can be relaxed to an initial exec access when creating a shared library, and if that happens on a local symbol then we currently relax it to a local exec access instead. This usually does not happen since we only relax an access if aarch64_can_relax_tls returns true and aarch64_can_relax_tls does not have the same problem. However, it can happen when we have seen both an IE and GD access on the same symbol. This case is exercised in the newly added testcase tls-relax-gd-ie-2. The second problem is that deciding based on whether the symbol is local misses the case when the symbol is global but is still non-interposable and known to be located in the executable. This happens on all global symbols in executables. This case is exercised in the newly added testcase tls-relax-ie-le-4. Here we adjust the condition we base our relaxation on so that we relax to local-exec if we are creating an executable and the relevant symbol we're accessing is stored inside that executable. -- Updating tests for new relaxation criteria Many of the tests added to check our relaxation to IE were implemented by taking advantage of the fact that we did not relax a global symbol defined in an executable. Since a global symbol defined in an executable is still not interposable, we know that a TLS version of such a symbol will be in the main TLS block. This means that we can perform a stronger relaxation on such symbols and relax their accesses to a local-exec access. Hence we have to update all tests that relied on the older suboptimal decision making. The two cases when we still would want to relax a general dynamic access to an initial exec one are: 1) When in a shared library and accessing a symbol which we have already seen accessed with an initial exec access sequence. 2) When in an executable and accessing a symbol defined in a shared library. Both of these require shared library support, which means that these tests are now only available on targets with that. I have chosen to switch the existing testcases from a plain executable to one dynamically linked to a shared object as that doesn't require changing the testcases quite so much (just requires accessing a different variable rather than requiring adding another code sequence). The tls-relax-all testcase was an outlier to the above approach, since it included a general dynamic access to both a local and global symbol and inspected for the difference accordingly.
Diffstat (limited to 'ld')
-rw-r--r--ld/testsuite/ld-aarch64/aarch64-elf.exp41
-rw-r--r--ld/testsuite/ld-aarch64/tls-gd-symbolic.d20
-rw-r--r--ld/testsuite/ld-aarch64/tls-gd-symbolic.s27
-rw-r--r--ld/testsuite/ld-aarch64/tls-relax-all-ilp32.d8
-rw-r--r--ld/testsuite/ld-aarch64/tls-relax-all.d8
-rw-r--r--ld/testsuite/ld-aarch64/tls-relax-gd-ie-2.d27
-rw-r--r--ld/testsuite/ld-aarch64/tls-relax-gd-ie-2.s34
-rw-r--r--ld/testsuite/ld-aarch64/tls-relax-gd-ie-3.d29
-rw-r--r--ld/testsuite/ld-aarch64/tls-relax-gd-ie-ilp32.d2
-rw-r--r--ld/testsuite/ld-aarch64/tls-relax-gd-ie.d2
-rw-r--r--ld/testsuite/ld-aarch64/tls-relax-gd-ie.s4
-rw-r--r--ld/testsuite/ld-aarch64/tls-relax-gdesc-ie-2.d2
-rw-r--r--ld/testsuite/ld-aarch64/tls-relax-gdesc-ie-2.s5
-rw-r--r--ld/testsuite/ld-aarch64/tls-relax-gdesc-ie.d2
-rw-r--r--ld/testsuite/ld-aarch64/tls-relax-gdesc-ie.s4
-rw-r--r--ld/testsuite/ld-aarch64/tls-relax-ie-le-4.d20
-rw-r--r--ld/testsuite/ld-aarch64/tls-relax-ie-le-4.s22
-rw-r--r--ld/testsuite/ld-aarch64/tls-relax-large-desc-ie.d2
-rw-r--r--ld/testsuite/ld-aarch64/tls-relax-large-desc-ie.s5
-rw-r--r--ld/testsuite/ld-aarch64/tls-relax-large-gd-ie.d2
-rw-r--r--ld/testsuite/ld-aarch64/tls-relax-large-gd-ie.s5
-rw-r--r--ld/testsuite/ld-aarch64/tls-sharedlib.s4
-rw-r--r--ld/testsuite/ld-aarch64/tls-tiny-desc-ie-ilp32.d4
-rw-r--r--ld/testsuite/ld-aarch64/tls-tiny-desc-ie.d4
-rw-r--r--ld/testsuite/ld-aarch64/tls-tiny-desc-ie.s9
-rw-r--r--ld/testsuite/ld-aarch64/tls-tiny-gd-ie-ilp32.d4
-rw-r--r--ld/testsuite/ld-aarch64/tls-tiny-gd-ie.d4
-rw-r--r--ld/testsuite/ld-aarch64/tls-tiny-gd-ie.s9
28 files changed, 232 insertions, 77 deletions
diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp
index 3c45f87..337bead 100644
--- a/ld/testsuite/ld-aarch64/aarch64-elf.exp
+++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp
@@ -273,17 +273,8 @@ run_dump_test "tls-relax-gd-le-ilp32"
run_dump_test "tls-relax-gdesc-le"
run_dump_test "tls-relax-gdesc-le-now"
run_dump_test "tls-relax-gdesc-le-ilp32"
-run_dump_test "tls-relax-gd-ie"
-run_dump_test "tls-relax-gd-ie-ilp32"
-run_dump_test_lp64 "tls-relax-large-gd-ie"
-run_dump_test_lp64 "tls-relax-large-gd-ie-be"
run_dump_test_lp64 "tls-relax-large-gd-le"
run_dump_test_lp64 "tls-relax-large-gd-le-be"
-run_dump_test_lp64 "tls-relax-large-desc-ie"
-run_dump_test_lp64 "tls-relax-large-desc-ie-be"
-run_dump_test_lp64 "tls-relax-large-desc-le"
-run_dump_test_lp64 "tls-relax-large-desc-le-be"
-run_dump_test "tls-relax-gdesc-ie"
run_dump_test "tls-relax-ie-le"
run_dump_test "tls-relax-ie-le-ilp32"
run_dump_test "tls-relax-ld-le-small"
@@ -292,7 +283,6 @@ run_dump_test "tls-relax-ld-le-tiny"
run_dump_test "tls-relax-ld-le-tiny-ilp32"
run_dump_test "tls-desc-ie"
run_dump_test "tls-desc-ie-ilp32"
-run_dump_test "tls-relax-gdesc-ie-2"
run_dump_test "tls-relax-gdesc-le-2"
run_dump_test "tls-relax-gdesc-le-2-ilp32"
run_dump_test "tls-relax-ie-le-2"
@@ -300,13 +290,9 @@ run_dump_test "tls-relax-ie-le-2-ilp32"
run_dump_test "tls-relax-ie-le-3"
run_dump_test "tls-relax-ie-le-3-ilp32"
run_dump_test "tls-tiny-gd"
-run_dump_test "tls-tiny-gd-ie"
-run_dump_test "tls-tiny-gd-ie-ilp32"
run_dump_test "tls-tiny-gd-le"
run_dump_test "tls-tiny-gd-le-ilp32"
run_dump_test "tls-tiny-desc"
-run_dump_test "tls-tiny-desc-ie"
-run_dump_test "tls-tiny-desc-ie-ilp32"
run_dump_test "tls-tiny-desc-le"
run_dump_test "tls-tiny-desc-le-ilp32"
run_dump_test "tls-tiny-ie"
@@ -331,6 +317,33 @@ run_dump_test "protected-data"
run_dump_test_lp64 "pr22764"
run_dump_test_lp64 "pr20402"
+if {[check_shared_lib_support]
+ && [ld_assemble $as $srcdir/$subdir/tls-sharedlib.s tmpdir/tls-sharedlib.o]
+ && [ld_link $ld tmpdir/tls-sharedlib.so "-shared tmpdir/tls-sharedlib.o"] } {
+ run_dump_test "tls-relax-gd-ie"
+ run_dump_test_lp64 "tls-relax-large-gd-ie"
+ run_dump_test_lp64 "tls-relax-large-gd-ie-be"
+ run_dump_test_lp64 "tls-relax-large-desc-ie"
+ run_dump_test_lp64 "tls-relax-large-desc-ie-be"
+ run_dump_test_lp64 "tls-relax-large-desc-le"
+ run_dump_test_lp64 "tls-relax-large-desc-le-be"
+ run_dump_test "tls-relax-gdesc-ie"
+ run_dump_test "tls-relax-gdesc-ie-2"
+ run_dump_test "tls-tiny-gd-ie"
+ run_dump_test "tls-tiny-desc-ie"
+}
+if {[check_shared_lib_support]
+ && [ld_assemble_flags $as -mabi=ilp32 $srcdir/$subdir/tls-sharedlib.s tmpdir/tls-sharedlib.o]
+ && [ld_link $ld tmpdir/tls-sharedlib-ilp32.so "-shared tmpdir/tls-sharedlib.o -m [aarch64_choose_ilp32_emul]"] } {
+ run_dump_test "tls-relax-gd-ie-ilp32"
+ run_dump_test "tls-tiny-gd-ie-ilp32"
+ run_dump_test "tls-tiny-desc-ie-ilp32"
+}
+run_dump_test "tls-relax-gd-ie-2"
+run_dump_test "tls-relax-gd-ie-3"
+run_dump_test "tls-relax-ie-le-4"
+run_dump_test "tls-gd-symbolic"
+
# ifunc tests
run_dump_test "ifunc-1"
run_dump_test "ifunc-1-local"
diff --git a/ld/testsuite/ld-aarch64/tls-gd-symbolic.d b/ld/testsuite/ld-aarch64/tls-gd-symbolic.d
new file mode 100644
index 0000000..d6732ac
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/tls-gd-symbolic.d
@@ -0,0 +1,20 @@
+# Testcase to show that -Bsymbolic does not trigger any relaxation from general
+# dynamic or initial exec for global symbols.
+#target: [check_shared_lib_support]
+#ld: -shared -Bsymbolic
+#objdump: -d -j .text
+
+.*: file format .*
+
+
+Disassembly of section \.text:
+
+[0-9a-f]+ <_test_tls_desc>:
+ +[0-9a-f]+: ........ adrp x0, .*
+ +[0-9a-f]+: ........ ldr x1, \[x0, #.*\]
+ +[0-9a-f]+: ........ add x0, x0, .*
+ +[0-9a-f]+: d63f0020 blr x1
+
+[0-9a-f]+ <_test_tls_desc2>:
+ +[0-9a-f]+: ........ adrp x0, .*
+ +[0-9a-f]+: ........ ldr x0, \[x0, #.*\]
diff --git a/ld/testsuite/ld-aarch64/tls-gd-symbolic.s b/ld/testsuite/ld-aarch64/tls-gd-symbolic.s
new file mode 100644
index 0000000..d2ca5da
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/tls-gd-symbolic.s
@@ -0,0 +1,27 @@
+ # Demonstrating TLS relaxation behavior for -Bsymbolic linking.
+ # (i.e. no extra relaxation when using -Bsymbolic).
+ .global tlsdescvar
+ .global tlsdescvar2
+ .section .tbss,"awT",%nobits
+ .align 2
+ .type tlsdescvar, %object
+ .size tlsdescvar, 4
+tlsdescvar:
+ .zero 4
+ .type tlsdescvar2, %object
+ .size tlsdescvar2, 4
+tlsdescvar2:
+ .zero 4
+.text
+_test_tls_desc:
+
+ adrp x0, :tlsdesc:tlsdescvar
+ ldr x1, [x0, :tlsdesc_lo12:tlsdescvar]
+ add x0, x0, :tlsdesc_lo12:tlsdescvar
+ .tlsdesccall tlsdescvar
+ blr x1
+
+_test_tls_desc2:
+
+ adrp x0, :gottprel:tlsdescvar2
+ ldr x0, [x0, #:gottprel_lo12:tlsdescvar2]
diff --git a/ld/testsuite/ld-aarch64/tls-relax-all-ilp32.d b/ld/testsuite/ld-aarch64/tls-relax-all-ilp32.d
index 1cb4ef4..62faed4 100644
--- a/ld/testsuite/ld-aarch64/tls-relax-all-ilp32.d
+++ b/ld/testsuite/ld-aarch64/tls-relax-all-ilp32.d
@@ -5,8 +5,8 @@
#...
+10000: a9bf7bfd stp x29, x30, \[sp, #-16\]!
+10004: 910003fd mov x29, sp
- +10008: 90000080 adrp x0, 20000 <_GLOBAL_OFFSET_TABLE_>
- +1000c: b9400400 ldr w0, \[x0, #4\]
+ +10008: 52a00000 movz w0, #0x0, lsl #16
+ +1000c: 72800100 movk w0, #0x8
+10010: d503201f nop
+10014: d503201f nop
+10018: d53bd041 mrs x1, tpidr_el0
@@ -20,8 +20,8 @@
+10038: 8b000040 add x0, x2, x0
+1003c: b9400000 ldr w0, \[x0\]
+10040: 0b000021 add w1, w1, w0
- +10044: 90000080 adrp x0, 20000 <_GLOBAL_OFFSET_TABLE_>
- +10048: b9400800 ldr w0, \[x0, #8\]
+ +10044: 52a00000 movz w0, #0x0, lsl #16
+ +10048: 72800200 movk w0, #0x10
+1004c: d53bd041 mrs x1, tpidr_el0
+10050: 0b000020 add w0, w1, w0
+10054: b9400000 ldr w0, \[x0\]
diff --git a/ld/testsuite/ld-aarch64/tls-relax-all.d b/ld/testsuite/ld-aarch64/tls-relax-all.d
index 5942186..1262a99 100644
--- a/ld/testsuite/ld-aarch64/tls-relax-all.d
+++ b/ld/testsuite/ld-aarch64/tls-relax-all.d
@@ -4,8 +4,8 @@
#...
+10000: a9bf7bfd stp x29, x30, \[sp, #-16\]!
+10004: 910003fd mov x29, sp
- +10008: 90000080 adrp x0, 20000 <_GLOBAL_OFFSET_TABLE_>
- +1000c: f9400400 ldr x0, \[x0, #8\]
+ +10008: d2a00000 movz x0, #0x0, lsl #16
+ +1000c: f2800200 movk x0, #0x10
+10010: d503201f nop
+10014: d503201f nop
+10018: d53bd041 mrs x1, tpidr_el0
@@ -19,8 +19,8 @@
+10038: 8b000040 add x0, x2, x0
+1003c: b9400000 ldr w0, \[x0\]
+10040: 0b000021 add w1, w1, w0
- +10044: 90000080 adrp x0, 20000 <_GLOBAL_OFFSET_TABLE_>
- +10048: f9400800 ldr x0, \[x0, #16\]
+ +10044: d2a00000 movz x0, #0x0, lsl #16
+ +10048: f2800300 movk x0, #0x18
+1004c: d53bd041 mrs x1, tpidr_el0
+10050: 8b000020 add x0, x1, x0
+10054: b9400000 ldr w0, \[x0\]
diff --git a/ld/testsuite/ld-aarch64/tls-relax-gd-ie-2.d b/ld/testsuite/ld-aarch64/tls-relax-gd-ie-2.d
new file mode 100644
index 0000000..f0281b7
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/tls-relax-gd-ie-2.d
@@ -0,0 +1,27 @@
+# The linker recognises that if we have one IE access to a TLS symbol then all
+# accesses to that symbol could be IE. Here we are also interested to check
+# the linker does not also decide that a second access to that symbol could be
+# LE.
+#target: [check_shared_lib_support]
+#ld: -shared
+#objdump: -dr
+
+.*: file format .*
+
+
+Disassembly of section \.text:
+
+[0-9a-f]+ <foo>:
+ +[0-9a-f]+: d2800000 mov x0, #0x0 // #0
+ +[0-9a-f]+: d53bd041 mrs x1, tpidr_el0
+ +[0-9a-f]+: .* adrp x0, .*
+ +[0-9a-f]+: .* ldr x0, \[x0, #.*\]
+ +[0-9a-f]+: b8606820 ldr w0, \[x1, x0\]
+ +[0-9a-f]+: d53bd041 mrs x1, tpidr_el0
+ +[0-9a-f]+: 910003fd mov x29, sp
+ +[0-9a-f]+: .* adrp x0, .*
+ +[0-9a-f]+: .* ldr x0, \[x0, #.*\]
+ +[0-9a-f]+: d503201f nop
+ +[0-9a-f]+: d503201f nop
+ +[0-9a-f]+: b8606820 ldr w0, \[x1, x0\]
+ +[0-9a-f]+: d65f03c0 ret
diff --git a/ld/testsuite/ld-aarch64/tls-relax-gd-ie-2.s b/ld/testsuite/ld-aarch64/tls-relax-gd-ie-2.s
new file mode 100644
index 0000000..568ceb4
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/tls-relax-gd-ie-2.s
@@ -0,0 +1,34 @@
+ .section .tbss,"awT",@nobits
+ .align 2
+ .type y, %object
+ .size y, 4
+y:
+ .zero 4
+
+
+
+
+ .text
+ .global foo
+ .type foo, @function
+foo:
+ # Access the local symbol with an IE access.
+ mov x0, 0
+ mrs x1, tpidr_el0
+ adrp x0, :gottprel:y
+ ldr x0, [x0, #:gottprel_lo12:y]
+ ldr w0, [x1, x0]
+
+ # Also access the same symbol with a General Dynamic access.
+ # The linker should be able to recognise that if we're already
+ # accessing this symbol with an Initial Exec access then this General
+ # Dynamic access could be relaxed to an Initial Exec one too.
+ mrs x1, tpidr_el0
+ mov x29, sp
+ adrp x0, :tlsdesc:y
+ ldr x2, [x0, #:tlsdesc_lo12:y]
+ add x0, x0, :tlsdesc_lo12:y
+ .tlsdesccall y
+ blr x2
+ ldr w0, [x1, x0]
+ ret
diff --git a/ld/testsuite/ld-aarch64/tls-relax-gd-ie-3.d b/ld/testsuite/ld-aarch64/tls-relax-gd-ie-3.d
new file mode 100644
index 0000000..2e45ec9
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/tls-relax-gd-ie-3.d
@@ -0,0 +1,29 @@
+# The linker recognises that if we have one IE access to a TLS symbol then all
+# accesses to that symbol could be IE. Here we are also interested to check
+# the linker does not also decide that a second access to that symbol could be
+# LE.
+#source: tls-relax-gd-ie-2.s
+#target: [check_shared_lib_support]
+#ld: -shared -Bsymbolic
+#objdump: -dr
+
+.*: file format .*
+
+
+Disassembly of section \.text:
+
+[0-9a-f]+ <foo>:
+ +[0-9a-f]+: d2800000 mov x0, #0x0 // #0
+ +[0-9a-f]+: d53bd041 mrs x1, tpidr_el0
+ +[0-9a-f]+: .* adrp x0, .*
+ +[0-9a-f]+: .* ldr x0, \[x0, #.*\]
+ +[0-9a-f]+: b8606820 ldr w0, \[x1, x0\]
+ +[0-9a-f]+: d53bd041 mrs x1, tpidr_el0
+ +[0-9a-f]+: 910003fd mov x29, sp
+ +[0-9a-f]+: .* adrp x0, .*
+ +[0-9a-f]+: .* ldr x0, \[x0, #.*\]
+ +[0-9a-f]+: d503201f nop
+ +[0-9a-f]+: d503201f nop
+ +[0-9a-f]+: b8606820 ldr w0, \[x1, x0\]
+ +[0-9a-f]+: d65f03c0 ret
+
diff --git a/ld/testsuite/ld-aarch64/tls-relax-gd-ie-ilp32.d b/ld/testsuite/ld-aarch64/tls-relax-gd-ie-ilp32.d
index ab08c61..340206a 100644
--- a/ld/testsuite/ld-aarch64/tls-relax-gd-ie-ilp32.d
+++ b/ld/testsuite/ld-aarch64/tls-relax-gd-ie-ilp32.d
@@ -1,6 +1,6 @@
#source: tls-relax-gd-ie.s
#as: -mabi=ilp32
-#ld: -m [aarch64_choose_ilp32_emul] -T relocs-ilp32.ld -e0
+#ld: -m [aarch64_choose_ilp32_emul] -T relocs-ilp32.ld -e0 tmpdir/tls-sharedlib-ilp32.so
#objdump: -dr
#...
+10000: 90000080 adrp x0, 20000 <_GLOBAL_OFFSET_TABLE_>
diff --git a/ld/testsuite/ld-aarch64/tls-relax-gd-ie.d b/ld/testsuite/ld-aarch64/tls-relax-gd-ie.d
index f80bb90..0c03290 100644
--- a/ld/testsuite/ld-aarch64/tls-relax-gd-ie.d
+++ b/ld/testsuite/ld-aarch64/tls-relax-gd-ie.d
@@ -1,5 +1,5 @@
#source: tls-relax-gd-ie.s
-#ld: -T relocs.ld -e0
+#ld: -T relocs.ld -e0 tmpdir/tls-sharedlib.so
#objdump: -dr
#...
+10000: 90000080 adrp x0, 20000 <_GLOBAL_OFFSET_TABLE_>
diff --git a/ld/testsuite/ld-aarch64/tls-relax-gd-ie.s b/ld/testsuite/ld-aarch64/tls-relax-gd-ie.s
index 88c7eec..afe076c 100644
--- a/ld/testsuite/ld-aarch64/tls-relax-gd-ie.s
+++ b/ld/testsuite/ld-aarch64/tls-relax-gd-ie.s
@@ -1,7 +1,3 @@
- .global var
- .section .tdata,"awT",%progbits
-var:
- .word 2
.text
adrp x0, :tlsgd:var
add x0, x0, :tlsgd_lo12:var
diff --git a/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie-2.d b/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie-2.d
index 2b8e346..f13263f 100644
--- a/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie-2.d
+++ b/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie-2.d
@@ -1,5 +1,5 @@
#source: tls-relax-gdesc-ie-2.s
-#ld: -T relocs.ld -e0
+#ld: -T relocs.ld -e0 tmpdir/tls-sharedlib.so
#objdump: -dr
#...
+10000: 90000080 adrp x0, 20000 <_GLOBAL_OFFSET_TABLE_>
diff --git a/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie-2.s b/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie-2.s
index 790b6c6..f7be57c 100644
--- a/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie-2.s
+++ b/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie-2.s
@@ -1,9 +1,5 @@
// Test TLS Desc to TLS IE relaxation when instructions are not consecutive.
- .global var
- .section .tdata
-var:
- .word 2
.text
adrp x0, :tlsdesc:var
nop
@@ -20,5 +16,4 @@ var:
mrs x1, tpidr_el0
add x0, x1, x0
ldr w0, [x0]
- .global var
.section .tdata
diff --git a/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie.d b/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie.d
index 86277f8..1ace848 100644
--- a/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie.d
+++ b/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie.d
@@ -1,5 +1,5 @@
#source: tls-relax-gdesc-ie.s
-#ld: -T relocs.ld -e0
+#ld: -T relocs.ld -e0 tmpdir/tls-sharedlib.so
#objdump: -dr
#...
+10000: 90000080 adrp x0, 20000 <_GLOBAL_OFFSET_TABLE_>
diff --git a/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie.s b/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie.s
index 38b3721..089d36c 100644
--- a/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie.s
+++ b/ld/testsuite/ld-aarch64/tls-relax-gdesc-ie.s
@@ -1,7 +1,3 @@
- .global var
- .section .tdata
-var:
- .word 2
.text
adrp x0, :tlsdesc:var
ldr x17, [x0, #:tlsdesc_lo12:var]
diff --git a/ld/testsuite/ld-aarch64/tls-relax-ie-le-4.d b/ld/testsuite/ld-aarch64/tls-relax-ie-le-4.d
new file mode 100644
index 0000000..e2bc5f1
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/tls-relax-ie-le-4.d
@@ -0,0 +1,20 @@
+# We already test that we relax an access to a local symbol, this testcase
+# checks that we relax an access to a global-binding symbol if the static linker
+# knows that the symbol will resolve to the executable local value.
+#
+# The access should be relaxed to a LE access.
+#ld:
+#objdump: -d
+
+.*: file format .*
+
+
+Disassembly of section \.text:
+
+[0-9a-f]+ <_start>:
+ +[0-9a-f]+: d2800000 mov x0, #0x0 // #0
+ +[0-9a-f]+: d53bd041 mrs x1, tpidr_el0
+ +[0-9a-f]+: d2a00000 movz x0, #0x0, lsl #16
+ +[0-9a-f]+: f2800200 movk x0, #0x10
+ +[0-9a-f]+: b8606820 ldr w0, \[x1, x0\]
+ +[0-9a-f]+: d65f03c0 ret
diff --git a/ld/testsuite/ld-aarch64/tls-relax-ie-le-4.s b/ld/testsuite/ld-aarch64/tls-relax-ie-le-4.s
new file mode 100644
index 0000000..e151cd4
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/tls-relax-ie-le-4.s
@@ -0,0 +1,22 @@
+# Test TLS IE to TLS LE relaxation for global symbols.
+ .section .tbss,"awT",@nobits
+ .global x
+ .align 2
+ .type x, %object
+ .size x, 4
+x:
+ .zero 4
+
+
+
+ .text
+ .global _start
+ .type _start, @function
+_start:
+ mov x0, 0
+ mrs x1, tpidr_el0
+ adrp x0, :gottprel:x
+ ldr x0, [x0, #:gottprel_lo12:x]
+ ldr w0, [x1, x0]
+ ret
+
diff --git a/ld/testsuite/ld-aarch64/tls-relax-large-desc-ie.d b/ld/testsuite/ld-aarch64/tls-relax-large-desc-ie.d
index 21ad5e5..cb546ad 100644
--- a/ld/testsuite/ld-aarch64/tls-relax-large-desc-ie.d
+++ b/ld/testsuite/ld-aarch64/tls-relax-large-desc-ie.d
@@ -1,5 +1,5 @@
#source: tls-relax-large-desc-ie.s
-#ld: -T relocs.ld -e0
+#ld: -T relocs.ld -e0 tmpdir/tls-sharedlib.so
#notarget: aarch64_be-*-*
#objdump: -dr
#...
diff --git a/ld/testsuite/ld-aarch64/tls-relax-large-desc-ie.s b/ld/testsuite/ld-aarch64/tls-relax-large-desc-ie.s
index a4d1e00..98dc2a5 100644
--- a/ld/testsuite/ld-aarch64/tls-relax-large-desc-ie.s
+++ b/ld/testsuite/ld-aarch64/tls-relax-large-desc-ie.s
@@ -1,8 +1,3 @@
- .global var
- .section .tdata,"awT",%progbits
-var:
- .word 2
-
.text
test:
ldr x1, .Lgot
diff --git a/ld/testsuite/ld-aarch64/tls-relax-large-gd-ie.d b/ld/testsuite/ld-aarch64/tls-relax-large-gd-ie.d
index 2b398db..740178d 100644
--- a/ld/testsuite/ld-aarch64/tls-relax-large-gd-ie.d
+++ b/ld/testsuite/ld-aarch64/tls-relax-large-gd-ie.d
@@ -1,5 +1,5 @@
#source: tls-relax-large-gd-ie.s
-#ld: -T relocs.ld -e0
+#ld: -T relocs.ld -e0 tmpdir/tls-sharedlib.so
#notarget: aarch64_be-*-*
#objdump: -dr
#...
diff --git a/ld/testsuite/ld-aarch64/tls-relax-large-gd-ie.s b/ld/testsuite/ld-aarch64/tls-relax-large-gd-ie.s
index 8e0310d..d35aace 100644
--- a/ld/testsuite/ld-aarch64/tls-relax-large-gd-ie.s
+++ b/ld/testsuite/ld-aarch64/tls-relax-large-gd-ie.s
@@ -1,8 +1,3 @@
- .global var
- .section .tdata,"awT",%progbits
-var:
- .word 2
-
.text
test:
ldr x1, .Lgot
diff --git a/ld/testsuite/ld-aarch64/tls-sharedlib.s b/ld/testsuite/ld-aarch64/tls-sharedlib.s
new file mode 100644
index 0000000..8838b9f
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/tls-sharedlib.s
@@ -0,0 +1,4 @@
+ .global var
+ .section .tdata,"awT",@progbits
+var:
+ .word 2
diff --git a/ld/testsuite/ld-aarch64/tls-tiny-desc-ie-ilp32.d b/ld/testsuite/ld-aarch64/tls-tiny-desc-ie-ilp32.d
index ebbaf85..3dffa1b 100644
--- a/ld/testsuite/ld-aarch64/tls-tiny-desc-ie-ilp32.d
+++ b/ld/testsuite/ld-aarch64/tls-tiny-desc-ie-ilp32.d
@@ -1,12 +1,12 @@
#source: tls-tiny-desc-ie.s
#as: -mabi=ilp32
-#ld: -m [aarch64_choose_ilp32_emul] -T relocs-ilp32.ld -e0
+#ld: -m [aarch64_choose_ilp32_emul] -T relocs-ilp32.ld -e0 tmpdir/tls-sharedlib-ilp32.so
#objdump: -dr
#...
Disassembly of section .text:
00010000 \<test\>:
- +10000: 18080020 ldr w0, 20004 \<_GLOBAL_OFFSET_TABLE_\+0x4\>
+ +10000: 18080020 ldr w0, 20004 \<var\>
+10004: d503201f nop
+10008: d503201f nop
diff --git a/ld/testsuite/ld-aarch64/tls-tiny-desc-ie.d b/ld/testsuite/ld-aarch64/tls-tiny-desc-ie.d
index 0088539..e759ae9 100644
--- a/ld/testsuite/ld-aarch64/tls-tiny-desc-ie.d
+++ b/ld/testsuite/ld-aarch64/tls-tiny-desc-ie.d
@@ -1,11 +1,11 @@
#source: tls-tiny-desc-ie.s
-#ld: -T relocs.ld -e0
+#ld: -T relocs.ld -e0 tmpdir/tls-sharedlib.so
#objdump: -dr
#...
Disassembly of section .text:
0000000000010000 \<test\>:
- +10000: 58080040 ldr x0, 20008 \<_GLOBAL_OFFSET_TABLE_\+0x8\>
+ +10000: 58080040 ldr x0, 20008 \<var\>
+10004: d503201f nop
+10008: d503201f nop
diff --git a/ld/testsuite/ld-aarch64/tls-tiny-desc-ie.s b/ld/testsuite/ld-aarch64/tls-tiny-desc-ie.s
index 520cd4e..fcc970f 100644
--- a/ld/testsuite/ld-aarch64/tls-tiny-desc-ie.s
+++ b/ld/testsuite/ld-aarch64/tls-tiny-desc-ie.s
@@ -1,12 +1,3 @@
- .global var
-
- .section .tbss,"awT",%nobits
- .align 2
- .type var, %object
- .size var, 4
-var:
- .zero 4
-
.text
test:
ldr x1, :tlsdesc:var
diff --git a/ld/testsuite/ld-aarch64/tls-tiny-gd-ie-ilp32.d b/ld/testsuite/ld-aarch64/tls-tiny-gd-ie-ilp32.d
index 1ea6110..6317152 100644
--- a/ld/testsuite/ld-aarch64/tls-tiny-gd-ie-ilp32.d
+++ b/ld/testsuite/ld-aarch64/tls-tiny-gd-ie-ilp32.d
@@ -1,12 +1,12 @@
#source: tls-tiny-gd-ie.s
#as: -mabi=ilp32
-#ld: -m [aarch64_choose_ilp32_emul] -T relocs-ilp32.ld -e0
+#ld: -m [aarch64_choose_ilp32_emul] -T relocs-ilp32.ld -e0 tmpdir/tls-sharedlib-ilp32.so
#objdump: -dr
#...
Disassembly of section .text:
00010000 \<test\>:
- +10000: 18080020 ldr w0, 20004 \<_GLOBAL_OFFSET_TABLE_\+0x4\>
+ +10000: 18080020 ldr w0, 20004 \<var\>
+10004: d53bd041 mrs x1, tpidr_el0
+10008: 0b000020 add w0, w1, w0
diff --git a/ld/testsuite/ld-aarch64/tls-tiny-gd-ie.d b/ld/testsuite/ld-aarch64/tls-tiny-gd-ie.d
index 629d90c..66b996e 100644
--- a/ld/testsuite/ld-aarch64/tls-tiny-gd-ie.d
+++ b/ld/testsuite/ld-aarch64/tls-tiny-gd-ie.d
@@ -1,11 +1,11 @@
#source: tls-tiny-gd-ie.s
-#ld: -T relocs.ld -e0
+#ld: -T relocs.ld -e0 tmpdir/tls-sharedlib.so
#objdump: -dr
#...
Disassembly of section .text:
0000000000010000 \<test\>:
- +10000: 58080040 ldr x0, 20008 \<_GLOBAL_OFFSET_TABLE_\+0x8\>
+ +10000: 58080040 ldr x0, 20008 \<var\>
+10004: d53bd041 mrs x1, tpidr_el0
+10008: 8b000020 add x0, x1, x0
diff --git a/ld/testsuite/ld-aarch64/tls-tiny-gd-ie.s b/ld/testsuite/ld-aarch64/tls-tiny-gd-ie.s
index 4dc7e66..3ae4a0c 100644
--- a/ld/testsuite/ld-aarch64/tls-tiny-gd-ie.s
+++ b/ld/testsuite/ld-aarch64/tls-tiny-gd-ie.s
@@ -1,12 +1,3 @@
- .global var
-
- .section .tbss,"awT",%nobits
- .align 2
- .type var, %object
- .size var, 4
-var:
- .zero 4
-
.text
test:
adr x0, :tlsgd:var