[PATCH 11/11] s390: Add linker TLS IE w/o GOT pointer using lgrl GOT access tests
Jens Remus
jremus@linux.ibm.com
Thu Nov 13 13:21:44 GMT 2025
On s390 64-bit (s390x) TLS IE variant without GOT pointer can
either use (1) a literal pool entry, (2) larl GOT access, or
(3) lgrl GOT access.
1. Sample for TLS IE variant without GOT pointer using literal pool
entry:
# Precond: TCB pointer in %r7, literal pool address in %r13
lg %r8,.L1-.L0(%r13)
lg %r9,0(%r8):tls_load:x # IE->LE: sllg %r9,%r8,0
la %r10,0(%r9,%r7) # %r10 = &x
...
.L0: # literal pool
.L1: .quad x@indntpoff # IE->LE: x@ntpoff
2. Sample for TLS IE variant without GOT pointer using larl GOT access:
# Precond: TCB pointer in %r7
larl %r8,x@indntpoff
lg %r9,0(%r8)
la %r10,0(%r9,%r7) # %r10 = &x
3. Sample for TLS IE variant without GOT pointer using lgrl GOT access:
# Precond: TCB pointer in %r7
lgrl %r8,x@indntpoff
la %r10,0(%r9,%r7) # %r10 = &x
Add linker tests for s390 64-bit (s390x) TLS IE variant without GOT
pointer using lgrl GOT access. This requires assembler option -Aesame
to be removed form the test, as the lgrl instruction is only available
starting with IBM z10. Remove the assembler option from all s390
64-bit (s390x) TLS tests.
While at it use an ellipsis instead of testing for all padding NOPs
in the expected test results, as their number changes. Do so in both
32-bit and 64-bit tests to keep them aligned.
ld/testsuite/
* ld-s390/s390.exp: Remove assembler option -Aesame from all
s390 64-bit (s390x) TLS tests to enable use of lgrl insn.
* ld-s390/tlsbinpic_64.s: Add TLS IE without GOT pointer using
lgrl GOT access tests.
* ld-s390/tlsbin_64.dd: Adapt expected test output patterns to
test changes. Use ellipsis instead of testing for all NOPs.
* ld-s390/tlsbin.dd: Use ellipsis instead of testing for all
padding NOPs.
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---
ld/testsuite/ld-s390/s390.exp | 4 ++--
ld/testsuite/ld-s390/tlsbin.dd | 8 +-------
ld/testsuite/ld-s390/tlsbin_64.dd | 24 ++++++++++++++----------
ld/testsuite/ld-s390/tlsbinpic_64.s | 16 ++++++++++++++++
4 files changed, 33 insertions(+), 19 deletions(-)
diff --git a/ld/testsuite/ld-s390/s390.exp b/ld/testsuite/ld-s390/s390.exp
index 74dd20b7d43c..75c9c054f011 100644
--- a/ld/testsuite/ld-s390/s390.exp
+++ b/ld/testsuite/ld-s390/s390.exp
@@ -85,7 +85,7 @@ set s390tests {
set s390xtests {
{"TLS -fpic -shared transitions" "-shared -melf64_s390 --hash-style=sysv --no-ld-generated-unwind-info" ""
- "-m64 -Aesame" {tlspic1_64.s tlspic2_64.s}
+ "-m64" {tlspic1_64.s tlspic2_64.s}
{{readelf -WSsrl tlspic_64.rd} {objdump -dzrj.text tlspic_64.dd}
{objdump -sj.got tlspic_64.sd} {objdump -sj.tdata tlspic_64.td}}
"libtlspic_64.so"}
@@ -93,7 +93,7 @@ set s390xtests {
"-m64 -Aesame" {tlslib_64.s} {} "libtlslib_64.so"}
{"TLS -fpic and -fno-pic exec transitions"
"-melf64_s390 tmpdir/libtlslib_64.so --hash-style=sysv --no-ld-generated-unwind-info" ""
- "-m64 -Aesame" {tlsbinpic_64.s tlsbin_64.s}
+ "-m64" {tlsbinpic_64.s tlsbin_64.s}
{{readelf -WSsrl tlsbin_64.rd} {objdump -dzrj.text tlsbin_64.dd}
{objdump -sj.got tlsbin_64.sd} {objdump -sj.tdata tlsbin_64.td}}
"tlsbin_64"}
diff --git a/ld/testsuite/ld-s390/tlsbin.dd b/ld/testsuite/ld-s390/tlsbin.dd
index 015a9eb1df2a..a211e3a3ae49 100644
--- a/ld/testsuite/ld-s390/tlsbin.dd
+++ b/ld/testsuite/ld-s390/tlsbin.dd
@@ -138,13 +138,7 @@ Disassembly of section .text:
+[0-9a-f]+: 98 6f f0 78 lm %r6,%r15,120\(%r15\)
+[0-9a-f]+: 07 fe br %r14
+[0-9a-f]+: 07 07 nopr %r7
- +[0-9a-f]+: 07 07 nopr %r7
- +[0-9a-f]+: 07 07 nopr %r7
- +[0-9a-f]+: 07 07 nopr %r7
- +[0-9a-f]+: 07 07 nopr %r7
- +[0-9a-f]+: 07 07 nopr %r7
- +[0-9a-f]+: 07 07 nopr %r7
- +[0-9a-f]+: 07 07 nopr %r7
+#...
0+[0-9a-f]+ <_start>:
# function prologue
diff --git a/ld/testsuite/ld-s390/tlsbin_64.dd b/ld/testsuite/ld-s390/tlsbin_64.dd
index f2b23b3643ad..fb99d343318c 100644
--- a/ld/testsuite/ld-s390/tlsbin_64.dd
+++ b/ld/testsuite/ld-s390/tlsbin_64.dd
@@ -145,6 +145,18 @@ Disassembly of section .text:
+[0-9a-f]+: c0 30 [0-9a-f ]+ larl %r3,[0-9a-f]+ <_GLOBAL_OFFSET_TABLE_\+0x38>
+[0-9a-f]+: e3 40 30 00 00 04 lg %r4,0\(%r3\)
+[0-9a-f]+: 41 54 90 00 la %r5,0\(%r4,%r9\)
+# IE against global var with lgrl got access
+ +[0-9a-f]+: c4 48 [0-9a-f ]+ lgrl %r4,[0-9a-f]+ <.*>
+ +[0-9a-f]+: 41 54 90 00 la %r5,0\(%r4,%r9\)
+# IE against global var defined in exec with lgrl got access
+ +[0-9a-f]+: c4 48 [0-9a-f ]+ lgrl %r4,[0-9a-f]+ <_GLOBAL_OFFSET_TABLE_\+0x30>
+ +[0-9a-f]+: 41 54 90 00 la %r5,0\(%r4,%r9\)
+# IE against local var with lgrl got access
+ +[0-9a-f]+: c4 48 [0-9a-f ]+ lgrl %r4,[0-9a-f]+ <_GLOBAL_OFFSET_TABLE_\+0x20>
+ +[0-9a-f]+: 41 54 90 00 la %r5,0\(%r4,%r9\)
+# IE against hidden var with lgrl got access
+ +[0-9a-f]+: c4 48 [0-9a-f ]+ lgrl %r4,[0-9a-f]+ <_GLOBAL_OFFSET_TABLE_\+0x38>
+ +[0-9a-f]+: 41 54 90 00 la %r5,0\(%r4,%r9\)
# IE against global var with small got access (no optimization)
+[0-9a-f]+: e3 30 c0 28 00 04 lg %r3,40\(%r12\)
+[0-9a-f]+: 41 33 90 00 la %r3,0\(%r3,%r9\)
@@ -162,15 +174,7 @@ Disassembly of section .text:
+[0-9a-f]+: eb 6f f0 d0 00 04 lmg %r6,%r15,208\(%r15\)
+[0-9a-f]+: 07 fe br %r14
+[0-9a-f]+: 07 07 nopr %r7
- +[0-9a-f]+: 07 07 nopr %r7
- +[0-9a-f]+: 07 07 nopr %r7
- +[0-9a-f]+: 07 07 nopr %r7
- +[0-9a-f]+: 07 07 nopr %r7
- +[0-9a-f]+: 07 07 nopr %r7
- +[0-9a-f]+: 07 07 nopr %r7
- +[0-9a-f]+: 07 07 nopr %r7
- +[0-9a-f]+: 07 07 nopr %r7
- +[0-9a-f]+: 07 07 nopr %r7
+#...
0+[0-9a-f]+ <_start>:
# function prologue
@@ -178,7 +182,7 @@ Disassembly of section .text:
+[0-9a-f]+: a7 d5 00 16 bras %r13,[0-9a-f]+ <_start\+0x32>
# sG6@indntpoff
+[0-9a-f]+: 00 00 00 00 .long 0x00000000
- +[0-9a-f]+: 01 00 18 28 .long 0x01001828
+ +[0-9a-f]+: 01 00 18 68 .long 0x01001868
# bg6@indntpoff -> bg6@ntpoff
+[0-9a-f]+: ff ff ff ff .long 0xffffffff
+[0-9a-f]+: ff ff ff d4 .long 0xffffffd4
diff --git a/ld/testsuite/ld-s390/tlsbinpic_64.s b/ld/testsuite/ld-s390/tlsbinpic_64.s
index 4b0c5020aa12..13aa233be315 100644
--- a/ld/testsuite/ld-s390/tlsbinpic_64.s
+++ b/ld/testsuite/ld-s390/tlsbinpic_64.s
@@ -163,6 +163,22 @@ fn2:
lg %r4,0(%r3)
la %r5,0(%r4,%r9)
+ /* IE against global var with lgrl got access */
+ lgrl %r4,sG3@indntpoff
+ la %r5,0(%r4,%r9)
+
+ /* IE against global var defined in exec with lgrl got access */
+ lgrl %r4,sg3@indntpoff
+ la %r5,0(%r4,%r9)
+
+ /* IE against local var with lgrl got access */
+ lgrl %r4,sl3@indntpoff
+ la %r5,0(%r4,%r9)
+
+ /* IE against hidden var with lgrl got access */
+ lgrl %r4,sh3@indntpoff
+ la %r5,0(%r4,%r9)
+
/* IE against global var with small got access (no optimization) */
lg %r3,sG3@gotntpoff(%r12)
la %r3,0(%r3,%r9)
--
2.48.1
More information about the Binutils
mailing list