PowerPC TLS tests

Message ID 20191007042752.GI7064@bubble.grove.modra.org
State New
Headers show
Series
  • PowerPC TLS tests
Related show

Commit Message

Alan Modra Oct. 7, 2019, 4:27 a.m.
This patch adds some --no-tls-optimize tests and performs some of the
existing dynamic tests with tls markers in order to catch any
regression in PLT counting.

	* testsuite/ld-powerpc/tlsexe.r: Adjust for added TLSMARK symbol.
	* testsuite/ld-powerpc/tlsexe32.r: Likewise.
	* testsuite/ld-powerpc/tlsso.r: Likewise.
	* testsuite/ld-powerpc/tlsso32.r: Likewise.
	* testsuite/ld-powerpc/tls32no.d,
	* testsuite/ld-powerpc/tls32no.g: New test files.
	* testsuite/ld-powerpc/tlsexe32no.d,
	* testsuite/ld-powerpc/tlsexe32no.g,
	* testsuite/ld-powerpc/tlsexe32no.r: New test files.
	* testsuite/ld-powerpc/tlsexeno.d,
	* testsuite/ld-powerpc/tlsexeno.g,
	* testsuite/ld-powerpc/tlsexeno.r: New test files.
	* testsuite/ld-powerpc/tlsexetocno.d,
	* testsuite/ld-powerpc/tlsexetocno.g: New test files.
	* testsuite/ld-powerpc/tlsno.d,
	* testsuite/ld-powerpc/tlsno.g: New test files.
	* testsuite/ld-powerpc/tlstocno.d,
	* testsuite/ld-powerpc/tlstocno.g: New test files.
	* testsuite/ld-powerpc/powerpc.exp: Run new tests.


-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/ld/testsuite/ld-powerpc/powerpc.exp b/ld/testsuite/ld-powerpc/powerpc.exp
index 87a7462fa0..bbd4813ebd 100644
--- a/ld/testsuite/ld-powerpc/powerpc.exp
+++ b/ld/testsuite/ld-powerpc/powerpc.exp
@@ -119,12 +119,21 @@  set ppcelftests {
      {{objdump -dr tls32.d} {objdump -sj.got tls32.g}
       {objdump -sj.tdata tls32.t}}
      "tls32"}
+    {"TLS32 static exec (--no-tls-optimize)" "-melf32ppc --no-tls-optimize" ""
+     "-a32 --defsym TLSMARK=1"  {tls32.s tlslib32.s}
+     {{objdump -dr tls32no.d} {objdump -sj.got tls32no.g}
+      {objdump -sj.tdata tls32.t}}
+     "tls32no"}
     {"TLS32 helper shared library" "-shared -melf32ppc tmpdir/tlslib32.o" "" "" {}
      {} "libtlslib32.so"}
     {"TLS32 dynamic exec" "-melf32ppc --no-plt-align --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tls32.o tmpdir/libtlslib32.so" "" "" {}
      {{readelf -WSsrl tlsexe32.r} {objdump -dr tlsexe32.d}
       {objdump -sj.got tlsexe32.g} {objdump -sj.tdata tlsexe32.t}}
      "tlsexe32"}
+    {"TLS32 dynamic exec (--no-tls-optimize)" "-melf32ppc --no-tls-optimize --no-plt-align --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tls32.o tmpdir/libtlslib32.so" "" "" {}
+     {{readelf -WSsrl tlsexe32no.r} {objdump -dr tlsexe32no.d}
+      {objdump -sj.got tlsexe32no.g} {objdump -sj.tdata tlsexe32.t}}
+     "tlsexe32no"}
     {"TLS32 shared" "-shared -melf32ppc --no-plt-align --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tls32.o" "" "" {}
      {{readelf -WSsrl tlsso32.r} {objdump -dr tlsso32.d}
       {objdump -sj.got tlsso32.g} {objdump -sj.tdata tlsso32.t}}
@@ -173,6 +182,10 @@  set ppc64elftests {
     {"TLS static exec" "-melf64ppc --no-plt-align" "" "-a64"  {tls.s tlslib.s}
      {{objdump -dr tls.d} {objdump -sj.got tls.g} {objdump -sj.tdata tls.t}}
      "tls"}
+    {"TLS static exec (--no-tls-optimize)" "-melf64ppc --no-tls-optimize --no-plt-align" ""
+     "-a64 --defsym TLSMARK=1"  {tls.s tlslib.s}
+     {{objdump -dr tlsno.d} {objdump -sj.got tlsno.g} {objdump -sj.tdata tls.t}}
+     "tlsno"}
     {"TLS helper shared library" "-shared -melf64ppc tmpdir/tlslib.o" "" "" {}
      {} "libtlslib.so"}
     {"TLS helper old shared lib" "-shared -melf64ppc" "" "-a64" {oldtlslib.s}
@@ -185,14 +198,22 @@  set ppc64elftests {
      {{readelf -WSsrl tlsexe.r} {objdump -dr tlsexe.d}
       {objdump -sj.got tlsexe.g} {objdump -sj.tdata tlsexe.t}}
      "tlsexeold"}
+    {"TLS dynamic exec (--no-tls-optimize)" "-melf64ppc --no-tls-optimize --no-plt-align --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tls.o tmpdir/libtlslib.so" "" "" {}
+     {{readelf -WSsrl tlsexeno.r} {objdump -dr tlsexeno.d}
+      {objdump -sj.got tlsexeno.g} {objdump -sj.tdata tlsexe.t}}
+     "tlsexeno"}
     {"TLS shared" "-shared -melf64ppc --no-plt-align --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tls.o" "" "" {}
      {{readelf -WSsrl tlsso.r} {objdump -dr tlsso.d}
       {objdump -sj.got tlsso.g} {objdump -sj.tdata tlsso.t}}
      "tls.so"}
-    {"TLSTOC static exec" "-melf64ppc tmpdir/tlslib.o " "" "-a64"  {tlstoc.s}
+    {"TLSTOC static exec" "-melf64ppc tmpdir/tlslib.o" "" "-a64"  {tlstoc.s}
      {{objdump -dr tlstoc.d} {objdump -sj.got tlstoc.g}
       {objdump -sj.tdata tlstoc.t}}
      "tlstoc"}
+    {"TLSTOC static exec (--no-tls-optimize)" "-melf64ppc --no-tls-optimize tmpdir/tlslib.o tmpdir/tlstoc.o" "" ""  {}
+     {{objdump -dr tlstocno.d} {objdump -sj.got tlstocno.g}
+      {objdump -sj.tdata tlstoc.t}}
+     "tlstocno"}
     {"TLSTOC dynamic exec" "-melf64ppc --no-plt-align --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tlstoc.o tmpdir/libtlslib.so" ""
      "" {}
      {{readelf -WSsrl tlsexetoc.r} {objdump -dr tlsexetoc.d}
@@ -203,6 +224,11 @@  set ppc64elftests {
      {{readelf -WSsrl tlsexetoc.r} {objdump -dr tlsexetoc.d}
       {objdump -sj.got tlsexetoc.g} {objdump -sj.tdata tlsexetoc.t}}
      "tlsexetocold"}
+    {"TLSTOC dynamic exec (--no-tls-optimize)" "-melf64ppc --no-tls-optimize --no-plt-align --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tlstoc.o tmpdir/libtlslib.so" ""
+     "" {}
+     {{readelf -WSsrl tlsexetoc.r} {objdump -dr tlsexetocno.d}
+      {objdump -sj.got tlsexetocno.g} {objdump -sj.tdata tlsexetoc.t}}
+     "tlsexetocno"}
     {"TLSTOC shared" "-shared -melf64ppc --no-plt-align --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tlstoc.o" "" "" {}
      {{readelf -WSsrl tlstocso.r} {objdump -dr tlstocso.d}
       {objdump -sj.got tlstocso.g} {objdump -sj.tdata tlstocso.t}}
diff --git a/ld/testsuite/ld-powerpc/tls32no.d b/ld/testsuite/ld-powerpc/tls32no.d
new file mode 100644
index 0000000000..a840936dd2
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tls32no.d
@@ -0,0 +1,47 @@ 
+#source: tls32.s
+#source: tlslib32.s
+#as: -a32
+#ld: --no-tls-optimize
+#objdump: -dr
+#target: powerpc*-*-*
+
+.*
+
+Disassembly of section \.text:
+
+0+18000a0 <_start>:
+.*:	(42 9f 00 05|05 00 9f 42) 	bcl     .*
+.*:	(7f c8 02 a6|a6 02 c8 7f) 	mflr    r30
+.*:	(3f de 00 02|02 00 de 3f) 	addis   r30,r30,2
+.*:	(3b de 80 a0|a0 80 de 3b) 	addi    r30,r30,-32608
+.*:	(38 7f ff e4|e4 ff 7f 38) 	addi    r3,r31,-28
+.*:	(48 00 00 6d|6d 00 00 48) 	bl      .*
+.*:	(38 7f ff f8|f8 ff 7f 38) 	addi    r3,r31,-8
+.*:	(48 00 00 65|65 00 00 48) 	bl      .*
+.*:	(38 7f ff ec|ec ff 7f 38) 	addi    r3,r31,-20
+.*:	(48 00 00 5d|5d 00 00 48) 	bl      .*
+.*:	(38 7f ff f8|f8 ff 7f 38) 	addi    r3,r31,-8
+.*:	(48 00 00 55|55 00 00 48) 	bl      .*
+.*:	(39 23 80 24|24 80 23 39) 	addi    r9,r3,-32732
+.*:	(3d 23 00 00|00 00 23 3d) 	addis   r9,r3,0
+.*:	(81 49 80 28|28 80 49 81) 	lwz     r10,-32728\(r9\)
+.*:	(81 3f ff f4|f4 ff 3f 81) 	lwz     r9,-12\(r31\)
+.*:	(7d 49 12 2e|2e 12 49 7d) 	lhzx    r10,r9,r2
+.*:	(89 42 90 34|34 90 42 89) 	lbz     r10,-28620\(r2\)
+.*:	(3d 22 00 00|00 00 22 3d) 	addis   r9,r2,0
+.*:	(99 49 90 38|38 90 49 99) 	stb     r10,-28616\(r9\)
+.*:	(38 7e ff dc|dc ff 7e 38) 	addi    r3,r30,-36
+.*:	(48 00 00 2d|2d 00 00 48) 	bl      .*
+.*:	(38 7e ff f8|f8 ff 7e 38) 	addi    r3,r30,-8
+.*:	(48 00 00 25|25 00 00 48) 	bl      .*
+.*:	(91 43 80 04|04 80 43 91) 	stw     r10,-32764\(r3\)
+.*:	(3d 23 00 00|00 00 23 3d) 	addis   r9,r3,0
+.*:	(91 49 80 08|08 80 49 91) 	stw     r10,-32760\(r9\)
+.*:	(81 3e ff f4|f4 ff 3e 81) 	lwz     r9,-12\(r30\)
+.*:	(7d 49 13 2e|2e 13 49 7d) 	sthx    r10,r9,r2
+.*:	(a1 42 90 14|14 90 42 a1) 	lhz     r10,-28652\(r2\)
+.*:	(3d 22 00 00|00 00 22 3d) 	addis   r9,r2,0
+.*:	(a9 49 90 18|18 90 49 a9) 	lha     r10,-28648\(r9\)
+
+0+1800120 <__tls_get_addr>:
+.*:	(4e 80 00 20|20 00 80 4e) 	blr
diff --git a/ld/testsuite/ld-powerpc/tls32no.g b/ld/testsuite/ld-powerpc/tls32no.g
new file mode 100644
index 0000000000..b0e5f5aea3
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tls32no.g
@@ -0,0 +1,13 @@ 
+#source: tls32.s
+#source: tlslib32.s
+#as: -a32
+#ld: --no-tls-optimize
+#objdump: -sj.got
+#target: powerpc*-*-*
+
+.*
+
+Contents of section \.got:
+ 1810144 (0+01 f+8000 0+01 f+803c|010+ 0080f+ 010+ 3c80f+)  .*
+ 1810154 (0+01 f+8020 f+9030 0+01|010+ 2080f+ 3090f+ 010+)  .*
+ 1810164 0+ 0+ 0+ 0+0  .*
diff --git a/ld/testsuite/ld-powerpc/tlsexe.r b/ld/testsuite/ld-powerpc/tlsexe.r
index aecf0fff52..a2a129d954 100644
--- a/ld/testsuite/ld-powerpc/tlsexe.r
+++ b/ld/testsuite/ld-powerpc/tlsexe.r
@@ -84,6 +84,7 @@  Symbol table '\.symtab' contains [0-9]+ entries:
 .* SECTION +LOCAL +DEFAULT +12 *
 .* SECTION +LOCAL +DEFAULT +13 *
 .* FILE +LOCAL +DEFAULT +ABS .*
+.* NOTYPE +LOCAL +DEFAULT +ABS TLSMARK
 .* TLS +LOCAL +DEFAULT +8 gd4
 .* TLS +LOCAL +DEFAULT +8 ld4
 .* TLS +LOCAL +DEFAULT +8 ld5
diff --git a/ld/testsuite/ld-powerpc/tlsexe32.r b/ld/testsuite/ld-powerpc/tlsexe32.r
index 23045c8ab6..112acde933 100644
--- a/ld/testsuite/ld-powerpc/tlsexe32.r
+++ b/ld/testsuite/ld-powerpc/tlsexe32.r
@@ -82,6 +82,7 @@  Symbol table '\.symtab' contains [0-9]+ entries:
 .* SECTION +LOCAL +DEFAULT +11 
 .* SECTION +LOCAL +DEFAULT +12 
 .* FILE +LOCAL +DEFAULT +ABS .*
+.* NOTYPE +LOCAL +DEFAULT +ABS TLSMARK
 .* TLS +LOCAL +DEFAULT +8 gd4
 .* TLS +LOCAL +DEFAULT +8 ld4
 .* TLS +LOCAL +DEFAULT +8 ld5
diff --git a/ld/testsuite/ld-powerpc/tlsexe32no.d b/ld/testsuite/ld-powerpc/tlsexe32no.d
new file mode 100644
index 0000000000..ae35d9e63e
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsexe32no.d
@@ -0,0 +1,75 @@ 
+#source: tls32.s
+#as: -a32
+#ld: --no-tls-optimize tmpdir/libtlslib32.so
+#objdump: -dr
+#target: powerpc*-*-*
+
+.*
+
+Disassembly of section \.text:
+
+.* <_start>:
+.*:	(42 9f 00 05|05 00 9f 42) 	bcl     .*
+.*:	(7f c8 02 a6|a6 02 c8 7f) 	mflr    r30
+.*:	(3f de 00 02|02 00 de 3f) 	addis   r30,r30,2
+.*:	(3b de 81 08|08 81 de 3b) 	addi    r30,r30,-32504
+.*:	(38 7f ff dc|dc ff 7f 38) 	addi    r3,r31,-36
+.*:	(48 00 00 6d|6d 00 00 48) 	bl      .*
+.*:	(38 7f ff e4|e4 ff 7f 38) 	addi    r3,r31,-28
+.*:	(48 00 00 65|65 00 00 48) 	bl      .*
+.*:	(38 7f ff ec|ec ff 7f 38) 	addi    r3,r31,-20
+.*:	(48 00 00 5d|5d 00 00 48) 	bl      .*
+.*:	(38 7f ff f8|f8 ff 7f 38) 	addi    r3,r31,-8
+.*:	(48 00 00 55|55 00 00 48) 	bl      .*
+.*:	(39 23 80 20|20 80 23 39) 	addi    r9,r3,-32736
+.*:	(3d 23 00 00|00 00 23 3d) 	addis   r9,r3,0
+.*:	(81 49 80 24|24 80 49 81) 	lwz     r10,-32732\(r9\)
+.*:	(81 3f ff f4|f4 ff 3f 81) 	lwz     r9,-12\(r31\)
+.*:	(7d 49 12 2e|2e 12 49 7d) 	lhzx    r10,r9,r2
+.*:	(89 42 90 30|30 90 42 89) 	lbz     r10,-28624\(r2\)
+.*:	(3d 22 00 00|00 00 22 3d) 	addis   r9,r2,0
+.*:	(99 49 90 34|34 90 49 99) 	stb     r10,-28620\(r9\)
+.*:	(38 7e ff d4|d4 ff 7e 38) 	addi    r3,r30,-44
+.*:	(48 00 00 2d|2d 00 00 48) 	bl      .*
+.*:	(38 7e ff f8|f8 ff 7e 38) 	addi    r3,r30,-8
+.*:	(48 00 00 25|25 00 00 48) 	bl      .*
+.*:	(91 43 80 04|04 80 43 91) 	stw     r10,-32764\(r3\)
+.*:	(3d 23 00 00|00 00 23 3d) 	addis   r9,r3,0
+.*:	(91 49 80 08|08 80 49 91) 	stw     r10,-32760\(r9\)
+.*:	(81 3e ff f4|f4 ff 3e 81) 	lwz     r9,-12\(r30\)
+.*:	(7d 49 13 2e|2e 13 49 7d) 	sthx    r10,r9,r2
+.*:	(a1 42 90 14|14 90 42 a1) 	lhz     r10,-28652\(r2\)
+.*:	(3d 22 00 00|00 00 22 3d) 	addis   r9,r2,0
+.*:	(a9 49 90 18|18 90 49 a9) 	lha     r10,-28648\(r9\)
+
+.* <__tls_get_addr_opt@plt>:
+.*:	(81 63 00 00|00 00 63 81) 	lwz     r11,0\(r3\)
+.*:	(81 83 00 04|04 00 83 81) 	lwz     r12,4\(r3\)
+.*:	(7c 60 1b 78|78 1b 60 7c) 	mr      r0,r3
+.*:	(2c 0b 00 00|00 00 0b 2c) 	cmpwi   r11,0
+.*:	(7c 6c 12 14|14 12 6c 7c) 	add     r3,r12,r2
+.*:	(4d 82 00 20|20 00 82 4d) 	beqlr
+.*:	(7c 03 03 78|78 03 03 7c) 	mr      r3,r0
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(3d 60 01 81|81 01 60 3d) 	lis     r11,385
+.*:	(81 6b 03 c4|c4 03 6b 81) 	lwz     r11,964\(r11\)
+.*:	(7d 69 03 a6|a6 03 69 7d) 	mtctr   r11
+.*:	(4e 80 04 20|20 04 80 4e) 	bctr
+
+.* <__glink>:
+.*:	(3d 80 01 81|81 01 80 3d) 	lis     r12,385
+.*:	(3d 6b fe 80|80 fe 6b 3d) 	addis   r11,r11,-384
+.*:	(80 0c 03 bc|bc 03 0c 80) 	lwz     r0,956\(r12\)
+.*:	(39 6b fd 80|80 fd 6b 39) 	addi    r11,r11,-640
+.*:	(7c 09 03 a6|a6 03 09 7c) 	mtctr   r0
+.*:	(7c 0b 5a 14|14 5a 0b 7c) 	add     r0,r11,r11
+.*:	(81 8c 03 c0|c0 03 8c 81) 	lwz     r12,960\(r12\)
+.*:	(7d 60 5a 14|14 5a 60 7d) 	add     r11,r0,r11
+.*:	(4e 80 04 20|20 04 80 4e) 	bctr
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(60 00 00 00|00 00 00 60) 	nop
diff --git a/ld/testsuite/ld-powerpc/tlsexe32no.g b/ld/testsuite/ld-powerpc/tlsexe32no.g
new file mode 100644
index 0000000000..db1f7a94c9
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsexe32no.g
@@ -0,0 +1,13 @@ 
+#source: tls32.s
+#as: -a32
+#ld: --no-tls-optimize tmpdir/libtlslib32.so
+#objdump: -sj.got
+#target: powerpc*-*-*
+
+.*
+
+Contents of section \.got:
+.* (0+01 f+8000 0+ 0+|010+ 0080f+ 0+ 0+)  .*
+.* (0+ 0+ 0+01 f+801c|0+ 0+ 010+ 1c80f+)  .*
+.* (f+902c 0+01 0+ 018102dc|2c90f+ 010+ 0+ dc028101)  .*
+.* 0+ 0+  .*
diff --git a/ld/testsuite/ld-powerpc/tlsexe32no.r b/ld/testsuite/ld-powerpc/tlsexe32no.r
new file mode 100644
index 0000000000..4658b7d4ec
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsexe32no.r
@@ -0,0 +1,111 @@ 
+#source: tls32.s
+#source: tlslib32.s
+#as: -a32
+#ld: --no-tls-optimize
+#readelf: -WSsrl
+#target: powerpc*-*-*
+
+There are [0-9]+ section headers, starting at offset 0x[0-9a-f]+:
+
+Section Headers:
+ +\[Nr\] Name +Type +Addr +Off +Size +ES Flg Lk Inf Al
+ +\[[ 0-9]+\] +NULL +0+ 0+ 0+ 00 +0 +0 +0
+ +\[[ 0-9]+\] \.interp +.*
+ +\[[ 0-9]+\] \.hash +.*
+ +\[[ 0-9]+\] \.dynsym +.*
+ +\[[ 0-9]+\] \.dynstr +.*
+ +\[[ 0-9]+\] \.rela\.dyn +.*
+ +\[[ 0-9]+\] \.rela\.plt +.*
+ +\[[ 0-9]+\] \.text +PROGBITS +[0-9a-f]+ [0-9a-f]+ 0000f0 00 +AX +0 +0 +16
+ +\[[ 0-9]+\] \.tdata +PROGBITS +[0-9a-f]+ [0-9a-f]+ 00001c 00 WAT +0 +0 +4
+ +\[[ 0-9]+\] \.tbss +NOBITS +[0-9a-f]+ [0-9a-f]+ 00001c 00 WAT +0 +0 +4
+ +\[[ 0-9]+\] \.dynamic +DYNAMIC +[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 08 +WA +4 +0 +4
+ +\[[ 0-9]+\] \.got +PROGBITS +[0-9a-f]+ [0-9a-f]+ 000038 04 +WA +0 +0 +4
+ +\[[ 0-9]+\] \.plt +PROGBITS +[0-9a-f]+ [0-9a-f]+ 000004 00 +WA +0 +0 +4
+ +\[[ 0-9]+\] \.symtab +SYMTAB +.*
+ +\[[ 0-9]+\] \.strtab +STRTAB +.*
+ +\[[ 0-9]+\] \.shstrtab +STRTAB +.*
+#...
+
+Elf file type is EXEC \(Executable file\)
+Entry point .*
+There are [0-9]+ program headers, starting at offset [0-9]+
+
+Program Headers:
+ +Type +Offset +VirtAddr +PhysAddr +FileSiz MemSiz +Flg Align
+ +PHDR +0x000034 0x01800034 0x01800034 0x000c0 0x000c0 R +0x4
+ +INTERP +0x0000f4 0x018000f4 0x018000f4 0x00011 0x00011 R +0x1
+ +\[Requesting program interpreter: .*\]
+ +LOAD .* R E 0x10000
+ +LOAD .* RW +0x10000
+ +DYNAMIC .* RW +0x4
+ +TLS .* 0x0001c 0x00038 R +0x4
+
+ Section to Segment mapping:
+ +Segment Sections\.\.\.
+ +00 +
+ +01 +\.interp 
+ +02 +\.interp \.hash \.dynsym \.dynstr \.rela\.dyn \.rela\.plt \.text 
+ +03 +\.tdata \.dynamic \.got \.plt 
+ +04 +\.dynamic 
+ +05 +\.tdata \.tbss 
+
+Relocation section '\.rela\.dyn' at offset .* contains 3 entries:
+ Offset +Info +Type +Sym\. Value +Symbol's Name \+ Addend
+[0-9a-f ]+R_PPC_DTPMOD32 +0+ +gd \+ 0
+[0-9a-f ]+R_PPC_DTPREL32 +0+ +gd \+ 0
+[0-9a-f ]+R_PPC_DTPMOD32 +0+ +ld \+ 0
+
+Relocation section '\.rela\.plt' at offset .* contains 1 entry:
+ Offset +Info +Type +Sym\. Value +Symbol's Name \+ Addend
+[0-9a-f ]+R_PPC_JMP_SLOT[0-9a-f ]+__tls_get_addr_opt \+ 0
+
+Symbol table '\.dynsym' contains [0-9]+ entries:
+ +Num: +Value +Size +Type +Bind +Vis +Ndx +Name
+.* NOTYPE +LOCAL +DEFAULT +UND 
+.* TLS +GLOBAL +DEFAULT +UND gd
+.* TLS +GLOBAL +DEFAULT +UND ld
+.* FUNC +GLOBAL +DEFAULT +UND __tls_get_addr_opt
+
+Symbol table '\.symtab' contains [0-9]+ entries:
+ +Num: +Value +Size +Type +Bind +Vis +Ndx +Name
+.* NOTYPE +LOCAL +DEFAULT +UND 
+.* SECTION +LOCAL +DEFAULT +1 
+.* SECTION +LOCAL +DEFAULT +2 
+.* SECTION +LOCAL +DEFAULT +3 
+.* SECTION +LOCAL +DEFAULT +4 
+.* SECTION +LOCAL +DEFAULT +5 
+.* SECTION +LOCAL +DEFAULT +6 
+.* SECTION +LOCAL +DEFAULT +7 
+.* SECTION +LOCAL +DEFAULT +8 
+.* SECTION +LOCAL +DEFAULT +9 
+.* SECTION +LOCAL +DEFAULT +10 
+.* SECTION +LOCAL +DEFAULT +11 
+.* SECTION +LOCAL +DEFAULT +12 
+.* FILE +LOCAL +DEFAULT +ABS .*
+.* NOTYPE +LOCAL +DEFAULT +ABS TLSMARK
+.* TLS +LOCAL +DEFAULT +8 gd4
+.* TLS +LOCAL +DEFAULT +8 ld4
+.* TLS +LOCAL +DEFAULT +8 ld5
+.* TLS +LOCAL +DEFAULT +8 ld6
+.* TLS +LOCAL +DEFAULT +8 ie4
+.* TLS +LOCAL +DEFAULT +8 le4
+.* TLS +LOCAL +DEFAULT +8 le5
+.* FILE +LOCAL +DEFAULT +ABS .*
+.* OBJECT +LOCAL +DEFAULT +10 _DYNAMIC
+.* OBJECT +LOCAL +DEFAULT +11 _GLOBAL_OFFSET_TABLE_
+.* TLS +GLOBAL +DEFAULT +UND gd
+.* TLS +GLOBAL +DEFAULT +9 le0
+.* TLS +GLOBAL +DEFAULT +9 ld0
+.* TLS +GLOBAL +DEFAULT +9 le1
+.* TLS +GLOBAL +DEFAULT +UND ld
+.* NOTYPE +GLOBAL +DEFAULT +7 _start
+.* NOTYPE +GLOBAL +DEFAULT +12 __end
+.* TLS +GLOBAL +DEFAULT +9 ld2
+.* TLS +GLOBAL +DEFAULT +9 ld1
+.* NOTYPE +GLOBAL +DEFAULT +12 __bss_start
+.* FUNC +GLOBAL +DEFAULT +UND __tls_get_addr_opt
+.* NOTYPE +GLOBAL +DEFAULT +12 _edata
+.* NOTYPE +GLOBAL +DEFAULT +12 _end
+.* TLS +GLOBAL +DEFAULT +9 gd0
+.* TLS +GLOBAL +DEFAULT +9 ie0
diff --git a/ld/testsuite/ld-powerpc/tlsexeno.d b/ld/testsuite/ld-powerpc/tlsexeno.d
new file mode 100644
index 0000000000..4c5248563b
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsexeno.d
@@ -0,0 +1,88 @@ 
+#source: tls.s
+#as: -a64
+#ld: --no-tls-optimize tmpdir/libtlslib.so
+#objdump: -dr
+#target: powerpc64*-*-*
+
+.*
+
+Disassembly of section \.text:
+
+.* <.*plt_call\.__tls_get_addr(|_opt)>:
+.*:	(e9 63 00 00|00 00 63 e9) 	ld      r11,0\(r3\)
+.*:	(e9 83 00 08|08 00 83 e9) 	ld      r12,8\(r3\)
+.*:	(7c 60 1b 78|78 1b 60 7c) 	mr      r0,r3
+.*:	(2c 2b 00 00|00 00 2b 2c) 	cmpdi   r11,0
+.*:	(7c 6c 6a 14|14 6a 6c 7c) 	add     r3,r12,r13
+.*:	(4d 82 00 20|20 00 82 4d) 	beqlr
+.*:	(7c 03 03 78|78 03 03 7c) 	mr      r3,r0
+.*:	(7d 68 02 a6|a6 02 68 7d) 	mflr    r11
+.*:	(f9 61 00 20|20 00 61 f9) 	std     r11,32\(r1\)
+.*:	(f8 41 00 28|28 00 41 f8) 	std     r2,40\(r1\)
+.*:	(e9 82 80 88|88 80 82 e9) 	ld      r12,-32632\(r2\)
+.*:	(7d 89 03 a6|a6 03 89 7d) 	mtctr   r12
+.*:	(e8 42 80 90|90 80 42 e8) 	ld      r2,-32624\(r2\)
+.*:	(4e 80 04 21|21 04 80 4e) 	bctrl
+.*:	(e8 41 00 28|28 00 41 e8) 	ld      r2,40\(r1\)
+.*:	(e9 61 00 20|20 00 61 e9) 	ld      r11,32\(r1\)
+.*:	(7d 68 03 a6|a6 03 68 7d) 	mtlr    r11
+.*:	(4e 80 00 20|20 00 80 4e) 	blr
+
+.* <\._start>:
+.*:	(38 62 80 20|20 80 62 38) 	addi    r3,r2,-32736
+.*:	(4b ff ff b5|b5 ff ff 4b) 	bl      .*
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(38 62 80 30|30 80 62 38) 	addi    r3,r2,-32720
+.*:	(4b ff ff a9|a9 ff ff 4b) 	bl      .*
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(38 62 80 48|48 80 62 38) 	addi    r3,r2,-32696
+.*:	(4b ff ff 9d|9d ff ff 4b) 	bl      .*
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(38 62 80 60|60 80 62 38) 	addi    r3,r2,-32672
+.*:	(4b ff ff 91|91 ff ff 4b) 	bl      .*
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(39 23 80 40|40 80 23 39) 	addi    r9,r3,-32704
+.*:	(3d 23 00 00|00 00 23 3d) 	addis   r9,r3,0
+.*:	(81 49 80 48|48 80 49 81) 	lwz     r10,-32696\(r9\)
+.*:	(e9 22 80 40|40 80 22 e9) 	ld      r9,-32704\(r2\)
+.*:	(7d 49 18 2a|2a 18 49 7d) 	ldx     r10,r9,r3
+.*:	(e9 22 80 58|58 80 22 e9) 	ld      r9,-32680\(r2\)
+.*:	(7d 49 6a 2e|2e 6a 49 7d) 	lhzx    r10,r9,r13
+.*:	(89 4d 90 60|60 90 4d 89) 	lbz     r10,-28576\(r13\)
+.*:	(3d 2d 00 00|00 00 2d 3d) 	addis   r9,r13,0
+.*:	(99 49 90 68|68 90 49 99) 	stb     r10,-28568\(r9\)
+.*:	(38 62 80 08|08 80 62 38) 	addi    r3,r2,-32760
+.*:	(4b ff ff 5d|5d ff ff 4b) 	bl      .*
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(38 62 80 60|60 80 62 38) 	addi    r3,r2,-32672
+.*:	(4b ff ff 51|51 ff ff 4b) 	bl      .*
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(f9 43 80 08|08 80 43 f9) 	std     r10,-32760\(r3\)
+.*:	(3d 23 00 00|00 00 23 3d) 	addis   r9,r3,0
+.*:	(91 49 80 10|10 80 49 91) 	stw     r10,-32752\(r9\)
+.*:	(e9 22 80 18|18 80 22 e9) 	ld      r9,-32744\(r2\)
+.*:	(7d 49 19 2a|2a 19 49 7d) 	stdx    r10,r9,r3
+.*:	(e9 22 80 58|58 80 22 e9) 	ld      r9,-32680\(r2\)
+.*:	(7d 49 6b 2e|2e 6b 49 7d) 	sthx    r10,r9,r13
+.*:	(e9 4d 90 2a|2a 90 4d e9) 	lwa     r10,-28632\(r13\)
+.*:	(3d 2d 00 00|00 00 2d 3d) 	addis   r9,r13,0
+.*:	(a9 49 90 30|30 90 49 a9) 	lha     r10,-28624\(r9\)
+.*:	(00 00 00 00|c0 02 01 00) 	.*
+.*:	(00 01 02 c0|00 00 00 00) 	.*
+
+.* <__glink_PLTresolve>:
+.*:	(7d 88 02 a6|a6 02 88 7d) 	mflr    r12
+.*:	(42 9f 00 05|05 00 9f 42) 	bcl     .*
+.*:	(7d 68 02 a6|a6 02 68 7d) 	mflr    r11
+.*:	(e8 4b ff f0|f0 ff 4b e8) 	ld      r2,-16\(r11\)
+.*:	(7d 88 03 a6|a6 03 88 7d) 	mtlr    r12
+.*:	(7d 62 5a 14|14 5a 62 7d) 	add     r11,r2,r11
+.*:	(e9 8b 00 00|00 00 8b e9) 	ld      r12,0\(r11\)
+.*:	(e8 4b 00 08|08 00 4b e8) 	ld      r2,8\(r11\)
+.*:	(7d 89 03 a6|a6 03 89 7d) 	mtctr   r12
+.*:	(e9 6b 00 10|10 00 6b e9) 	ld      r11,16\(r11\)
+.*:	(4e 80 04 20|20 04 80 4e) 	bctr
+
+.* <__tls_get_addr_opt@plt>:
+.*:	(38 00 00 00|00 00 00 38) 	li      r0,0
+.*:	(4b ff ff d0|d0 ff ff 4b) 	b       .* <__glink_PLTresolve>
diff --git a/ld/testsuite/ld-powerpc/tlsexeno.g b/ld/testsuite/ld-powerpc/tlsexeno.g
new file mode 100644
index 0000000000..9d6dcb5601
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsexeno.g
@@ -0,0 +1,16 @@ 
+#source: tls.s
+#as: -a64
+#ld: --no-tls-optimize tmpdir/libtlslib.so
+#objdump: -sj.got
+#target: powerpc64*-*-*
+
+.*
+
+Contents of section \.got:
+.* (0+ 10018600 0+ 0+01|00860110 0+ 010+ 0+)  .*
+.* (f+ f+8000 f+ f+8018|0080f+ f+ 1880f+ f+)  .*
+.* 0+ 0+ 0+ 0+  .*
+.* 0+ 0+ 0+ 0+  .*
+.* (f+ f+8050 0+ 0+01|5080f+ f+ 010+ 0+)  .*
+.* (f+ f+8038 f+ f+9058|3880f+ f+ 5890f+ f+)  .*
+.* (0+ 0+01|010+ 0+) 0+0 0+  .*
diff --git a/ld/testsuite/ld-powerpc/tlsexeno.r b/ld/testsuite/ld-powerpc/tlsexeno.r
new file mode 100644
index 0000000000..c0f6620f67
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsexeno.r
@@ -0,0 +1,113 @@ 
+#source: tls.s
+#source: tlslib.s
+#as: -a64
+#ld: --no-tls-optimize
+#readelf: -WSsrl
+#target: powerpc64*-*-*
+
+There are [0-9]+ section headers, starting at offset 0x[0-9a-f]+:
+
+Section Headers:
+ +\[Nr\] Name +Type +Address +Off +Size +ES Flg Lk Inf Al
+ +\[[ 0-9]+\] +NULL +0+ 0+ 0+ 0+ +0 +0 +0
+ +\[[ 0-9]+\] \.interp +.*
+ +\[[ 0-9]+\] \.hash +.*
+ +\[[ 0-9]+\] \.dynsym +.*
+ +\[[ 0-9]+\] \.dynstr +.*
+ +\[[ 0-9]+\] \.rela\.dyn +.*
+ +\[[ 0-9]+\] \.rela\.plt +.*
+ +\[[ 0-9]+\] \.text +PROGBITS .* 0+11c 0+ +AX +0 +0 +32
+ +\[[ 0-9]+\] \.tdata +PROGBITS .* 0+38 0+ WAT +0 +0 +8
+ +\[[ 0-9]+\] \.tbss +NOBITS .* 0+38 0+ WAT +0 +0 +8
+ +\[[ 0-9]+\] \.dynamic +DYNAMIC .* 0+160 10 +WA +4 +0 +8
+ +\[[ 0-9]+\] \.opd .*
+ +\[[ 0-9]+\] \.got +PROGBITS .* 0+70 08 +WA +0 +0 +256
+ +\[[ 0-9]+\] \.plt +.*
+ +\[[ 0-9]+\] \.symtab +.*
+ +\[[ 0-9]+\] \.strtab +.*
+ +\[[ 0-9]+\] \.shstrtab +.*
+#...
+
+Elf file type is EXEC \(Executable file\)
+Entry point .*
+There are [0-9]+ program headers, starting at offset [0-9]+
+
+Program Headers:
+ +Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
+ +PHDR +0x0+40 0x0+10000040 0x0+10000040 0x0+150 0x0+150 R +0x8
+ +INTERP +0x0+190 0x0+10000190 0x0+10000190 0x0+11 0x0+11 R +0x1
+ +\[Requesting program interpreter: .*\]
+ +LOAD .* R E 0x10000
+ +LOAD .* RW +0x10000
+ +DYNAMIC .* RW +0x8
+ +TLS .* 0x0+38 0x0+70 R +0x8
+
+ Section to Segment mapping:
+ +Segment Sections\.\.\.
+ +0+ +
+ +01 +\.interp *
+ +02 +\.interp \.hash \.dynsym \.dynstr \.rela\.dyn \.rela\.plt \.text *
+ +03 +\.tdata \.dynamic \.opd \.got \.plt *
+ +04 +\.dynamic *
+ +05 +\.tdata \.tbss *
+
+Relocation section '\.rela\.dyn' at offset .* contains 3 entries:
+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
+[0-9a-f ]+R_PPC64_DTPMOD64 +0+ gd \+ 0
+[0-9a-f ]+R_PPC64_DTPREL64 +0+ gd \+ 0
+[0-9a-f ]+R_PPC64_DTPMOD64 +0+ ld \+ 0
+
+Relocation section '\.rela\.plt' at offset .* contains 1 entry:
+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
+[0-9a-f ]+R_PPC64_JMP_SLOT +0+ __tls_get_addr_opt \+ 0
+
+Symbol table '\.dynsym' contains [0-9]+ entries:
+ +Num: +Value +Size +Type +Bind +Vis +Ndx +Name
+.* NOTYPE +LOCAL +DEFAULT +UND *
+.* TLS +GLOBAL +DEFAULT +UND gd
+.* TLS +GLOBAL +DEFAULT +UND ld
+.* FUNC +GLOBAL +DEFAULT +UND __tls_get_addr_opt
+
+Symbol table '\.symtab' contains [0-9]+ entries:
+ +Num: +Value +Size +Type +Bind +Vis +Ndx +Name
+.* 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND *
+.* SECTION +LOCAL +DEFAULT +1 *
+.* SECTION +LOCAL +DEFAULT +2 *
+.* SECTION +LOCAL +DEFAULT +3 *
+.* SECTION +LOCAL +DEFAULT +4 *
+.* SECTION +LOCAL +DEFAULT +5 *
+.* SECTION +LOCAL +DEFAULT +6 *
+.* SECTION +LOCAL +DEFAULT +7 *
+.* SECTION +LOCAL +DEFAULT +8 *
+.* SECTION +LOCAL +DEFAULT +9 *
+.* SECTION +LOCAL +DEFAULT +10 *
+.* SECTION +LOCAL +DEFAULT +11 *
+.* SECTION +LOCAL +DEFAULT +12 *
+.* SECTION +LOCAL +DEFAULT +13 *
+.* FILE +LOCAL +DEFAULT +ABS .*
+.* NOTYPE +LOCAL +DEFAULT +ABS TLSMARK
+.* TLS +LOCAL +DEFAULT +8 gd4
+.* TLS +LOCAL +DEFAULT +8 ld4
+.* TLS +LOCAL +DEFAULT +8 ld5
+.* TLS +LOCAL +DEFAULT +8 ld6
+.* TLS +LOCAL +DEFAULT +8 ie4
+.* TLS +LOCAL +DEFAULT +8 le4
+.* TLS +LOCAL +DEFAULT +8 le5
+.* FILE +LOCAL +DEFAULT +ABS 
+.* OBJECT +LOCAL +DEFAULT +10 _DYNAMIC
+.* NOTYPE +LOCAL +DEFAULT +7 __glink_PLTresolve
+.* NOTYPE +LOCAL +DEFAULT +7 .*\.plt_call\.__tls_get_addr(|_opt)
+.* GLOBAL +DEFAULT +UND gd
+.* GLOBAL +DEFAULT +9 le0
+.* GLOBAL +DEFAULT +9 ld0
+.* GLOBAL +DEFAULT +9 le1
+.* GLOBAL +DEFAULT +UND ld
+.* FUNC +GLOBAL +DEFAULT +11 _start
+.* TLS +GLOBAL +DEFAULT +9 ld2
+.* TLS +GLOBAL +DEFAULT +9 ld1
+.* NOTYPE +GLOBAL +DEFAULT +13 __bss_start
+.* FUNC +GLOBAL +DEFAULT +UND __tls_get_addr_opt
+.* NOTYPE +GLOBAL +DEFAULT +13 _edata
+.* NOTYPE +GLOBAL +DEFAULT +13 _end
+.* TLS +GLOBAL +DEFAULT +9 gd0
+.* TLS +GLOBAL +DEFAULT +9 ie0
diff --git a/ld/testsuite/ld-powerpc/tlsexetocno.d b/ld/testsuite/ld-powerpc/tlsexetocno.d
new file mode 100644
index 0000000000..4f3b7a244d
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsexetocno.d
@@ -0,0 +1,72 @@ 
+#source: tlstoc.s
+#as: -a64
+#ld: --no-tls-optimize tmpdir/libtlslib.so
+#objdump: -dr
+#target: powerpc64*-*-*
+
+.*
+
+Disassembly of section \.text:
+
+.* <.*plt_call\.__tls_get_addr(|_opt)>:
+.*:	(e9 63 00 00|00 00 63 e9) 	ld      r11,0\(r3\)
+.*:	(e9 83 00 08|08 00 83 e9) 	ld      r12,8\(r3\)
+.*:	(7c 60 1b 78|78 1b 60 7c) 	mr      r0,r3
+.*:	(2c 2b 00 00|00 00 2b 2c) 	cmpdi   r11,0
+.*:	(7c 6c 6a 14|14 6a 6c 7c) 	add     r3,r12,r13
+.*:	(4d 82 00 20|20 00 82 4d) 	beqlr
+.*:	(7c 03 03 78|78 03 03 7c) 	mr      r3,r0
+.*:	(7d 68 02 a6|a6 02 68 7d) 	mflr    r11
+.*:	(f9 61 00 20|20 00 61 f9) 	std     r11,32\(r1\)
+.*:	(f8 41 00 28|28 00 41 f8) 	std     r2,40\(r1\)
+.*:	(e9 82 80 70|70 80 82 e9) 	ld      r12,-32656\(r2\)
+.*:	(7d 89 03 a6|a6 03 89 7d) 	mtctr   r12
+.*:	(e8 42 80 78|78 80 42 e8) 	ld      r2,-32648\(r2\)
+.*:	(4e 80 04 21|21 04 80 4e) 	bctrl
+.*:	(e8 41 00 28|28 00 41 e8) 	ld      r2,40\(r1\)
+.*:	(e9 61 00 20|20 00 61 e9) 	ld      r11,32\(r1\)
+.*:	(7d 68 03 a6|a6 03 68 7d) 	mtlr    r11
+.*:	(4e 80 00 20|20 00 80 4e) 	blr
+
+.* <\._start>:
+.*:	(38 62 80 08|08 80 62 38) 	addi    r3,r2,-32760
+.*:	(4b ff ff b5|b5 ff ff 4b) 	bl      .*
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(38 62 80 18|18 80 62 38) 	addi    r3,r2,-32744
+.*:	(4b ff ff a9|a9 ff ff 4b) 	bl      .*
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(38 62 80 28|28 80 62 38) 	addi    r3,r2,-32728
+.*:	(4b ff ff 9d|9d ff ff 4b) 	bl      .*
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(38 62 80 38|38 80 62 38) 	addi    r3,r2,-32712
+.*:	(4b ff ff 91|91 ff ff 4b) 	bl      .*
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(39 23 80 40|40 80 23 39) 	addi    r9,r3,-32704
+.*:	(3d 23 00 00|00 00 23 3d) 	addis   r9,r3,0
+.*:	(81 49 80 48|48 80 49 81) 	lwz     r10,-32696\(r9\)
+.*:	(e9 22 80 48|48 80 22 e9) 	ld      r9,-32696\(r2\)
+.*:	(7d 49 18 2a|2a 18 49 7d) 	ldx     r10,r9,r3
+.*:	(e9 22 80 50|50 80 22 e9) 	ld      r9,-32688\(r2\)
+.*:	(7d 49 6a 2e|2e 6a 49 7d) 	lhzx    r10,r9,r13
+.*:	(89 4d 90 60|60 90 4d 89) 	lbz     r10,-28576\(r13\)
+.*:	(3d 2d 00 00|00 00 2d 3d) 	addis   r9,r13,0
+.*:	(99 49 90 68|68 90 49 99) 	stb     r10,-28568\(r9\)
+.*:	(00 00 00 00|e8 02 01 00) 	.*
+.*:	(00 01 02 e8|00 00 00 00) 	.*
+
+.* <__glink_PLTresolve>:
+.*:	(7d 88 02 a6|a6 02 88 7d) 	mflr    r12
+.*:	(42 9f 00 05|05 00 9f 42) 	bcl     .*
+.*:	(7d 68 02 a6|a6 02 68 7d) 	mflr    r11
+.*:	(e8 4b ff f0|f0 ff 4b e8) 	ld      r2,-16\(r11\)
+.*:	(7d 88 03 a6|a6 03 88 7d) 	mtlr    r12
+.*:	(7d 62 5a 14|14 5a 62 7d) 	add     r11,r2,r11
+.*:	(e9 8b 00 00|00 00 8b e9) 	ld      r12,0\(r11\)
+.*:	(e8 4b 00 08|08 00 4b e8) 	ld      r2,8\(r11\)
+.*:	(7d 89 03 a6|a6 03 89 7d) 	mtctr   r12
+.*:	(e9 6b 00 10|10 00 6b e9) 	ld      r11,16\(r11\)
+.*:	(4e 80 04 20|20 04 80 4e) 	bctr
+
+.* <__tls_get_addr_opt@plt>:
+.*:	(38 00 00 00|00 00 00 38) 	li      r0,0
+.*:	(4b ff ff d0|d0 ff ff 4b) 	b       .* <__glink_PLTresolve>
diff --git a/ld/testsuite/ld-powerpc/tlsexetocno.g b/ld/testsuite/ld-powerpc/tlsexetocno.g
new file mode 100644
index 0000000000..122cc39cff
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsexetocno.g
@@ -0,0 +1,15 @@ 
+#source: tlstoc.s
+#as: -a64
+#ld: --no-tls-optimize tmpdir/libtlslib.so
+#objdump: -sj.got
+#target: powerpc64*-*-*
+
+.*
+
+Contents of section \.got:
+.* (0+ 10018600 0+ 0+|00860110 0+ 0+ 0+)  .*
+.* 0+ 0+ 0+ 0+  .*
+.* 0+ 0+ (0+ 0+01|010+ 0+)  .*
+.* (f+ f+8038 0+ 0+01|3880f+ f+ 010+ 0+)  .*
+.* 0+ 0+ (f+ f+8050|5080f+ f+)  .*
+.* (f+ f+9058|5890f+ f+)  .*
diff --git a/ld/testsuite/ld-powerpc/tlsno.d b/ld/testsuite/ld-powerpc/tlsno.d
new file mode 100644
index 0000000000..761c4ab87d
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsno.d
@@ -0,0 +1,53 @@ 
+#source: tls.s
+#source: tlslib.s
+#as: -a64
+#ld: --no-tls-optimize
+#objdump: -dr
+#target: powerpc64*-*-*
+
+.*
+
+Disassembly of section \.text:
+
+.* <\._start>:
+.*:	(38 62 80 20|20 80 62 38) 	addi    r3,r2,-32736
+.*:	(48 00 00 95|95 00 00 48) 	bl      .*
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(38 62 80 50|50 80 62 38) 	addi    r3,r2,-32688
+.*:	(48 00 00 89|89 00 00 48) 	bl      .*
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(38 62 80 38|38 80 62 38) 	addi    r3,r2,-32712
+.*:	(48 00 00 7d|7d 00 00 48) 	bl      .*
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(38 62 80 50|50 80 62 38) 	addi    r3,r2,-32688
+.*:	(48 00 00 71|71 00 00 48) 	bl      .*
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(39 23 80 48|48 80 23 39) 	addi    r9,r3,-32696
+.*:	(3d 23 00 00|00 00 23 3d) 	addis   r9,r3,0
+.*:	(81 49 80 50|50 80 49 81) 	lwz     r10,-32688\(r9\)
+.*:	(e9 22 80 30|30 80 22 e9) 	ld      r9,-32720\(r2\)
+.*:	(7d 49 18 2a|2a 18 49 7d) 	ldx     r10,r9,r3
+.*:	(e9 22 80 48|48 80 22 e9) 	ld      r9,-32696\(r2\)
+.*:	(7d 49 6a 2e|2e 6a 49 7d) 	lhzx    r10,r9,r13
+.*:	(89 4d 90 68|68 90 4d 89) 	lbz     r10,-28568\(r13\)
+.*:	(3d 2d 00 00|00 00 2d 3d) 	addis   r9,r13,0
+.*:	(99 49 90 70|70 90 49 99) 	stb     r10,-28560\(r9\)
+.*:	(38 62 80 08|08 80 62 38) 	addi    r3,r2,-32760
+.*:	(48 00 00 3d|3d 00 00 48) 	bl      .*
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(38 62 80 50|50 80 62 38) 	addi    r3,r2,-32688
+.*:	(48 00 00 31|31 00 00 48) 	bl      .*
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(f9 43 80 08|08 80 43 f9) 	std     r10,-32760\(r3\)
+.*:	(3d 23 00 00|00 00 23 3d) 	addis   r9,r3,0
+.*:	(91 49 80 10|10 80 49 91) 	stw     r10,-32752\(r9\)
+.*:	(e9 22 80 18|18 80 22 e9) 	ld      r9,-32744\(r2\)
+.*:	(7d 49 19 2a|2a 19 49 7d) 	stdx    r10,r9,r3
+.*:	(e9 22 80 48|48 80 22 e9) 	ld      r9,-32696\(r2\)
+.*:	(7d 49 6b 2e|2e 6b 49 7d) 	sthx    r10,r9,r13
+.*:	(e9 4d 90 2a|2a 90 4d e9) 	lwa     r10,-28632\(r13\)
+.*:	(3d 2d 00 00|00 00 2d 3d) 	addis   r9,r13,0
+.*:	(a9 49 90 30|30 90 49 a9) 	lha     r10,-28624\(r9\)
+
+.* <\.__tls_get_addr>:
+.*:	(4e 80 00 20|20 00 80 4e) 	blr
diff --git a/ld/testsuite/ld-powerpc/tlsno.g b/ld/testsuite/ld-powerpc/tlsno.g
new file mode 100644
index 0000000000..1e6b77d0a4
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsno.g
@@ -0,0 +1,16 @@ 
+#source: tls.s
+#source: tlslib.s
+#as: -a64
+#ld: --no-tls-optimize
+#objdump: -sj.got
+#target: powerpc64*-*-*
+
+.*
+
+Contents of section \.got:
+.* (0+ 10018200 0+ 0+01|00820110 0+ 010+ 0+)  .*
+.* (f+ f+8000 f+ f+8018|0080f+ f+ 1880f+ f+)  .*
+.* (0+ 0+01 f+ f+8078|010+ 0+ 7880f+ f+)  .*
+.* (f+ f+8058 0+ 0+01|5880f+ f+ 010+ 0+)  .*
+.* (f+ f+8040 f+ f+9060|4080f+ f+ 6090f+ f+)  .*
+.* (0+ 0+01|010+ 0+) 0+ 0+ .*
diff --git a/ld/testsuite/ld-powerpc/tlsso.r b/ld/testsuite/ld-powerpc/tlsso.r
index 94b8c3ccdf..573139dbca 100644
--- a/ld/testsuite/ld-powerpc/tlsso.r
+++ b/ld/testsuite/ld-powerpc/tlsso.r
@@ -104,6 +104,7 @@  Symbol table '\.symtab' contains [0-9]+ entries:
 .* SECTION +LOCAL +DEFAULT +11 *
 .* SECTION +LOCAL +DEFAULT +12 *
 .* FILE +LOCAL +DEFAULT +ABS .*
+.* NOTYPE +LOCAL +DEFAULT +ABS TLSMARK
 .* TLS +LOCAL +DEFAULT +7 gd4
 .* TLS +LOCAL +DEFAULT +7 ld4
 .* TLS +LOCAL +DEFAULT +7 ld5
diff --git a/ld/testsuite/ld-powerpc/tlsso32.r b/ld/testsuite/ld-powerpc/tlsso32.r
index 08fe4661f3..7c0d680acf 100644
--- a/ld/testsuite/ld-powerpc/tlsso32.r
+++ b/ld/testsuite/ld-powerpc/tlsso32.r
@@ -101,6 +101,7 @@  Symbol table '\.symtab' contains [0-9]+ entries:
 .* SECTION +LOCAL +DEFAULT +10 
 .* SECTION +LOCAL +DEFAULT +11 
 .* FILE +LOCAL +DEFAULT +ABS .*
+.* NOTYPE +LOCAL +DEFAULT +ABS TLSMARK
 .* TLS +LOCAL +DEFAULT +7 gd4
 .* TLS +LOCAL +DEFAULT +7 ld4
 .* TLS +LOCAL +DEFAULT +7 ld5
diff --git a/ld/testsuite/ld-powerpc/tlstocno.d b/ld/testsuite/ld-powerpc/tlstocno.d
new file mode 100644
index 0000000000..89f349e0ad
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlstocno.d
@@ -0,0 +1,37 @@ 
+#source: tlslib.s
+#source: tlstoc.s
+#as: -a64
+#ld: --no-tls-optimize
+#objdump: -dr
+#target: powerpc64*-*-*
+
+.*
+
+Disassembly of section \.text:
+
+.* <\.__tls_get_addr>:
+.*:	(4e 80 00 20|20 00 80 4e) 	blr
+
+.* <\._start>:
+.*:	(38 62 80 00|00 80 62 38) 	addi    r3,r2,-32768
+.*:	(4b ff ff f9|f9 ff ff 4b) 	bl      .*
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(38 62 80 10|10 80 62 38) 	addi    r3,r2,-32752
+.*:	(4b ff ff ed|ed ff ff 4b) 	bl      .*
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(38 62 80 20|20 80 62 38) 	addi    r3,r2,-32736
+.*:	(4b ff ff e1|e1 ff ff 4b) 	bl      .*
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(38 62 80 30|30 80 62 38) 	addi    r3,r2,-32720
+.*:	(4b ff ff d5|d5 ff ff 4b) 	bl      .*
+.*:	(60 00 00 00|00 00 00 60) 	nop
+.*:	(39 23 80 50|50 80 23 39) 	addi    r9,r3,-32688
+.*:	(3d 23 00 00|00 00 23 3d) 	addis   r9,r3,0
+.*:	(81 49 80 58|58 80 49 81) 	lwz     r10,-32680\(r9\)
+.*:	(e9 22 80 40|40 80 22 e9) 	ld      r9,-32704\(r2\)
+.*:	(7d 49 18 2a|2a 18 49 7d) 	ldx     r10,r9,r3
+.*:	(e9 22 80 48|48 80 22 e9) 	ld      r9,-32696\(r2\)
+.*:	(7d 49 6a 2e|2e 6a 49 7d) 	lhzx    r10,r9,r13
+.*:	(89 4d 90 70|70 90 4d 89) 	lbz     r10,-28560\(r13\)
+.*:	(3d 2d 00 00|00 00 2d 3d) 	addis   r9,r13,0
+.*:	(99 49 90 78|78 90 49 99) 	stb     r10,-28552\(r9\)
diff --git a/ld/testsuite/ld-powerpc/tlstocno.g b/ld/testsuite/ld-powerpc/tlstocno.g
new file mode 100644
index 0000000000..6b088627db
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlstocno.g
@@ -0,0 +1,15 @@ 
+#source: tlslib.s
+#source: tlstoc.s
+#as: -a64
+#ld: --no-tls-optimize
+#objdump: -sj.got
+#target: powerpc64*-*-*
+
+.*
+
+Contents of section \.got:
+.* (0+ 0+01 f+ f+8040|010+ 0+ 4080f+ f+)  .*
+.* (0+ 0+01|010+ 0+) 0+ 0+  .*
+.* (0+ 0+01 f+ f+8048|010+ 0+ 4880f+ f+)  .*
+.* (0+ 0+01|010+ 0+) 0+ 0+  .*
+.* (f+ f+8060 f+ f+9068|6080f+ f+ 6890f+ f+)  .*