ppc32 tlsopt tests

Alan Modra amodra@gmail.com
Fri Jul 14 13:23:00 GMT 2017


These all were odd in that they used r13 as the GOT pointer.  That
didn't matter for the purpose of testing, but would never occur in
practice.  Also, the tlsopt5 tests could have their global dynamic
sequences optimized to initial exec, so link with -shared.

	* testsuite/ld-powerpc/powerpc.exp: Add -shared to tlsop5 tests.
	* testsuite/ld-powerpc/tlsopt5.d: Adjust.
	* testsuite/ld-powerpc/tlsopt1_32.s: Use r30 as GOT pointer.
	* testsuite/ld-powerpc/tlsopt2_32.s: Likewise.
	* testsuite/ld-powerpc/tlsopt3_32.s: Likewise.
	* testsuite/ld-powerpc/tlsopt4_32.s: Likewise.
	* testsuite/ld-powerpc/tlsopt5_32.s: Rewrite.
	* testsuite/ld-powerpc/tlsopt1_32.d: Adjust.
	* testsuite/ld-powerpc/tlsopt2_32.d: Adjust.
	* testsuite/ld-powerpc/tlsopt3_32.d: Adjust.
	* testsuite/ld-powerpc/tlsopt5_32.d: Adjust.

diff --git a/ld/testsuite/ld-powerpc/powerpc.exp b/ld/testsuite/ld-powerpc/powerpc.exp
index f709b1e..9816eff 100644
--- a/ld/testsuite/ld-powerpc/powerpc.exp
+++ b/ld/testsuite/ld-powerpc/powerpc.exp
@@ -140,7 +140,7 @@ set ppcelftests {
       "tlsopt4_32"}
     {"TLS32 DLL" "-shared -melf32ppc --version-script tlsdll.ver" "" "-a32" {tlsdll_32.s}
      {} "tlsdll32.so"}
-    {"TLS32 opt 5" "-melf32ppc --gc-sections --secure-plt tmpdir/tlsdll32.so" "" "-a32"  {tlsopt5_32.s}
+    {"TLS32 opt 5" "-melf32ppc -shared --gc-sections --secure-plt tmpdir/tlsdll32.so" "" "-a32"  {tlsopt5_32.s}
      {{objdump -dr tlsopt5_32.d}}
       "tlsopt5_32"}
     {"Shared library with global symbol" "-shared -melf32ppc" "" "-a32" {sdalib.s}
@@ -210,7 +210,7 @@ set ppc64elftests {
       "tlsopt4"}
     {"TLS DLL" "-shared -melf64ppc --version-script tlsdll.ver" "" "-a64" {tlsdll.s}
      {} "tlsdll.so"}
-    {"TLS opt 5" "-melf64ppc --gc-sections --no-plt-localentry tmpdir/tlsdll.so" "" "-a64"  {tlsopt5.s}
+    {"TLS opt 5" "-melf64ppc -shared --gc-sections --no-plt-localentry tmpdir/tlsdll.so" "" "-a64"  {tlsopt5.s}
      {{objdump -dr tlsopt5.d}}
       "tlsopt5"}
     {"sym@tocbase" "-shared -melf64ppc" "" "-a64" {symtocbase-1.s symtocbase-2.s}
diff --git a/ld/testsuite/ld-powerpc/tlsopt1_32.d b/ld/testsuite/ld-powerpc/tlsopt1_32.d
index ec9c7ca..fd0f7eb 100644
--- a/ld/testsuite/ld-powerpc/tlsopt1_32.d
+++ b/ld/testsuite/ld-powerpc/tlsopt1_32.d
@@ -15,7 +15,7 @@ Disassembly of section \.text:
 Disassembly of section \.no_opt1:
 
 0+1800098 <\.no_opt1>:
-.*:	(38 6d ff f4|f4 ff 6d 38) 	addi    r3,r13,-12
+.*:	(38 7e ff f4|f4 ff 7e 38) 	addi    r3,r30,-12
 .*:	(2c 04 00 00|00 00 04 2c) 	cmpwi   r4,0
 .*:	(41 82 00 0c|0c 00 82 41) 	beq     .*
 .*:	(4b ff ff f1|f1 ff ff 4b) 	bl      1800094 <__tls_get_addr>
diff --git a/ld/testsuite/ld-powerpc/tlsopt1_32.s b/ld/testsuite/ld-powerpc/tlsopt1_32.s
index aba2bbc..79d6662 100644
--- a/ld/testsuite/ld-powerpc/tlsopt1_32.s
+++ b/ld/testsuite/ld-powerpc/tlsopt1_32.s
@@ -2,7 +2,7 @@
 # this section should not be optimised since we have old-style
 # __tls_get_addr without marker relocs, and the arg setup insn
 # is shared with two __tls_get_addr calls.
- addi 3,13,gd@got@tlsgd
+ addi 3,30,gd@got@tlsgd
  cmpwi 4,0
  beq 0f
  bl __tls_get_addr
diff --git a/ld/testsuite/ld-powerpc/tlsopt2_32.d b/ld/testsuite/ld-powerpc/tlsopt2_32.d
index baffe91..7dc1bce 100644
--- a/ld/testsuite/ld-powerpc/tlsopt2_32.d
+++ b/ld/testsuite/ld-powerpc/tlsopt2_32.d
@@ -15,9 +15,9 @@ Disassembly of section \.text:
 Disassembly of section \.no_opt2:
 
 0+1800098 <\.no_opt2>:
-.*:	(38 6d ff f4|f4 ff 6d 38) 	addi    r3,r13,-12
+.*:	(38 7e ff f4|f4 ff 7e 38) 	addi    r3,r30,-12
 .*:	(2c 04 00 00|00 00 04 2c) 	cmpwi   r4,0
 .*:	(41 82 00 08|08 00 82 41) 	beq     .*
-.*:	(38 6d ff f4|f4 ff 6d 38) 	addi    r3,r13,-12
+.*:	(38 7e ff f4|f4 ff 7e 38) 	addi    r3,r30,-12
 .*:	(4b ff ff ed|ed ff ff 4b) 	bl      1800094 <__tls_get_addr>
 #pass
diff --git a/ld/testsuite/ld-powerpc/tlsopt2_32.s b/ld/testsuite/ld-powerpc/tlsopt2_32.s
index bca1247..8c387d0 100644
--- a/ld/testsuite/ld-powerpc/tlsopt2_32.s
+++ b/ld/testsuite/ld-powerpc/tlsopt2_32.s
@@ -2,9 +2,9 @@
 # this section should not be optimised since we have old-style
 # __tls_get_addr without marker relocs, and two arg setup insns
 # feed into one __tls_get_addr call.
- addi 3,13,gd@got@tlsgd
+ addi 3,30,gd@got@tlsgd
  cmpwi 4,0
  beq 0f
- addi 3,13,gd@got@tlsgd
+ addi 3,30,gd@got@tlsgd
 0:
  bl __tls_get_addr
diff --git a/ld/testsuite/ld-powerpc/tlsopt3_32.d b/ld/testsuite/ld-powerpc/tlsopt3_32.d
index 55827a2..2bc999f 100644
--- a/ld/testsuite/ld-powerpc/tlsopt3_32.d
+++ b/ld/testsuite/ld-powerpc/tlsopt3_32.d
@@ -15,9 +15,9 @@ Disassembly of section \.text:
 Disassembly of section \.no_opt3:
 
 0+1800098 <\.no_opt3>:
-.*:	(38 6d ff ec|ec ff 6d 38) 	addi    r3,r13,-20
+.*:	(38 7e ff ec|ec ff 7e 38) 	addi    r3,r30,-20
 .*:	(48 00 00 0c|0c 00 00 48) 	b       .*
-.*:	(38 6d ff f4|f4 ff 6d 38) 	addi    r3,r13,-12
+.*:	(38 7e ff f4|f4 ff 7e 38) 	addi    r3,r30,-12
 .*:	(48 00 00 0c|0c 00 00 48) 	b       .*
 .*:	(4b ff ff ed|ed ff ff 4b) 	bl      1800094 <__tls_get_addr>
 .*:	(48 00 00 08|08 00 00 48) 	b       .*
diff --git a/ld/testsuite/ld-powerpc/tlsopt3_32.s b/ld/testsuite/ld-powerpc/tlsopt3_32.s
index 6432c24..c2b5fcd 100644
--- a/ld/testsuite/ld-powerpc/tlsopt3_32.s
+++ b/ld/testsuite/ld-powerpc/tlsopt3_32.s
@@ -5,9 +5,9 @@ gd0: .space 8
 
  .section ".no_opt3", "ax", %progbits
 # this section should also not be optimised
- addi 3,13,gd@got@tlsgd
+ addi 3,30,gd@got@tlsgd
  b 0f
- addi 3,13,gd0@got@tlsgd
+ addi 3,30,gd0@got@tlsgd
  b 1f
 0:
  bl __tls_get_addr
diff --git a/ld/testsuite/ld-powerpc/tlsopt4_32.s b/ld/testsuite/ld-powerpc/tlsopt4_32.s
index 9643fcb..762067e 100644
--- a/ld/testsuite/ld-powerpc/tlsopt4_32.s
+++ b/ld/testsuite/ld-powerpc/tlsopt4_32.s
@@ -4,7 +4,7 @@
 gd0: .space 8
 
  .section ".opt1", "ax", %progbits
- addi 3,13,gd@got@tlsgd
+ addi 3,30,gd@got@tlsgd
  cmpwi 4,0
  beq 0f
  bl __tls_get_addr(gd@tlsgd)
@@ -14,17 +14,17 @@ gd0: .space 8
 1:
 
  .section ".opt2", "ax", %progbits
- addi 3,13,gd@got@tlsgd
+ addi 3,30,gd@got@tlsgd
  cmpwi 4,0
  beq 0f
- addi 3,13,gd@got@tlsgd
+ addi 3,30,gd@got@tlsgd
 0:
  bl __tls_get_addr(gd@tlsgd)
 
  .section ".opt3", "ax", %progbits
- addi 3,13,gd@got@tlsgd
+ addi 3,30,gd@got@tlsgd
  b 0f
- addi 3,13,gd0@got@tlsgd
+ addi 3,30,gd0@got@tlsgd
  b 1f
 0:
  bl __tls_get_addr(gd@tlsgd)
diff --git a/ld/testsuite/ld-powerpc/tlsopt5.d b/ld/testsuite/ld-powerpc/tlsopt5.d
index b356a2e..7a74679 100644
--- a/ld/testsuite/ld-powerpc/tlsopt5.d
+++ b/ld/testsuite/ld-powerpc/tlsopt5.d
@@ -1,6 +1,6 @@
 #source: tlsopt5.s
 #as: -a64
-#ld: --gc-sections --no-plt-localentry tlsdll.so
+#ld: -shared --gc-sections --no-plt-localentry tlsdll.so
 #objdump: -dr
 #target: powerpc64*-*-*
 
@@ -8,7 +8,7 @@
 
 Disassembly of section \.text:
 
-0000000010000300 <.*\.plt_call\.__tls_get_addr_opt@@GLIBC_2\.22>:
+0+2c0 <.*\.plt_call\.__tls_get_addr_opt@@GLIBC_2\.22>:
 .*:	(00 00 63 e9|e9 63 00 00) 	ld      r11,0\(r3\)
 .*:	(08 00 83 e9|e9 83 00 08) 	ld      r12,8\(r3\)
 .*:	(78 1b 60 7c|7c 60 1b 78) 	mr      r0,r3
@@ -27,14 +27,14 @@ Disassembly of section \.text:
 .*:	(a6 03 68 7d|7d 68 03 a6) 	mtlr    r11
 .*:	(20 00 80 4e|4e 80 00 20) 	blr
 
-0000000010000344 <_start>:
+0+304 <_start>:
 .*:	(08 80 62 38|38 62 80 08) 	addi    r3,r2,-32760
 .*:	(b9 ff ff 4b|4b ff ff b9) 	bl      .*
 .*:	(00 00 00 60|60 00 00 00) 	nop
-.*:	(b8 02 01 00|00 00 00 00) 	.*
-.*:	(00 00 00 00|00 01 02 b8) 	.*
+.*:	(f8 01 01 00|00 00 00 00) 	.*
+.*:	(00 00 00 00|00 01 01 f8) 	.*
 
-0000000010000358 <__glink_PLTresolve>:
+0+318 <__glink_PLTresolve>:
 .*:	(a6 02 08 7c|7c 08 02 a6) 	mflr    r0
 .*:	(05 00 9f 42|42 9f 00 05) 	bcl     .*
 .*:	(a6 02 68 7d|7d 68 02 a6) 	mflr    r11
@@ -50,5 +50,5 @@ Disassembly of section \.text:
 .*:	(08 00 6b e9|e9 6b 00 08) 	ld      r11,8\(r11\)
 .*:	(20 04 80 4e|4e 80 04 20) 	bctr
 
-0000000010000390 <__tls_get_addr_opt@plt>:
+0+350 <__tls_get_addr_opt@plt>:
 .*:	(c8 ff ff 4b|4b ff ff c8) 	b       .*
diff --git a/ld/testsuite/ld-powerpc/tlsopt5_32.d b/ld/testsuite/ld-powerpc/tlsopt5_32.d
index 9749248..64acf10 100644
--- a/ld/testsuite/ld-powerpc/tlsopt5_32.d
+++ b/ld/testsuite/ld-powerpc/tlsopt5_32.d
@@ -1,6 +1,6 @@
 #source: tlsopt5_32.s
 #as: -a32
-#ld: --gc-sections --secure-plt tlsdll32.so
+#ld: -shared --gc-sections --secure-plt tlsdll32.so
 #objdump: -dr
 #target: powerpc*-*-*
 
@@ -8,12 +8,25 @@
 
 Disassembly of section \.text:
 
-01800230 <_start>:
-.*:	(f8 ff 6d 38|38 6d ff f8) 	addi    r3,r13,-8
-.*:	(0d 00 00 48|48 00 00 0d) 	bl      1800240 <__tls_get_addr_opt@plt>
-	\.\.\.
+0+200 <_start>:
+.*:	(f0 ff 21 94|94 21 ff f0) 	stwu    r1,-16\(r1\)
+.*:	(a6 02 08 7c|7c 08 02 a6) 	mflr    r0
+.*:	(05 00 9f 42|42 9f 00 05) 	bcl     .*
+.*:	(08 00 c1 93|93 c1 00 08) 	stw     r30,8\(r1\)
+.*:	(a6 02 c8 7f|7f c8 02 a6) 	mflr    r30
+.*:	(01 00 de 3f|3f de 00 01) 	addis   r30,r30,1
+.*:	(14 00 01 90|90 01 00 14) 	stw     r0,20\(r1\)
+.*:	(7c 01 de 3b|3b de 01 7c) 	addi    r30,r30,380
+.*:	(f8 ff 7e 38|38 7e ff f8) 	addi    r3,r30,-8
+.*:	(1d 00 00 48|48 00 00 1d) 	bl      240 <.*__tls_get_addr_opt.*>
+.*:	(14 00 01 80|80 01 00 14) 	lwz     r0,20\(r1\)
+.*:	(08 00 c1 83|83 c1 00 08) 	lwz     r30,8\(r1\)
+.*:	(a6 03 08 7c|7c 08 03 a6) 	mtlr    r0
+.*:	(10 00 21 38|38 21 00 10) 	addi    r1,r1,16
+.*:	(20 00 80 4e|4e 80 00 20) 	blr
+.*
 
-01800240 <__tls_get_addr_opt@plt>:
+0+240 <.*__tls_get_addr_opt.*>:
 .*:	(00 00 63 81|81 63 00 00) 	lwz     r11,0\(r3\)
 .*:	(04 00 83 81|81 83 00 04) 	lwz     r12,4\(r3\)
 .*:	(78 1b 60 7c|7c 60 1b 78) 	mr      r0,r3
@@ -22,31 +35,31 @@ Disassembly of section \.text:
 .*:	(20 00 82 4d|4d 82 00 20) 	beqlr   
 .*:	(78 03 03 7c|7c 03 03 78) 	mr      r3,r0
 .*:	(00 00 00 60|60 00 00 00) 	nop
-.*:	(81 01 60 3d|3d 60 01 81) 	lis     r11,385
-.*:	(9c 03 6b 81|81 6b 03 9c) 	lwz     r11,924\(r11\)
+.*:	(0c 00 7e 81|81 7e 00 0c) 	lwz     r11,12\(r30\)
 .*:	(a6 03 69 7d|7d 69 03 a6) 	mtctr   r11
 .*:	(20 04 80 4e|4e 80 04 20) 	bctr
+.*:	(00 00 00 60|60 00 00 00) 	nop
 
-01800270 <__glink>:
+0+270 <__glink>:
 .*:	(00 00 00 60|60 00 00 00) 	nop
 .*:	(00 00 00 60|60 00 00 00) 	nop
 .*:	(00 00 00 60|60 00 00 00) 	nop
 .*:	(00 00 00 60|60 00 00 00) 	nop
 
-01800280 <__glink_PLTresolve>:
-.*:	(81 01 80 3d|3d 80 01 81) 	lis     r12,385
-.*:	(80 fe 6b 3d|3d 6b fe 80) 	addis   r11,r11,-384
-.*:	(94 03 0c 80|80 0c 03 94) 	lwz     r0,916\(r12\)
-.*:	(90 fd 6b 39|39 6b fd 90) 	addi    r11,r11,-624
+0+280 <__glink_PLTresolve>:
+.*:	(00 00 6b 3d|3d 6b 00 00) 	addis   r11,r11,0
+.*:	(a6 02 08 7c|7c 08 02 a6) 	mflr    r0
+.*:	(05 00 9f 42|42 9f 00 05) 	bcl     .*
+.*:	(1c 00 6b 39|39 6b 00 1c) 	addi    r11,r11,28
+.*:	(a6 02 88 7d|7d 88 02 a6) 	mflr    r12
+.*:	(a6 03 08 7c|7c 08 03 a6) 	mtlr    r0
+.*:	(50 58 6c 7d|7d 6c 58 50) 	subf    r11,r12,r11
+.*:	(01 00 8c 3d|3d 8c 00 01) 	addis   r12,r12,1
+.*:	(00 01 0c 80|80 0c 01 00) 	lwz     r0,256\(r12\)
+.*:	(04 01 8c 81|81 8c 01 04) 	lwz     r12,260\(r12\)
 .*:	(a6 03 09 7c|7c 09 03 a6) 	mtctr   r0
 .*:	(14 5a 0b 7c|7c 0b 5a 14) 	add     r0,r11,r11
-.*:	(98 03 8c 81|81 8c 03 98) 	lwz     r12,920\(r12\)
 .*:	(14 5a 60 7d|7d 60 5a 14) 	add     r11,r0,r11
 .*:	(20 04 80 4e|4e 80 04 20) 	bctr
 .*:	(00 00 00 60|60 00 00 00) 	nop
 .*:	(00 00 00 60|60 00 00 00) 	nop
-.*:	(00 00 00 60|60 00 00 00) 	nop
-.*:	(00 00 00 60|60 00 00 00) 	nop
-.*:	(00 00 00 60|60 00 00 00) 	nop
-.*:	(00 00 00 60|60 00 00 00) 	nop
-.*:	(00 00 00 60|60 00 00 00) 	nop
diff --git a/ld/testsuite/ld-powerpc/tlsopt5_32.s b/ld/testsuite/ld-powerpc/tlsopt5_32.s
index 36b4858..d07b742 100644
--- a/ld/testsuite/ld-powerpc/tlsopt5_32.s
+++ b/ld/testsuite/ld-powerpc/tlsopt5_32.s
@@ -1,4 +1,18 @@
  .globl _start
 _start:
- addi 3,13,gd@got@tlsgd
- bl __tls_get_addr(gd@tlsgd)
+ stwu 1,-16(1)
+ mflr 0
+ bcl 20,31,.L2
+.L2:
+ stw 30,8(1)
+ mflr 30
+ addis 30,30,_GLOBAL_OFFSET_TABLE_-.L2@ha
+ stw 0,20(1)
+ addi 30,30,_GLOBAL_OFFSET_TABLE_-.L2@l
+ addi 3,30,gd@got@tlsgd
+ bl __tls_get_addr(gd@tlsgd)@plt
+ lwz 0,20(1)
+ lwz 30,8(1)
+ mtlr 0
+ addi 1,1,16
+ blr

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list