aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ld/testsuite/ChangeLog31
-rw-r--r--ld/testsuite/ld-powerpc/powerpc.exp56
-rw-r--r--ld/testsuite/ld-powerpc/tls.d53
-rw-r--r--ld/testsuite/ld-powerpc/tls.g12
-rw-r--r--ld/testsuite/ld-powerpc/tls.s92
-rw-r--r--ld/testsuite/ld-powerpc/tls.t14
-rw-r--r--ld/testsuite/ld-powerpc/tlsexe.d49
-rw-r--r--ld/testsuite/ld-powerpc/tlsexe.g12
-rw-r--r--ld/testsuite/ld-powerpc/tlsexe.r120
-rw-r--r--ld/testsuite/ld-powerpc/tlsexe.t13
-rw-r--r--ld/testsuite/ld-powerpc/tlsexetoc.d33
-rw-r--r--ld/testsuite/ld-powerpc/tlsexetoc.g14
-rw-r--r--ld/testsuite/ld-powerpc/tlsexetoc.r121
-rw-r--r--ld/testsuite/ld-powerpc/tlsexetoc.t13
-rw-r--r--ld/testsuite/ld-powerpc/tlslib.s20
-rw-r--r--ld/testsuite/ld-powerpc/tlsso.d68
-rw-r--r--ld/testsuite/ld-powerpc/tlsso.g15
-rw-r--r--ld/testsuite/ld-powerpc/tlsso.r158
-rw-r--r--ld/testsuite/ld-powerpc/tlsso.t13
-rw-r--r--ld/testsuite/ld-powerpc/tlstoc.d37
-rw-r--r--ld/testsuite/ld-powerpc/tlstoc.g15
-rw-r--r--ld/testsuite/ld-powerpc/tlstoc.s88
-rw-r--r--ld/testsuite/ld-powerpc/tlstoc.t14
-rw-r--r--ld/testsuite/ld-powerpc/tlstocso.d52
-rw-r--r--ld/testsuite/ld-powerpc/tlstocso.g14
-rw-r--r--ld/testsuite/ld-powerpc/tlstocso.r157
-rw-r--r--ld/testsuite/ld-powerpc/tlstocso.t13
27 files changed, 1292 insertions, 5 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index dc062027..886d43f 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,34 @@
+2003-02-05 Alan Modra <amodra@bigpond.net.au>
+
+ * ld-powerpc/powerpc.exp (supports_ppc64): New.
+ (ppcelftests): Force 32 bit mode.
+ (ppc64elftests): New.
+ * ld-powerpc/tls.d: New.
+ * ld-powerpc/tls.g: New.
+ * ld-powerpc/tls.s: New.
+ * ld-powerpc/tls.t: New.
+ * ld-powerpc/tlsexe.d: New.
+ * ld-powerpc/tlsexe.g: New.
+ * ld-powerpc/tlsexe.r: New.
+ * ld-powerpc/tlsexe.t: New.
+ * ld-powerpc/tlsexetoc.d: New.
+ * ld-powerpc/tlsexetoc.g: New.
+ * ld-powerpc/tlsexetoc.r: New.
+ * ld-powerpc/tlsexetoc.t: New.
+ * ld-powerpc/tlslib.s: New.
+ * ld-powerpc/tlsso.d: New.
+ * ld-powerpc/tlsso.g: New.
+ * ld-powerpc/tlsso.r: New.
+ * ld-powerpc/tlsso.t: New.
+ * ld-powerpc/tlstoc.d: New.
+ * ld-powerpc/tlstoc.g: New.
+ * ld-powerpc/tlstoc.s: New.
+ * ld-powerpc/tlstoc.t: New.
+ * ld-powerpc/tlstocso.d: New.
+ * ld-powerpc/tlstocso.g: New.
+ * ld-powerpc/tlstocso.r: New.
+ * ld-powerpc/tlstocso.t: New.
+
2003-01-27 Alexandre Oliva <aoliva@redhat.com>
* ld-mips-elf/multi-got-1.d: New.
diff --git a/ld/testsuite/ld-powerpc/powerpc.exp b/ld/testsuite/ld-powerpc/powerpc.exp
index a853df9..01fca29 100644
--- a/ld/testsuite/ld-powerpc/powerpc.exp
+++ b/ld/testsuite/ld-powerpc/powerpc.exp
@@ -1,5 +1,5 @@
# Expect script for ld-powerpc tests
-# Copyright (C) 2002 Free Software Foundation
+# Copyright 2002, 2003 Free Software Foundation
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,15 +20,26 @@ if { ![istarget "powerpc*-*-*"] } {
return
}
-# powerpc 32 bit ELF only at the moment.
+# powerpc ELF only at the moment.
if { [istarget "*-*-macos*"] || [istarget "*-*-netware*"]
|| [istarget "*-*-pe"] || [istarget "*-*-winnt*"]
|| [istarget "*-*-cygwin*"] || [istarget "*-*-aix*"]
- || [istarget "*-*-beos*"] || [istarget "powerpc64*-*-*"] } {
+ || [istarget "*-*-beos*"] } {
return
}
+proc supports_ppc64 { } {
+ global ld
+
+ catch "exec $ld --help | grep emulations" tmp
+ if [ string match "*elf64ppc*" $tmp ] then {
+ return 1
+ } else {
+ return 0
+ }
+}
+
# List contains test-items with 3 items followed by 2 lists:
# 0:name 1:ld options 2:assembler options
# 3:filenames of assembler files 4: action and options. 5: name of output file
@@ -39,10 +50,45 @@ if { [istarget "*-*-macos*"] || [istarget "*-*-netware*"]
# readelf: Apply readelf options on result. Compare with regex (last arg).
set ppcelftests {
- {"Reloc section order" "-shared -z nocombreloc" "" {reloc.s}
+ {"Reloc section order" "-melf32ppc -shared -z nocombreloc" "-a32" {reloc.s}
{{objdump -hw reloc.d}} "reloc.so"}
- {"APUinfo section processing" "" "-me500" {apuinfo1.s apuinfo2.s}
+ {"APUinfo section processing" "-melf32ppc"
+ "-a32 -me500" {apuinfo1.s apuinfo2.s}
{{readelf -x5 apuinfo.rd}} "apuinfo"}
}
+set ppc64elftests {
+ {"TLS static exec" "-melf64ppc" "-a64" {tls.s tlslib.s}
+ {{objdump -dr tls.d} {objdump -sj.got tls.g} {objdump -sj.tdata tls.t}}
+ "tls"}
+ {"TLS helper shared library" "-shared -melf64ppc tmpdir/tlslib.o" "" {}
+ {} "libtlslib.so"}
+ {"TLS dynamic exec" "-melf64ppc tmpdir/tls.o tmpdir/libtlslib.so" "" {}
+ {{readelf -WSsrl tlsexe.r} {objdump -dr tlsexe.d}
+ {objdump -sj.got tlsexe.g} {objdump -sj.tdata tlsexe.t}}
+ "tlsexe"}
+ {"TLS shared" "-shared -melf64ppc 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}
+ {{objdump -dr tlstoc.d} {objdump -sj.toc tlstoc.g}
+ {objdump -sj.tdata tlstoc.t}}
+ "tlstoc"}
+ {"TLSTOC dynamic exec" "-melf64ppc tmpdir/tlstoc.o tmpdir/libtlslib.so"
+ "" {}
+ {{readelf -WSsrl tlsexetoc.r} {objdump -dr tlsexetoc.d}
+ {objdump -sj.toc tlsexetoc.g} {objdump -sj.tdata tlsexetoc.t}}
+ "tlsexetoc"}
+ {"TLSTOC shared" "-shared -melf64ppc tmpdir/tlstoc.o" "" {}
+ {{readelf -WSsrl tlstocso.r} {objdump -dr tlstocso.d}
+ {objdump -sj.toc tlstocso.g} {objdump -sj.tdata tlstocso.t}}
+ "tlstoc.so"}
+}
+
+
run_ld_link_tests $ppcelftests
+
+if [ supports_ppc64 ] then {
+ run_ld_link_tests $ppc64elftests
+}
diff --git a/ld/testsuite/ld-powerpc/tls.d b/ld/testsuite/ld-powerpc/tls.d
new file mode 100644
index 0000000..621fcb0
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tls.d
@@ -0,0 +1,53 @@
+#source: tls.s
+#source: tlslib.s
+#as: -a64
+#ld: -melf64ppc
+#objdump: -dr
+#target: powerpc64*-*-*
+
+.*: +file format elf64-powerpc
+
+Disassembly of section \.text:
+
+0+100000e8 <_start>:
+ 100000e8: 3c 6d 00 00 addis r3,r13,0
+ 100000ec: 60 00 00 00 nop
+ 100000f0: 38 63 90 78 addi r3,r3,-28552
+ 100000f4: 3c 6d 00 00 addis r3,r13,0
+ 100000f8: 60 00 00 00 nop
+ 100000fc: 38 63 10 00 addi r3,r3,4096
+ 10000100: 3c 6d 00 00 addis r3,r13,0
+ 10000104: 60 00 00 00 nop
+ 10000108: 38 63 90 40 addi r3,r3,-28608
+ 1000010c: 3c 6d 00 00 addis r3,r13,0
+ 10000110: 60 00 00 00 nop
+ 10000114: 38 63 10 00 addi r3,r3,4096
+ 10000118: 39 23 80 48 addi r9,r3,-32696
+ 1000011c: 3d 23 00 00 addis r9,r3,0
+ 10000120: 81 49 80 50 lwz r10,-32688\(r9\)
+ 10000124: e9 22 80 10 ld r9,-32752\(r2\)
+ 10000128: 7d 49 18 2a ldx r10,r9,r3
+ 1000012c: 3d 2d 00 00 addis r9,r13,0
+ 10000130: a1 49 90 60 lhz r10,-28576\(r9\)
+ 10000134: 89 4d 90 68 lbz r10,-28568\(r13\)
+ 10000138: 3d 2d 00 00 addis r9,r13,0
+ 1000013c: 99 49 90 70 stb r10,-28560\(r9\)
+ 10000140: 3c 6d 00 00 addis r3,r13,0
+ 10000144: 60 00 00 00 nop
+ 10000148: 38 63 90 00 addi r3,r3,-28672
+ 1000014c: 3c 6d 00 00 addis r3,r13,0
+ 10000150: 60 00 00 00 nop
+ 10000154: 38 63 10 00 addi r3,r3,4096
+ 10000158: f9 43 80 08 std r10,-32760\(r3\)
+ 1000015c: 3d 23 00 00 addis r9,r3,0
+ 10000160: 91 49 80 10 stw r10,-32752\(r9\)
+ 10000164: e9 22 80 08 ld r9,-32760\(r2\)
+ 10000168: 7d 49 19 2a stdx r10,r9,r3
+ 1000016c: 3d 2d 00 00 addis r9,r13,0
+ 10000170: b1 49 90 60 sth r10,-28576\(r9\)
+ 10000174: e9 4d 90 2a lwa r10,-28632\(r13\)
+ 10000178: 3d 2d 00 00 addis r9,r13,0
+ 1000017c: a9 49 90 30 lha r10,-28624\(r9\)
+
+0+10000180 <\.__tls_get_addr>:
+ 10000180: 4e 80 00 20 blr
diff --git a/ld/testsuite/ld-powerpc/tls.g b/ld/testsuite/ld-powerpc/tls.g
new file mode 100644
index 0000000..051ddd1
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tls.g
@@ -0,0 +1,12 @@
+#source: tls.s
+#source: tlslib.s
+#as: -a64
+#ld: -melf64ppc
+#objdump: -sj.got
+#target: powerpc64*-*-*
+
+.*: +file format elf64-powerpc
+
+Contents of section \.got:
+ 100101e0 00000000 100181e0 ffffffff ffff8018 .*
+ 100101f0 ffffffff ffff8058 .*
diff --git a/ld/testsuite/ld-powerpc/tls.s b/ld/testsuite/ld-powerpc/tls.s
new file mode 100644
index 0000000..5ad9f3d
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tls.s
@@ -0,0 +1,92 @@
+ .section ".tbss","awT",@nobits
+ .global _start,gd0,ld0,ld1,ld2,ie0,le0,le1
+ .align 3
+gd0: .space 8
+ld0: .space 8
+ld1: .space 8
+ld2: .space 8
+ie0: .space 8
+le0: .space 8
+le1: .space 8
+
+ .section ".tdata","awT",@progbits
+ .align 3
+gd4: .quad 0x123456789abcdef0
+ld4: .quad 0x23456789abcdef01
+ld5: .quad 0x3456789abcdef012
+ld6: .quad 0x456789abcdef0123
+ie4: .quad 0x56789abcdef01234
+le4: .quad 0x6789abcdef012345
+le5: .quad 0x789abcdef0123456
+
+ .text
+_start:
+#extern syms
+#GD
+ addi 3,2,gd@got@tlsgd #R_PPC64_GOT_TLSGD16 gd
+ bl .__tls_get_addr #R_PPC64_REL24 .__tls_get_addr
+ nop
+
+#LD
+ addi 3,2,ld@got@tlsld #R_PPC64_GOT_TLSLD16 ld
+ bl .__tls_get_addr #R_PPC64_REL24 .__tls_get_addr
+ nop
+
+#global syms
+#GD
+ addi 3,2,gd0@got@tlsgd #R_PPC64_GOT_TLSGD16 gd0
+ bl .__tls_get_addr #R_PPC64_REL24 .__tls_get_addr
+ nop
+
+#LD
+ addi 3,2,ld0@got@tlsld #R_PPC64_GOT_TLSLD16 ld0
+ bl .__tls_get_addr #R_PPC64_REL24 .__tls_get_addr
+ nop
+
+ addi 9,3,ld0@dtprel #R_PPC64_DTPREL16 ld0
+
+ addis 9,3,ld1@dtprel@ha #R_PPC64_DTPREL16_HA ld1
+ lwz 10,ld1@dtprel@l(9) #R_PPC64_DTPREL16_LO ld1
+
+ ld 9,ld2@got@dtprel(2) #R_PPC64_GOT_DTPREL16_DS ld2
+ ldx 10,9,3
+
+#IE
+ ld 9,ie0@got@tprel(2) #R_PPC64_GOT_TPREL16_DS ie0
+ lhzx 10,9,ie0@tls #R_PPC64_TLS ie0
+
+#LE
+ lbz 10,le0@tprel(13) #R_PPC64_TPREL16 le0
+
+ addis 9,13,le1@tprel@ha #R_PPC64_TPREL16_HA le1
+ stb 10,le1@tprel@l(9) #R_PPC64_TPREL16_LO le1
+
+#local syms
+#GD
+ addi 3,2,gd4@got@tlsgd #R_PPC64_GOT_TLSGD16 gd4
+ bl .__tls_get_addr #R_PPC64_REL24 .__tls_get_addr
+ nop
+
+#LD
+ addi 3,2,ld4@got@tlsld #R_PPC64_GOT_TLSLD16 ld4
+ bl .__tls_get_addr #R_PPC64_REL24 .__tls_get_addr
+ nop
+
+ std 10,ld4@dtprel(3) #R_PPC64_DTPREL16_DS ld4
+
+ addis 9,3,ld5@dtprel@ha #R_PPC64_DTPREL16_HA ld5
+ stw 10,ld5@dtprel@l(9) #R_PPC64_DTPREL16_LO ld5
+
+ ld 9,ld6@got@dtprel(2) #R_PPC64_GOT_DTPREL16_DS ld6
+ stdx 10,9,3
+
+#IE
+ ld 9,ie0@got@tprel(2) #R_PPC64_GOT_TPREL16_DS ie4
+ sthx 10,9,ie0@tls #R_PPC64_TLS ie4
+
+#LE
+ lwa 10,le4@tprel(13) #R_PPC64_TPREL16 le4
+
+ addis 9,13,le5@tprel@ha #R_PPC64_TPREL16_HA le5
+ lha 10,le5@tprel@l(9) #R_PPC64_TPREL16_LO le5
+
diff --git a/ld/testsuite/ld-powerpc/tls.t b/ld/testsuite/ld-powerpc/tls.t
new file mode 100644
index 0000000..a37e69b
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tls.t
@@ -0,0 +1,14 @@
+#source: tls.s
+#source: tlslib.s
+#as: -a64
+#ld: -melf64ppc
+#objdump: -sj.tdata
+#target: powerpc64*-*-*
+
+.*: +file format elf64-powerpc
+
+Contents of section \.tdata:
+ 10010188 12345678 9abcdef0 23456789 abcdef01 .*
+ 10010198 3456789a bcdef012 456789ab cdef0123 .*
+ 100101a8 56789abc def01234 6789abcd ef012345 .*
+ 100101b8 789abcde f0123456 00c0ffee .*
diff --git a/ld/testsuite/ld-powerpc/tlsexe.d b/ld/testsuite/ld-powerpc/tlsexe.d
new file mode 100644
index 0000000..4d5618f
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsexe.d
@@ -0,0 +1,49 @@
+#source: tls.s
+#as: -a64
+#ld: -melf64ppc tmpdir/libtlslib.so
+#objdump: -dr
+#target: powerpc64*-*-*
+
+.*: +file format elf64-powerpc
+
+Disassembly of section \.text:
+
+0+10000378 <_start>:
+ 10000378: e8 62 80 10 ld r3,-32752\(r2\)
+ 1000037c: 60 00 00 00 nop
+ 10000380: 7c 63 6a 14 add r3,r3,r13
+ 10000384: e8 62 80 18 ld r3,-32744\(r2\)
+ 10000388: 60 00 00 00 nop
+ 1000038c: 7c 63 6a 14 add r3,r3,r13
+ 10000390: 3c 6d 00 00 addis r3,r13,0
+ 10000394: 60 00 00 00 nop
+ 10000398: 38 63 90 38 addi r3,r3,-28616
+ 1000039c: 3c 6d 00 00 addis r3,r13,0
+ 100003a0: 60 00 00 00 nop
+ 100003a4: 38 63 10 00 addi r3,r3,4096
+ 100003a8: 39 23 80 40 addi r9,r3,-32704
+ 100003ac: 3d 23 00 00 addis r9,r3,0
+ 100003b0: 81 49 80 48 lwz r10,-32696\(r9\)
+ 100003b4: e9 22 80 20 ld r9,-32736\(r2\)
+ 100003b8: 7d 49 18 2a ldx r10,r9,r3
+ 100003bc: 3d 2d 00 00 addis r9,r13,0
+ 100003c0: a1 49 90 58 lhz r10,-28584\(r9\)
+ 100003c4: 89 4d 90 60 lbz r10,-28576\(r13\)
+ 100003c8: 3d 2d 00 00 addis r9,r13,0
+ 100003cc: 99 49 90 68 stb r10,-28568\(r9\)
+ 100003d0: 3c 6d 00 00 addis r3,r13,0
+ 100003d4: 60 00 00 00 nop
+ 100003d8: 38 63 90 00 addi r3,r3,-28672
+ 100003dc: 3c 6d 00 00 addis r3,r13,0
+ 100003e0: 60 00 00 00 nop
+ 100003e4: 38 63 10 00 addi r3,r3,4096
+ 100003e8: f9 43 80 08 std r10,-32760\(r3\)
+ 100003ec: 3d 23 00 00 addis r9,r3,0
+ 100003f0: 91 49 80 10 stw r10,-32752\(r9\)
+ 100003f4: e9 22 80 08 ld r9,-32760\(r2\)
+ 100003f8: 7d 49 19 2a stdx r10,r9,r3
+ 100003fc: 3d 2d 00 00 addis r9,r13,0
+ 10000400: b1 49 90 58 sth r10,-28584\(r9\)
+ 10000404: e9 4d 90 2a lwa r10,-28632\(r13\)
+ 10000408: 3d 2d 00 00 addis r9,r13,0
+ 1000040c: a9 49 90 30 lha r10,-28624\(r9\)
diff --git a/ld/testsuite/ld-powerpc/tlsexe.g b/ld/testsuite/ld-powerpc/tlsexe.g
new file mode 100644
index 0000000..13877d7
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsexe.g
@@ -0,0 +1,12 @@
+#source: tls.s
+#as: -a64
+#ld: -melf64ppc tmpdir/libtlslib.so
+#objdump: -sj.got
+#target: powerpc64*-*-*
+
+.*: +file format elf64-powerpc
+
+Contents of section \.got:
+ 10010548 00000000 10018548 ffffffff ffff8018 .*
+ 10010558 00000000 00000000 00000000 00000000 .*
+ 10010568 00000000 00000000 .*
diff --git a/ld/testsuite/ld-powerpc/tlsexe.r b/ld/testsuite/ld-powerpc/tlsexe.r
new file mode 100644
index 0000000..23a0521
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsexe.r
@@ -0,0 +1,120 @@
+#source: tls.s
+#source: tlslib.s
+#as: -a64
+#ld: -shared -melf64ppc
+#readelf: -WSsrl
+#target: powerpc64*-*-*
+
+There are 20 section headers.*
+
+Section Headers:
+ +\[Nr\] Name +Type +Address +Off +Size +ES Flg Lk Inf Al
+ +\[ 0\] +NULL +0+ 0+ 0+ 0+ +0 +0 +0
+ +\[ 1\] \.interp +PROGBITS +0+10000190 0+190 0+11 0+ +A +0 +0 +1
+ +\[ 2\] \.hash +HASH +0+100001a8 0+1a8 0+3c 04 +A +3 +0 +8
+ +\[ 3\] \.dynsym +DYNSYM +0+100001e8 0+1e8 0+f0 18 +A +4 +1 +8
+ +\[ 4\] \.dynstr +STRTAB +0+100002d8 0+2d8 0+51 0+ +A +0 +0 +1
+ +\[ 5\] \.rela\.dyn +RELA +0+10000330 0+330 0+48 18 +A +3 +0 +8
+ +\[ 6\] \.text +PROGBITS +0+10000378 0+378 0+98 0+ +AX +0 +0 +4
+ +\[ 7\] \.data +PROGBITS +0+10010410 0+410 0+ 0+ +WA +0 +0 +1
+ +\[ 8\] \.branch_lt +PROGBITS +0+10010410 0+410 0+ 0+ +WA +0 +0 +8
+ +\[ 9\] \.tdata +PROGBITS +0+10010410 0+410 0+38 0+ WAT +0 +0 +8
+ +\[10\] \.tbss +NOBITS +0+10010448 0+448 0+38 0+ WAT +0 +0 +8
+ +\[11\] \.dynamic +DYNAMIC +0+10010448 0+448 0+100 10 +WA +4 +0 +8
+ +\[12\] \.ctors +PROGBITS +0+10010548 0+570 0+ 0+ +W +0 +0 +1
+ +\[13\] \.dtors +PROGBITS +0+10010548 0+570 0+ 0+ +W +0 +0 +1
+ +\[14\] \.got +PROGBITS +0+10010548 0+548 0+28 08 +WA +0 +0 +8
+ +\[15\] \.sbss +PROGBITS +0+10010570 0+570 0+ 0+ +W +0 +0 +1
+ +\[16\] \.bss +NOBITS +0+10010570 0+570 0+ 0+ +WA +0 +0 +1
+ +\[17\] \.shstrtab +STRTAB +0+ 0+570 0+8e 0+ +0 +0 +1
+ +\[18\] \.symtab +SYMTAB +0+ 0+b00 0+408 18 +19 +1b +8
+ +\[19\] \.strtab +STRTAB +0+ 0+f08 0+7d 0+ +0 +0 +1
+#...
+
+Elf file type is EXEC \(Executable file\)
+Entry point 0x10000378
+There are 6 program headers.*
+
+Program Headers:
+ +Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
+ +PHDR +0x0+40 0x0+10000040 0x0+10000040 0x0+150 0x0+150 R E 0x8
+ +INTERP +0x0+190 0x0+10000190 0x0+10000190 0x0+11 0x0+11 R +0x1
+ +\[Requesting program interpreter: .*\]
+ +LOAD +0x0+ 0x0+10000000 0x0+10000000 0x0+410 0x0+410 R E 0x10000
+ +LOAD +0x0+410 0x0+10010410 0x0+10010410 0x0+160 0x0+160 RW +0x10000
+ +DYNAMIC +0x0+448 0x0+10010448 0x0+10010448 0x0+100 0x0+100 RW +0x8
+ +TLS +0x0+410 0x0+10010410 0x0+10010410 0x0+38 0x0+70 R +0x8
+
+ Section to Segment mapping:
+ +Segment Sections\.\.\.
+ +00 +
+ +01 +\.interp
+ +02 +\.interp \.hash \.dynsym \.dynstr \.rela\.dyn \.text
+ +03 +\.tdata \.tbss \.dynamic \.got
+ +04 +\.tbss \.dynamic
+ +05 +\.tdata \.tbss
+
+Relocation section '\.rela\.dyn' at offset .* contains 3 entries:
+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
+0+10010558 +0+200000049 R_PPC64_TPREL64 +0+ gd \+ 0
+0+10010560 +0+400000049 R_PPC64_TPREL64 +0+ ld \+ 0
+0+10010568 +0+60000004e R_PPC64_DTPREL64 +0+50 ld2 \+ 0
+
+Symbol table '\.dynsym' contains 10 entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+ +0: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND
+ +1: 0+10010448 +0 OBJECT +GLOBAL DEFAULT +ABS _DYNAMIC
+ +2: 0+ +0 TLS +GLOBAL DEFAULT +UND gd
+ +3: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND \.__tls_get_addr
+ +4: 0+ +0 TLS +GLOBAL DEFAULT +UND ld
+ +5: 0+10010570 +0 NOTYPE +GLOBAL DEFAULT +ABS __end
+ +6: 0+50 +0 TLS +GLOBAL DEFAULT +10 ld2
+ +7: 0+10010570 +0 NOTYPE +GLOBAL DEFAULT +ABS __bss_start
+ +8: 0+10010570 +0 NOTYPE +GLOBAL DEFAULT +ABS _edata
+ +9: 0+10010570 +0 NOTYPE +GLOBAL DEFAULT +ABS _end
+
+Symbol table '\.symtab' contains 43 entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+ +0: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND
+ +1: 0+10000190 +0 SECTION LOCAL +DEFAULT +1
+ +2: 0+100001a8 +0 SECTION LOCAL +DEFAULT +2
+ +3: 0+100001e8 +0 SECTION LOCAL +DEFAULT +3
+ +4: 0+100002d8 +0 SECTION LOCAL +DEFAULT +4
+ +5: 0+10000330 +0 SECTION LOCAL +DEFAULT +5
+ +6: 0+10000378 +0 SECTION LOCAL +DEFAULT +6
+ +7: 0+10010410 +0 SECTION LOCAL +DEFAULT +7
+ +8: 0+10010410 +0 SECTION LOCAL +DEFAULT +8
+ +9: 0+10010410 +0 SECTION LOCAL +DEFAULT +9
+ +10: 0+10010448 +0 SECTION LOCAL +DEFAULT +10
+ +11: 0+10010448 +0 SECTION LOCAL +DEFAULT +11
+ +12: 0+10010548 +0 SECTION LOCAL +DEFAULT +12
+ +13: 0+10010548 +0 SECTION LOCAL +DEFAULT +13
+ +14: 0+10010548 +0 SECTION LOCAL +DEFAULT +14
+ +15: 0+10010570 +0 SECTION LOCAL +DEFAULT +15
+ +16: 0+10010570 +0 SECTION LOCAL +DEFAULT +16
+ +17: 0+ +0 SECTION LOCAL +DEFAULT +17
+ +18: 0+ +0 SECTION LOCAL +DEFAULT +18
+ +19: 0+ +0 SECTION LOCAL +DEFAULT +19
+ +20: 0+ +0 TLS +LOCAL +DEFAULT +9 gd4
+ +21: 0+8 +0 TLS +LOCAL +DEFAULT +9 ld4
+ +22: 0+10 +0 TLS +LOCAL +DEFAULT +9 ld5
+ +23: 0+18 +0 TLS +LOCAL +DEFAULT +9 ld6
+ +24: 0+20 +0 TLS +LOCAL +DEFAULT +9 ie4
+ +25: 0+28 +0 TLS +LOCAL +DEFAULT +9 le4
+ +26: 0+30 +0 TLS +LOCAL +DEFAULT +9 le5
+ +27: 0+10010448 +0 OBJECT +GLOBAL DEFAULT +ABS _DYNAMIC
+ +28: 0+ +0 TLS +GLOBAL DEFAULT +UND gd
+ +29: 0+60 +0 TLS +GLOBAL DEFAULT +10 le0
+ +30: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND \.__tls_get_addr
+ +31: 0+40 +0 TLS +GLOBAL DEFAULT +10 ld0
+ +32: 0+68 +0 TLS +GLOBAL DEFAULT +10 le1
+ +33: 0+ +0 TLS +GLOBAL DEFAULT +UND ld
+ +34: 0+10000378 +0 NOTYPE +GLOBAL DEFAULT +6 _start
+ +35: 0+10010570 +0 NOTYPE +GLOBAL DEFAULT +ABS __end
+ +36: 0+50 +0 TLS +GLOBAL DEFAULT +10 ld2
+ +37: 0+48 +0 TLS +GLOBAL DEFAULT +10 ld1
+ +38: 0+10010570 +0 NOTYPE +GLOBAL DEFAULT +ABS __bss_start
+ +39: 0+10010570 +0 NOTYPE +GLOBAL DEFAULT +ABS _edata
+ +40: 0+10010570 +0 NOTYPE +GLOBAL DEFAULT +ABS _end
+ +41: 0+38 +0 TLS +GLOBAL DEFAULT +10 gd0
+ +42: 0+58 +0 TLS +GLOBAL DEFAULT +10 ie0
diff --git a/ld/testsuite/ld-powerpc/tlsexe.t b/ld/testsuite/ld-powerpc/tlsexe.t
new file mode 100644
index 0000000..eb2b371
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsexe.t
@@ -0,0 +1,13 @@
+#source: tls.s
+#as: -a64
+#ld: -melf64ppc tmpdir/libtlslib.so
+#objdump: -sj.tdata
+#target: powerpc64*-*-*
+
+.*: +file format elf64-powerpc
+
+Contents of section \.tdata:
+ 10010410 12345678 9abcdef0 23456789 abcdef01 .*
+ 10010420 3456789a bcdef012 456789ab cdef0123 .*
+ 10010430 56789abc def01234 6789abcd ef012345 .*
+ 10010440 789abcde f0123456 .*
diff --git a/ld/testsuite/ld-powerpc/tlsexetoc.d b/ld/testsuite/ld-powerpc/tlsexetoc.d
new file mode 100644
index 0000000..36df8d4
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsexetoc.d
@@ -0,0 +1,33 @@
+#source: tlstoc.s
+#as: -a64
+#ld: -melf64ppc tmpdir/libtlslib.so
+#objdump: -dr
+#target: powerpc64*-*-*
+
+.*: +file format elf64-powerpc
+
+Disassembly of section \.text:
+
+0+10000338 <_start>:
+ 10000338: e8 62 80 08 ld r3,-32760\(r2\)
+ 1000033c: 60 00 00 00 nop
+ 10000340: 7c 63 6a 14 add r3,r3,r13
+ 10000344: e8 62 80 18 ld r3,-32744\(r2\)
+ 10000348: 60 00 00 00 nop
+ 1000034c: 7c 63 6a 14 add r3,r3,r13
+ 10000350: 3c 6d 00 00 addis r3,r13,0
+ 10000354: 60 00 00 00 nop
+ 10000358: 38 63 91 40 addi r3,r3,-28352
+ 1000035c: 3c 6d 00 00 addis r3,r13,0
+ 10000360: 60 00 00 00 nop
+ 10000364: 38 63 10 00 addi r3,r3,4096
+ 10000368: 39 23 80 40 addi r9,r3,-32704
+ 1000036c: 3d 23 00 00 addis r9,r3,0
+ 10000370: 81 49 80 48 lwz r10,-32696\(r9\)
+ 10000374: 3d 2d 00 00 addis r9,r13,0
+ 10000378: 7d 49 18 2a ldx r10,r9,r3
+ 1000037c: 3d 2d 00 00 addis r9,r13,0
+ 10000380: a1 49 91 88 lhz r10,-28280\(r9\)
+ 10000384: 89 4d 90 60 lbz r10,-28576\(r13\)
+ 10000388: 3d 2d 00 00 addis r9,r13,0
+ 1000038c: 99 49 90 68 stb r10,-28568\(r9\)
diff --git a/ld/testsuite/ld-powerpc/tlsexetoc.g b/ld/testsuite/ld-powerpc/tlsexetoc.g
new file mode 100644
index 0000000..b168c3b
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsexetoc.g
@@ -0,0 +1,14 @@
+#source: tlstoc.s
+#as: -a64
+#ld: -melf64ppc tmpdir/libtlslib.so
+#objdump: -sj.toc
+#target: powerpc64*-*-*
+
+.*: +file format elf64-powerpc
+
+Contents of section \.toc:
+ 100104d0 00000000 00000000 00000000 00000000 .*
+ 100104e0 00000000 00000000 00000000 00000000 .*
+ 100104f0 00000000 00000001 00000000 00000000 .*
+ 10010500 00000000 00000001 00000000 00000000 .*
+ 10010510 ffffffff ffff8050 00000000 00000000 .*
diff --git a/ld/testsuite/ld-powerpc/tlsexetoc.r b/ld/testsuite/ld-powerpc/tlsexetoc.r
new file mode 100644
index 0000000..5627778
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsexetoc.r
@@ -0,0 +1,121 @@
+#source: tlslib.s
+#source: tlstoc.s
+#as: -a64
+#ld: -shared -melf64ppc
+#readelf: -WSsrl
+#target: powerpc64*-*-*
+
+There are 21 section headers.*
+
+Section Headers:
+ +\[Nr\] Name +Type +Address +Off +Size +ES Flg Lk Inf Al
+ +\[ 0\] +NULL +0+ 0+ 0+ 0+ +0 +0 +0
+ +\[ 1\] .interp +PROGBITS +0+10000190 0+190 0+11 0+ +A +0 +0 +1
+ +\[ 2\] .hash +HASH +0+100001a8 0+1a8 0+38 04 +A +3 +0 +8
+ +\[ 3\] .dynsym +DYNSYM +0+100001e0 0+1e0 0+d8 18 +A +4 +1 +8
+ +\[ 4\] .dynstr +STRTAB +0+100002b8 0+2b8 0+4d 0+ +A +0 +0 +1
+ +\[ 5\] .rela.dyn +RELA +0+10000308 0+308 0+30 18 +A +3 +0 +8
+ +\[ 6\] .text +PROGBITS +0+10000338 0+338 0+58 0+ +AX +0 +0 +4
+ +\[ 7\] .data +PROGBITS +0+10010390 0+390 0+ 0+ +WA +0 +0 +1
+ +\[ 8\] .branch_lt +PROGBITS +0+10010390 0+390 0+ 0+ +WA +0 +0 +8
+ +\[ 9\] .tdata +PROGBITS +0+10010390 0+390 0+38 0+ WAT +0 +0 +8
+ +\[10\] .tbss +NOBITS +0+100103c8 0+3c8 0+38 0+ WAT +0 +0 +8
+ +\[11\] .dynamic +DYNAMIC +0+100103c8 0+3c8 0+100 10 +WA +4 +0 +8
+ +\[12\] .ctors +PROGBITS +0+100104c8 0+520 0+ 0+ +W +0 +0 +1
+ +\[13\] .dtors +PROGBITS +0+100104c8 0+520 0+ 0+ +W +0 +0 +1
+ +\[14\] .got +PROGBITS +0+100104c8 0+4c8 0+8 08 +WA +0 +0 +8
+ +\[15\] .toc +PROGBITS +0+100104d0 0+4d0 0+50 0+ +WA +0 +0 +1
+ +\[16\] .sbss +PROGBITS +0+10010520 0+520 0+ 0+ +W +0 +0 +1
+ +\[17\] .bss +NOBITS +0+10010520 0+520 0+ 0+ +WA +0 +0 +1
+ +\[18\] .shstrtab +STRTAB +0+ 0+520 0+93 0+ +0 +0 +1
+ +\[19\] .symtab +SYMTAB +0+ 0+af8 0+438 18 +20 +1d +8
+ +\[20\] .strtab +STRTAB +0+ 0+f30 0+83 0+ +0 +0 +1
+#...
+
+Elf file type is EXEC \(Executable file\)
+Entry point 0x10000338
+There are 6 program headers.*
+
+Program Headers:
+ +Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
+ +PHDR +0x0+40 0x0+10000040 0x0+10000040 0x0+150 0x0+150 R E 0x8
+ +INTERP +0x0+190 0x0+10000190 0x0+10000190 0x0+11 0x0+11 R +0x1
+ +\[Requesting program interpreter: .*\]
+ +LOAD +0x0+ 0x0+10000000 0x0+10000000 0x0+390 0x0+390 R E 0x10000
+ +LOAD +0x0+390 0x0+10010390 0x0+10010390 0x0+190 0x0+190 RW +0x10000
+ +DYNAMIC +0x0+3c8 0x0+100103c8 0x0+100103c8 0x0+100 0x0+100 RW +0x8
+ +TLS +0x0+390 0x0+10010390 0x0+10010390 0x0+38 0x0+70 R +0x8
+
+ Section to Segment mapping:
+ +Segment Sections\.\.\.
+ +00 +
+ +01 +\.interp
+ +02 +\.interp \.hash \.dynsym \.dynstr \.rela\.dyn \.text
+ +03 +\.tdata \.tbss \.dynamic \.got \.toc
+ +04 +\.tbss \.dynamic
+ +05 +\.tdata \.tbss
+
+Relocation section '\.rela\.dyn' at offset .* contains 2 entries:
+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
+0+100104d0 +0+200000049 R_PPC64_TPREL64 +0+ gd \+ 0
+0+100104e0 +0+400000049 R_PPC64_TPREL64 +0+ ld \+ 0
+
+Symbol table '\.dynsym' contains 9 entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+ +0: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND
+ +1: 0+100103c8 +0 OBJECT +GLOBAL DEFAULT +ABS _DYNAMIC
+ +2: 0+ +0 TLS +GLOBAL DEFAULT +UND gd
+ +3: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND \.__tls_get_addr
+ +4: 0+ +0 TLS +GLOBAL DEFAULT +UND ld
+ +5: 0+10010520 +0 NOTYPE +GLOBAL DEFAULT +ABS __end
+ +6: 0+10010520 +0 NOTYPE +GLOBAL DEFAULT +ABS __bss_start
+ +7: 0+10010520 +0 NOTYPE +GLOBAL DEFAULT +ABS _edata
+ +8: 0+10010520 +0 NOTYPE +GLOBAL DEFAULT +ABS _end
+
+Symbol table '\.symtab' contains 45 entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+ +0: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND
+ +1: 0+10000190 +0 SECTION LOCAL +DEFAULT +1
+ +2: 0+100001a8 +0 SECTION LOCAL +DEFAULT +2
+ +3: 0+100001e0 +0 SECTION LOCAL +DEFAULT +3
+ +4: 0+100002b8 +0 SECTION LOCAL +DEFAULT +4
+ +5: 0+10000308 +0 SECTION LOCAL +DEFAULT +5
+ +6: 0+10000338 +0 SECTION LOCAL +DEFAULT +6
+ +7: 0+10010390 +0 SECTION LOCAL +DEFAULT +7
+ +8: 0+10010390 +0 SECTION LOCAL +DEFAULT +8
+ +9: 0+10010390 +0 SECTION LOCAL +DEFAULT +9
+ +10: 0+100103c8 +0 SECTION LOCAL +DEFAULT +10
+ +11: 0+100103c8 +0 SECTION LOCAL +DEFAULT +11
+ +12: 0+100104c8 +0 SECTION LOCAL +DEFAULT +12
+ +13: 0+100104c8 +0 SECTION LOCAL +DEFAULT +13
+ +14: 0+100104c8 +0 SECTION LOCAL +DEFAULT +14
+ +15: 0+100104d0 +0 SECTION LOCAL +DEFAULT +15
+ +16: 0+10010520 +0 SECTION LOCAL +DEFAULT +16
+ +17: 0+10010520 +0 SECTION LOCAL +DEFAULT +17
+ +18: 0+ +0 SECTION LOCAL +DEFAULT +18
+ +19: 0+ +0 SECTION LOCAL +DEFAULT +19
+ +20: 0+ +0 SECTION LOCAL +DEFAULT +20
+ +21: 0+ +0 TLS +LOCAL +DEFAULT +9 gd4
+ +22: 0+8 +0 TLS +LOCAL +DEFAULT +9 ld4
+ +23: 0+10 +0 TLS +LOCAL +DEFAULT +9 ld5
+ +24: 0+18 +0 TLS +LOCAL +DEFAULT +9 ld6
+ +25: 0+20 +0 TLS +LOCAL +DEFAULT +9 ie4
+ +26: 0+28 +0 TLS +LOCAL +DEFAULT +9 le4
+ +27: 0+30 +0 TLS +LOCAL +DEFAULT +9 le5
+ +28: 0+10010518 +0 NOTYPE +LOCAL +DEFAULT +15 \.Lie0
+ +29: 0+100103c8 +0 OBJECT +GLOBAL DEFAULT +ABS _DYNAMIC
+ +30: 0+ +0 TLS +GLOBAL DEFAULT +UND gd
+ +31: 0+60 +0 TLS +GLOBAL DEFAULT +10 le0
+ +32: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND \.__tls_get_addr
+ +33: 0+40 +0 TLS +GLOBAL DEFAULT +10 ld0
+ +34: 0+68 +0 TLS +GLOBAL DEFAULT +10 le1
+ +35: 0+ +0 TLS +GLOBAL DEFAULT +UND ld
+ +36: 0+10000338 +0 NOTYPE +GLOBAL DEFAULT +6 _start
+ +37: 0+10010520 +0 NOTYPE +GLOBAL DEFAULT +ABS __end
+ +38: 0+50 +0 TLS +GLOBAL DEFAULT +10 ld2
+ +39: 0+48 +0 TLS +GLOBAL DEFAULT +10 ld1
+ +40: 0+10010520 +0 NOTYPE +GLOBAL DEFAULT +ABS __bss_start
+ +41: 0+10010520 +0 NOTYPE +GLOBAL DEFAULT +ABS _edata
+ +42: 0+10010520 +0 NOTYPE +GLOBAL DEFAULT +ABS _end
+ +43: 0+38 +0 TLS +GLOBAL DEFAULT +10 gd0
+ +44: 0+58 +0 TLS +GLOBAL DEFAULT +10 ie0
diff --git a/ld/testsuite/ld-powerpc/tlsexetoc.t b/ld/testsuite/ld-powerpc/tlsexetoc.t
new file mode 100644
index 0000000..f17b6c6
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsexetoc.t
@@ -0,0 +1,13 @@
+#source: tlstoc.s
+#as: -a64
+#ld: -melf64ppc tmpdir/libtlslib.so
+#objdump: -sj.tdata
+#target: powerpc64*-*-*
+
+.*: +file format elf64-powerpc
+
+Contents of section \.tdata:
+ 10010390 12345678 9abcdef0 23456789 abcdef01 .*
+ 100103a0 3456789a bcdef012 456789ab cdef0123 .*
+ 100103b0 56789abc def01234 6789abcd ef012345 .*
+ 100103c0 789abcde f0123456 .*
diff --git a/ld/testsuite/ld-powerpc/tlslib.s b/ld/testsuite/ld-powerpc/tlslib.s
new file mode 100644
index 0000000..299bb27
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlslib.s
@@ -0,0 +1,20 @@
+ .global .__tls_get_addr,__tls_get_addr,gd,ld
+
+ .section ".opd","aw",@progbits
+__tls_get_addr:
+ .align 3
+ .quad .__tls_get_addr
+ .quad .TOC.@tocbase
+ .quad 0
+
+ .section ".tbss","awT",@nobits
+ .align 3
+gd: .space 8
+
+ .section ".tdata","awT",@progbits
+ .align 2
+ld: .long 0xc0ffee
+
+ .text
+.__tls_get_addr:
+ blr
diff --git a/ld/testsuite/ld-powerpc/tlsso.d b/ld/testsuite/ld-powerpc/tlsso.d
new file mode 100644
index 0000000..07e48ba
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsso.d
@@ -0,0 +1,68 @@
+#source: tls.s
+#as: -a64
+#ld: -shared -melf64ppc
+#objdump: -dr
+#target: powerpc64*-*-*
+
+.*: +file format elf64-powerpc
+
+Disassembly of section \.text:
+
+0+718 <\.__tls_get_addr>:
+ 718: 3d 82 00 00 addis r12,r2,0
+ 71c: f8 41 00 28 std r2,40\(r1\)
+ 720: e9 6c 80 78 ld r11,-32648\(r12\)
+ 724: e8 4c 80 80 ld r2,-32640\(r12\)
+ 728: 7d 69 03 a6 mtctr r11
+ 72c: e9 6c 80 88 ld r11,-32632\(r12\)
+ 730: 4e 80 04 20 bctr
+
+0+734 <_start>:
+ 734: 38 62 80 30 addi r3,r2,-32720
+ 738: 4b ff ff e1 bl 718 <\.__tls_get_addr>
+ 73c: e8 41 00 28 ld r2,40\(r1\)
+ 740: 38 62 80 08 addi r3,r2,-32760
+ 744: 4b ff ff d5 bl 718 <\.__tls_get_addr>
+ 748: e8 41 00 28 ld r2,40\(r1\)
+ 74c: 38 62 80 48 addi r3,r2,-32696
+ 750: 4b ff ff c9 bl 718 <\.__tls_get_addr>
+ 754: e8 41 00 28 ld r2,40\(r1\)
+ 758: 38 62 80 08 addi r3,r2,-32760
+ 75c: 4b ff ff bd bl 718 <\.__tls_get_addr>
+ 760: e8 41 00 28 ld r2,40\(r1\)
+ 764: 39 23 80 40 addi r9,r3,-32704
+ 768: 3d 23 00 00 addis r9,r3,0
+ 76c: 81 49 80 48 lwz r10,-32696\(r9\)
+ 770: e9 22 80 40 ld r9,-32704\(r2\)
+ 774: 7d 49 18 2a ldx r10,r9,r3
+ 778: e9 22 80 58 ld r9,-32680\(r2\)
+ 77c: 7d 49 6a 2e lhzx r10,r9,r13
+ 780: 89 4d 00 00 lbz r10,0\(r13\)
+ 784: 3d 2d 00 00 addis r9,r13,0
+ 788: 99 49 00 00 stb r10,0\(r9\)
+ 78c: 38 62 80 18 addi r3,r2,-32744
+ 790: 4b ff ff 89 bl 718 <\.__tls_get_addr>
+ 794: e8 41 00 28 ld r2,40\(r1\)
+ 798: 38 62 80 08 addi r3,r2,-32760
+ 79c: 4b ff ff 7d bl 718 <\.__tls_get_addr>
+ 7a0: e8 41 00 28 ld r2,40\(r1\)
+ 7a4: f9 43 80 08 std r10,-32760\(r3\)
+ 7a8: 3d 23 00 00 addis r9,r3,0
+ 7ac: 91 49 80 10 stw r10,-32752\(r9\)
+ 7b0: e9 22 80 28 ld r9,-32728\(r2\)
+ 7b4: 7d 49 19 2a stdx r10,r9,r3
+ 7b8: e9 22 80 58 ld r9,-32680\(r2\)
+ 7bc: 7d 49 6b 2e sthx r10,r9,r13
+ 7c0: e9 4d 90 2a lwa r10,-28632\(r13\)
+ 7c4: 3d 2d 00 00 addis r9,r13,0
+ 7c8: a9 49 90 30 lha r10,-28624\(r9\)
+ 7cc: e8 41 00 28 ld r2,40\(r1\)
+ 7d0: 3d 82 00 00 addis r12,r2,0
+ 7d4: e9 6c 80 60 ld r11,-32672\(r12\)
+ 7d8: e8 4c 80 68 ld r2,-32664\(r12\)
+ 7dc: 7d 69 03 a6 mtctr r11
+ 7e0: e9 6c 80 70 ld r11,-32656\(r12\)
+ 7e4: 4e 80 04 20 bctr
+ 7e8: 60 00 00 00 nop
+ 7ec: 38 00 00 00 li r0,0
+ 7f0: 4b ff ff dc b 7cc <_start\+0x98>
diff --git a/ld/testsuite/ld-powerpc/tlsso.g b/ld/testsuite/ld-powerpc/tlsso.g
new file mode 100644
index 0000000..72d445d
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsso.g
@@ -0,0 +1,15 @@
+#source: tls.s
+#as: -a64
+#ld: -shared -melf64ppc
+#objdump: -sj.got
+#target: powerpc64*-*-*
+
+.*: +file format elf64-powerpc
+
+Contents of section \.got:
+ 10980 00000000 00018980 00000000 00000000 .*
+ 10990 00000000 00000000 00000000 00000000 .*
+ 109a0 00000000 00000000 00000000 00000000 .*
+ 109b0 00000000 00000000 00000000 00000000 .*
+ 109c0 00000000 00000000 00000000 00000000 .*
+ 109d0 00000000 00000000 00000000 00000000 .*
diff --git a/ld/testsuite/ld-powerpc/tlsso.r b/ld/testsuite/ld-powerpc/tlsso.r
new file mode 100644
index 0000000..2d89e0b
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsso.r
@@ -0,0 +1,158 @@
+#source: tls.s
+#as: -a64
+#ld: -shared -melf64ppc
+#readelf: -WSsrl
+#target: powerpc64*-*-*
+
+There are 21 section headers.*
+
+Section Headers:
+ +\[Nr\] Name +Type +Address +Off +Size +ES Flg Lk Inf Al
+ +\[ 0\] +NULL +0+ 0+ 0+ 0+ +0 +0 +0
+ +\[ 1\] \.hash +HASH +0+120 0+120 0+d4 04 +A +2 +0 +8
+ +\[ 2\] \.dynsym +DYNSYM +0+1f8 0+1f8 0+330 18 +A +3 +12 +8
+ +\[ 3\] \.dynstr +STRTAB +0+528 0+528 0+54 0+ +A +0 +0 +1
+ +\[ 4\] \.rela\.dyn +RELA +0+580 0+580 0+180 18 +A +2 +0 +8
+ +\[ 5\] \.rela\.plt +RELA +0+700 0+700 0+18 18 +A +2 +10 +8
+ +\[ 6\] \.text +PROGBITS +0+718 0+718 0+dc 0+ +AX +0 +0 +4
+ +\[ 7\] \.data +PROGBITS +0+107f8 0+7f8 0+ 0+ +WA +0 +0 +1
+ +\[ 8\] \.branch_lt +PROGBITS +0+107f8 0+7f8 0+ 0+ +WA +0 +0 +8
+ +\[ 9\] \.tdata +PROGBITS +0+107f8 0+7f8 0+38 0+ WAT +0 +0 +8
+ +\[10\] \.tbss +NOBITS +0+10830 0+830 0+38 0+ WAT +0 +0 +8
+ +\[11\] \.dynamic +DYNAMIC +0+10830 0+830 0+150 10 +WA +3 +0 +8
+ +\[12\] \.ctors +PROGBITS +0+10980 0+9e0 0+ 0+ +W +0 +0 +1
+ +\[13\] \.dtors +PROGBITS +0+10980 0+9e0 0+ 0+ +W +0 +0 +1
+ +\[14\] \.got +PROGBITS +0+10980 0+980 0+60 08 +WA +0 +0 +8
+ +\[15\] \.sbss +PROGBITS +0+109e0 0+9e0 0+ 0+ +W +0 +0 +1
+ +\[16\] \.plt +NOBITS +0+109e0 0+9e0 0+30 18 +WA +0 +0 +8
+ +\[17\] \.bss +NOBITS +0+10a10 0+9e0 0+ 0+ +WA +0 +0 +1
+ +\[18\] \.shstrtab +STRTAB +0+ 0+9e0 0+90 0+ +0 +0 +1
+ +\[19\] \.symtab +SYMTAB +0+ 0+fb0 0+438 18 +20 +1d +8
+ +\[20\] \.strtab +STRTAB +0+ 0+13e8 0+8c 0+ +0 +0 +1
+#...
+
+Elf file type is DYN \(Shared object file\)
+Entry point 0x734
+There are 4 program headers.*
+
+Program Headers:
+ +Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
+ +LOAD +0x0+ 0x0+ 0x0+ 0x0+7f4 0x0+7f4 R E 0x10000
+ +LOAD +0x0+7f8 0x0+107f8 0x0+107f8 0x0+1e8 0x0+218 RW +0x10000
+ +DYNAMIC +0x0+830 0x0+10830 0x0+10830 0x0+150 0x0+150 RW +0x8
+ +TLS +0x0+7f8 0x0+107f8 0x0+107f8 0x0+38 0x0+70 R +0x8
+
+ Section to Segment mapping:
+ +Segment Sections\.\.\.
+ +0+ +\.hash \.dynsym \.dynstr \.rela\.dyn \.rela\.plt \.text
+ +01 +\.tdata \.tbss \.dynamic \.got \.plt
+ +02 +\.tbss \.dynamic
+ +03 +\.tdata \.tbss
+
+Relocation section '\.rela\.dyn' at offset .* contains 16 entries:
+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
+0+782 +0+1400000045 R_PPC64_TPREL16 +0+60 le0 \+ 0
+0+786 +0+1700000048 R_PPC64_TPREL16_HA +0+68 le1 \+ 0
+0+78a +0+1700000046 R_PPC64_TPREL16_LO +0+68 le1 \+ 0
+0+7c2 +0+90000005f R_PPC64_TPREL16_DS +0+107f8 \.tdata \+ 28
+0+7c6 +0+900000048 R_PPC64_TPREL16_HA +0+107f8 \.tdata \+ 30
+0+7ca +0+900000046 R_PPC64_TPREL16_LO +0+107f8 \.tdata \+ 30
+0+10988 +0+44 R_PPC64_DTPMOD64 +0+
+0+10998 +0+44 R_PPC64_DTPMOD64 +0+
+0+109a0 +0+4e R_PPC64_DTPREL64 +0+107f8
+0+109a8 +0+4e R_PPC64_DTPREL64 +0+10810
+0+109b0 +0+1300000044 R_PPC64_DTPMOD64 +0+ gd \+ 0
+0+109b8 +0+130000004e R_PPC64_DTPREL64 +0+ gd \+ 0
+0+109c0 +0+1b0000004e R_PPC64_DTPREL64 +0+50 ld2 \+ 0
+0+109c8 +0+2000000044 R_PPC64_DTPMOD64 +0+38 gd0 \+ 0
+0+109d0 +0+200000004e R_PPC64_DTPREL64 +0+38 gd0 \+ 0
+0+109d8 +0+2100000049 R_PPC64_TPREL64 +0+58 ie0 \+ 0
+
+Relocation section '\.rela\.plt' at offset .* contains 1 entries:
+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
+0+109f8 +0+1500000015 R_PPC64_JMP_SLOT +0+ __tls_get_addr \+ 0
+
+Symbol table '\.dynsym' contains 34 entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+ +0: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND
+ +1: 0+120 +0 SECTION LOCAL +DEFAULT +1
+ +2: 0+1f8 +0 SECTION LOCAL +DEFAULT +2
+ +3: 0+528 +0 SECTION LOCAL +DEFAULT +3
+ +4: 0+580 +0 SECTION LOCAL +DEFAULT +4
+ +5: 0+700 +0 SECTION LOCAL +DEFAULT +5
+ +6: 0+718 +0 SECTION LOCAL +DEFAULT +6
+ +7: 0+107f8 +0 SECTION LOCAL +DEFAULT +7
+ +8: 0+107f8 +0 SECTION LOCAL +DEFAULT +8
+ +9: 0+107f8 +0 SECTION LOCAL +DEFAULT +9
+ +10: 0+10830 +0 SECTION LOCAL +DEFAULT +10
+ +11: 0+10830 +0 SECTION LOCAL +DEFAULT +11
+ +12: 0+10980 +0 SECTION LOCAL +DEFAULT +12
+ +13: 0+10980 +0 SECTION LOCAL +DEFAULT +13
+ +14: 0+10980 +0 SECTION LOCAL +DEFAULT +14
+ +15: 0+109e0 +0 SECTION LOCAL +DEFAULT +15
+ +16: 0+109e0 +0 SECTION LOCAL +DEFAULT +16
+ +17: 0+10a10 +0 SECTION LOCAL +DEFAULT +17
+ +18: 0+10830 +0 OBJECT +GLOBAL DEFAULT +ABS _DYNAMIC
+ +19: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND gd
+ +20: 0+60 +0 TLS +GLOBAL DEFAULT +10 le0
+ +21: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND __tls_get_addr
+ +22: 0+40 +0 TLS +GLOBAL DEFAULT +10 ld0
+ +23: 0+68 +0 TLS +GLOBAL DEFAULT +10 le1
+ +24: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND ld
+ +25: 0+734 +0 NOTYPE +GLOBAL DEFAULT +6 _start
+ +26: 0+10a10 +0 NOTYPE +GLOBAL DEFAULT +ABS __end
+ +27: 0+50 +0 TLS +GLOBAL DEFAULT +10 ld2
+ +28: 0+48 +0 TLS +GLOBAL DEFAULT +10 ld1
+ +29: 0+109e0 +0 NOTYPE +GLOBAL DEFAULT +ABS __bss_start
+ +30: 0+109e0 +0 NOTYPE +GLOBAL DEFAULT +ABS _edata
+ +31: 0+10a10 +0 NOTYPE +GLOBAL DEFAULT +ABS _end
+ +32: 0+38 +0 TLS +GLOBAL DEFAULT +10 gd0
+ +33: 0+58 +0 TLS +GLOBAL DEFAULT +10 ie0
+
+Symbol table '\.symtab' contains 45 entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+ +0: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND
+ +1: 0+120 +0 SECTION LOCAL +DEFAULT +1
+ +2: 0+1f8 +0 SECTION LOCAL +DEFAULT +2
+ +3: 0+528 +0 SECTION LOCAL +DEFAULT +3
+ +4: 0+580 +0 SECTION LOCAL +DEFAULT +4
+ +5: 0+700 +0 SECTION LOCAL +DEFAULT +5
+ +6: 0+718 +0 SECTION LOCAL +DEFAULT +6
+ +7: 0+107f8 +0 SECTION LOCAL +DEFAULT +7
+ +8: 0+107f8 +0 SECTION LOCAL +DEFAULT +8
+ +9: 0+107f8 +0 SECTION LOCAL +DEFAULT +9
+ +10: 0+10830 +0 SECTION LOCAL +DEFAULT +10
+ +11: 0+10830 +0 SECTION LOCAL +DEFAULT +11
+ +12: 0+10980 +0 SECTION LOCAL +DEFAULT +12
+ +13: 0+10980 +0 SECTION LOCAL +DEFAULT +13
+ +14: 0+10980 +0 SECTION LOCAL +DEFAULT +14
+ +15: 0+109e0 +0 SECTION LOCAL +DEFAULT +15
+ +16: 0+109e0 +0 SECTION LOCAL +DEFAULT +16
+ +17: 0+10a10 +0 SECTION LOCAL +DEFAULT +17
+ +18: 0+ +0 SECTION LOCAL +DEFAULT +18
+ +19: 0+ +0 SECTION LOCAL +DEFAULT +19
+ +20: 0+ +0 SECTION LOCAL +DEFAULT +20
+ +21: 0+ +0 TLS +LOCAL +DEFAULT +9 gd4
+ +22: 0+8 +0 TLS +LOCAL +DEFAULT +9 ld4
+ +23: 0+10 +0 TLS +LOCAL +DEFAULT +9 ld5
+ +24: 0+18 +0 TLS +LOCAL +DEFAULT +9 ld6
+ +25: 0+20 +0 TLS +LOCAL +DEFAULT +9 ie4
+ +26: 0+28 +0 TLS +LOCAL +DEFAULT +9 le4
+ +27: 0+30 +0 TLS +LOCAL +DEFAULT +9 le5
+ +28: 0+718 +0 NOTYPE +LOCAL +DEFAULT +6 \.__tls_get_addr
+ +29: 0+10830 +0 OBJECT +GLOBAL DEFAULT +ABS _DYNAMIC
+ +30: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND gd
+ +31: 0+60 +0 TLS +GLOBAL DEFAULT +10 le0
+ +32: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND __tls_get_addr
+ +33: 0+40 +0 TLS +GLOBAL DEFAULT +10 ld0
+ +34: 0+68 +0 TLS +GLOBAL DEFAULT +10 le1
+ +35: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND ld
+ +36: 0+734 +0 NOTYPE +GLOBAL DEFAULT +6 _start
+ +37: 0+10a10 +0 NOTYPE +GLOBAL DEFAULT +ABS __end
+ +38: 0+50 +0 TLS +GLOBAL DEFAULT +10 ld2
+ +39: 0+48 +0 TLS +GLOBAL DEFAULT +10 ld1
+ +40: 0+109e0 +0 NOTYPE +GLOBAL DEFAULT +ABS __bss_start
+ +41: 0+109e0 +0 NOTYPE +GLOBAL DEFAULT +ABS _edata
+ +42: 0+10a10 +0 NOTYPE +GLOBAL DEFAULT +ABS _end
+ +43: 0+38 +0 TLS +GLOBAL DEFAULT +10 gd0
+ +44: 0+58 +0 TLS +GLOBAL DEFAULT +10 ie0
diff --git a/ld/testsuite/ld-powerpc/tlsso.t b/ld/testsuite/ld-powerpc/tlsso.t
new file mode 100644
index 0000000..31c7da5
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlsso.t
@@ -0,0 +1,13 @@
+#source: tls.s
+#as: -a64
+#ld: -shared -melf64ppc
+#objdump: -sj.tdata
+#target: powerpc64*-*-*
+
+.*: +file format elf64-powerpc
+
+Contents of section \.tdata:
+ 107f8 12345678 9abcdef0 23456789 abcdef01 .*
+ 10808 3456789a bcdef012 456789ab cdef0123 .*
+ 10818 56789abc def01234 6789abcd ef012345 .*
+ 10828 789abcde f0123456 .*
diff --git a/ld/testsuite/ld-powerpc/tlstoc.d b/ld/testsuite/ld-powerpc/tlstoc.d
new file mode 100644
index 0000000..d598bbe
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlstoc.d
@@ -0,0 +1,37 @@
+#source: tlslib.s
+#source: tlstoc.s
+#as: -a64
+#ld: -melf64ppc
+#objdump: -dr
+#target: powerpc64*-*-*
+
+.*: +file format elf64-powerpc
+
+Disassembly of section \.text:
+
+00000000100000e8 <\.__tls_get_addr>:
+ 100000e8: 4e 80 00 20 blr
+
+00000000100000ec <_start>:
+ 100000ec: 3c 6d 00 00 addis r3,r13,0
+ 100000f0: 60 00 00 00 nop
+ 100000f4: 38 63 90 58 addi r3,r3,-28584
+ 100000f8: 3c 6d 00 00 addis r3,r13,0
+ 100000fc: 60 00 00 00 nop
+ 10000100: 38 63 10 00 addi r3,r3,4096
+ 10000104: 3c 6d 00 00 addis r3,r13,0
+ 10000108: 60 00 00 00 nop
+ 1000010c: 38 63 90 58 addi r3,r3,-28584
+ 10000110: 3c 6d 00 00 addis r3,r13,0
+ 10000114: 60 00 00 00 nop
+ 10000118: 38 63 10 00 addi r3,r3,4096
+ 1000011c: 39 23 80 50 addi r9,r3,-32688
+ 10000120: 3d 23 00 00 addis r9,r3,0
+ 10000124: 81 49 80 58 lwz r10,-32680\(r9\)
+ 10000128: 3d 2d 00 00 addis r9,r13,0
+ 1000012c: 7d 49 18 2a ldx r10,r9,r3
+ 10000130: 3d 2d 00 00 addis r9,r13,0
+ 10000134: a1 49 90 a0 lhz r10,-28512\(r9\)
+ 10000138: 89 4d 90 70 lbz r10,-28560\(r13\)
+ 1000013c: 3d 2d 00 00 addis r9,r13,0
+ 10000140: 99 49 90 78 stb r10,-28552\(r9\)
diff --git a/ld/testsuite/ld-powerpc/tlstoc.g b/ld/testsuite/ld-powerpc/tlstoc.g
new file mode 100644
index 0000000..f5249ac
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlstoc.g
@@ -0,0 +1,15 @@
+#source: tlslib.s
+#source: tlstoc.s
+#as: -a64
+#ld: -melf64ppc
+#objdump: -sj.toc
+#target: powerpc64*-*-*
+
+.*: +file format elf64-powerpc
+
+Contents of section \.toc:
+ 100101a0 00000000 00000001 00000000 00000000 .*
+ 100101b0 00000000 00000001 00000000 00000000 .*
+ 100101c0 00000000 00000001 00000000 00000000 .*
+ 100101d0 00000000 00000001 00000000 00000000 .*
+ 100101e0 ffffffff ffff8060 00000000 00000000 .*
diff --git a/ld/testsuite/ld-powerpc/tlstoc.s b/ld/testsuite/ld-powerpc/tlstoc.s
new file mode 100644
index 0000000..5008d89
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlstoc.s
@@ -0,0 +1,88 @@
+ .section ".tbss","awT",@nobits
+ .global _start,gd0,ld0,ld1,ld2,ie0,le0,le1
+ .align 3
+gd0: .space 8
+ld0: .space 8
+ld1: .space 8
+ld2: .space 8
+ie0: .space 8
+le0: .space 8
+le1: .space 8
+
+ .section ".tdata","awT",@progbits
+ .align 3
+gd4: .quad 0x123456789abcdef0
+ld4: .quad 0x23456789abcdef01
+ld5: .quad 0x3456789abcdef012
+ld6: .quad 0x456789abcdef0123
+ie4: .quad 0x56789abcdef01234
+le4: .quad 0x6789abcdef012345
+le5: .quad 0x789abcdef0123456
+
+ .text
+_start:
+#extern syms
+#GD
+ addi 3,2,.Lgd@toc
+ bl .__tls_get_addr
+ nop
+ .section .toc,"aw",@progbits
+.Lgd:
+ .quad gd@dtpmod
+ .quad gd@dtprel
+ .text
+#LD
+ addi 3,2,.Lld@toc
+ bl .__tls_get_addr
+ nop
+ .section .toc,"aw",@progbits
+.Lld:
+ .quad ld@dtpmod
+ .quad 0
+ .text
+
+#global syms
+#GD
+ addi 3,2,.Lgd0@toc
+ bl .__tls_get_addr
+ nop
+ .section .toc,"aw",@progbits
+.Lgd0:
+ .quad gd0@dtpmod
+ .quad gd0@dtprel
+ .text
+#LD
+ addi 3,2,.Lld0@toc
+ bl .__tls_get_addr
+ nop
+ .section .toc,"aw",@progbits
+.Lld0:
+ .quad ld0@dtpmod
+ .quad 0
+ .text
+
+ addi 9,3,ld0@dtprel
+
+ addis 9,3,ld1@dtprel@ha
+ lwz 10,ld1@dtprel@l(9)
+
+ ld 9,.Lld2@toc(2)
+ ldx 10,9,3
+ .section .toc,"aw",@progbits
+.Lld2:
+ .quad ld2@dtprel
+ .text
+
+#IE
+ ld 9,.Lie0@toc(2)
+ lhzx 10,9,.Lie0@tls
+ .section .toc,"aw",@progbits
+.Lie0:
+ .quad ie0@tprel
+ .text
+
+#LE
+ lbz 10,le0@tprel(13) #R_PPC64_TPREL16 le0
+
+ addis 9,13,le1@tprel@ha #R_PPC64_TPREL16_HA le1
+ stb 10,le1@tprel@l(9) #R_PPC64_TPREL16_LO le1
diff --git a/ld/testsuite/ld-powerpc/tlstoc.t b/ld/testsuite/ld-powerpc/tlstoc.t
new file mode 100644
index 0000000..5a8129a
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlstoc.t
@@ -0,0 +1,14 @@
+#source: tlslib.s
+#source: tlstoc.s
+#as: -a64
+#ld: -melf64ppc
+#objdump: -sj.tdata
+#target: powerpc64*-*-*
+
+.*: +file format elf64-powerpc
+
+Contents of section \.tdata:
+ 10010148 00c0ffee 00000000 12345678 9abcdef0 .*
+ 10010158 23456789 abcdef01 3456789a bcdef012 .*
+ 10010168 456789ab cdef0123 56789abc def01234 .*
+ 10010178 6789abcd ef012345 789abcde f0123456 .*
diff --git a/ld/testsuite/ld-powerpc/tlstocso.d b/ld/testsuite/ld-powerpc/tlstocso.d
new file mode 100644
index 0000000..174ef23
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlstocso.d
@@ -0,0 +1,52 @@
+#source: tlstoc.s
+#as: -a64
+#ld: -shared -melf64ppc
+#objdump: -dr
+#target: powerpc64*-*-*
+
+.*: +file format elf64-powerpc
+
+Disassembly of section \.text:
+
+0+6b8 <\.__tls_get_addr>:
+ 6b8: 3d 82 00 00 addis r12,r2,0
+ 6bc: f8 41 00 28 std r2,40\(r1\)
+ 6c0: e9 6c 80 70 ld r11,-32656\(r12\)
+ 6c4: e8 4c 80 78 ld r2,-32648\(r12\)
+ 6c8: 7d 69 03 a6 mtctr r11
+ 6cc: e9 6c 80 80 ld r11,-32640\(r12\)
+ 6d0: 4e 80 04 20 bctr
+
+0+6d4 <_start>:
+ 6d4: 38 62 80 08 addi r3,r2,-32760
+ 6d8: 4b ff ff e1 bl 6b8 <\.__tls_get_addr>
+ 6dc: e8 41 00 28 ld r2,40\(r1\)
+ 6e0: 38 62 80 18 addi r3,r2,-32744
+ 6e4: 4b ff ff d5 bl 6b8 <\.__tls_get_addr>
+ 6e8: e8 41 00 28 ld r2,40\(r1\)
+ 6ec: 38 62 80 28 addi r3,r2,-32728
+ 6f0: 4b ff ff c9 bl 6b8 <\.__tls_get_addr>
+ 6f4: e8 41 00 28 ld r2,40\(r1\)
+ 6f8: 38 62 80 38 addi r3,r2,-32712
+ 6fc: 4b ff ff bd bl 6b8 <\.__tls_get_addr>
+ 700: e8 41 00 28 ld r2,40\(r1\)
+ 704: 39 23 80 40 addi r9,r3,-32704
+ 708: 3d 23 00 00 addis r9,r3,0
+ 70c: 81 49 80 48 lwz r10,-32696\(r9\)
+ 710: 3d 2d 00 00 addis r9,r13,0
+ 714: 7d 49 18 2a ldx r10,r9,r3
+ 718: e9 22 80 50 ld r9,-32688\(r2\)
+ 71c: 7d 49 6a 2e lhzx r10,r9,r13
+ 720: 89 4d 00 00 lbz r10,0\(r13\)
+ 724: 3d 2d 00 00 addis r9,r13,0
+ 728: 99 49 00 00 stb r10,0\(r9\)
+ 72c: e8 41 00 28 ld r2,40\(r1\)
+ 730: 3d 82 00 00 addis r12,r2,0
+ 734: e9 6c 80 58 ld r11,-32680\(r12\)
+ 738: e8 4c 80 60 ld r2,-32672\(r12\)
+ 73c: 7d 69 03 a6 mtctr r11
+ 740: e9 6c 80 68 ld r11,-32664\(r12\)
+ 744: 4e 80 04 20 bctr
+ 748: 60 00 00 00 nop
+ 74c: 38 00 00 00 li r0,0
+ 750: 4b ff ff dc b 72c <_start\+0x58>
diff --git a/ld/testsuite/ld-powerpc/tlstocso.g b/ld/testsuite/ld-powerpc/tlstocso.g
new file mode 100644
index 0000000..5842aac
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlstocso.g
@@ -0,0 +1,14 @@
+#source: tlstoc.s
+#as: -a64
+#ld: -shared -melf64ppc
+#objdump: -sj.toc
+#target: powerpc64*-*-*
+
+.*: +file format elf64-powerpc
+
+Contents of section \.toc:
+ 108e8 00000000 00000000 00000000 00000000 .*
+ 108f8 00000000 00000000 00000000 00000000 .*
+ 10908 00000000 00000000 00000000 00000000 .*
+ 10918 00000000 00000000 00000000 00000000 .*
+ 10928 00000000 00000000 00000000 00000000 .*
diff --git a/ld/testsuite/ld-powerpc/tlstocso.r b/ld/testsuite/ld-powerpc/tlstocso.r
new file mode 100644
index 0000000..05e45cb
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlstocso.r
@@ -0,0 +1,157 @@
+#source: tlstoc.s
+#as: -a64
+#ld: -shared -melf64ppc
+#readelf: -WSsrl
+#target: powerpc64*-*-*
+
+There are 22 section headers.*
+
+Section Headers:
+ +\[Nr\] Name +Type +Address +Off +Size +ES Flg Lk Inf Al
+ +\[ 0\] +NULL +0+ 0+ 0+ 0+ +0 +0 +0
+ +\[ 1\] \.hash +HASH +0+120 0+120 0+d8 04 +A +2 +0 +8
+ +\[ 2\] \.dynsym +DYNSYM +0+1f8 0+1f8 0+348 18 +A +3 +13 +8
+ +\[ 3\] \.dynstr +STRTAB +0+540 0+540 0+54 0+ +A +0 +0 +1
+ +\[ 4\] \.rela\.dyn +RELA +0+598 0+598 0+108 18 +A +2 +0 +8
+ +\[ 5\] \.rela\.plt +RELA +0+6a0 0+6a0 0+18 18 +A +2 +11 +8
+ +\[ 6\] \.text +PROGBITS +0+6b8 0+6b8 0+9c 0+ +AX +0 +0 +4
+ +\[ 7\] \.data +PROGBITS +0+10758 0+758 0+ 0+ +WA +0 +0 +1
+ +\[ 8\] \.branch_lt +PROGBITS +0+10758 0+758 0+ 0+ +WA +0 +0 +8
+ +\[ 9\] \.tdata +PROGBITS +0+10758 0+758 0+38 0+ WAT +0 +0 +8
+ +\[10\] \.tbss +NOBITS +0+10790 0+790 0+38 0+ WAT +0 +0 +8
+ +\[11\] \.dynamic +DYNAMIC +0+10790 0+790 0+150 10 +WA +3 +0 +8
+ +\[12\] \.ctors +PROGBITS +0+108e0 0+938 0+ 0+ +W +0 +0 +1
+ +\[13\] \.dtors +PROGBITS +0+108e0 0+938 0+ 0+ +W +0 +0 +1
+ +\[14\] \.got +PROGBITS +0+108e0 0+8e0 0+8 08 +WA +0 +0 +8
+ +\[15\] \.toc +PROGBITS +0+108e8 0+8e8 0+50 0+ +WA +0 +0 +1
+ +\[16\] \.sbss +PROGBITS +0+10938 0+938 0+ 0+ +W +0 +0 +1
+ +\[17\] \.plt +NOBITS +0+10938 0+938 0+30 18 +WA +0 +0 +8
+ +\[18\] \.bss +NOBITS +0+10968 0+938 0+ 0+ +WA +0 +0 +1
+ +\[19\] \.shstrtab +STRTAB +0+ 0+938 0+95 0+ +0 +0 +1
+ +\[20\] \.symtab +SYMTAB +0+ 0+f50 0+468 18 +21 +1f +8
+ +\[21\] \.strtab +STRTAB +0+ 0+13b8 0+92 0+ +0 +0 +1
+#...
+
+Elf file type is DYN \(Shared object file\)
+Entry point 0x6d4
+There are 4 program headers.*
+
+Program Headers:
+ +Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
+ +LOAD +0x0+ 0x0+ 0x0+ 0x0+754 0x0+754 R E 0x10000
+ +LOAD +0x0+758 0x0+10758 0x0+10758 0x0+1e0 0x0+210 RW +0x10000
+ +DYNAMIC +0x0+790 0x0+10790 0x0+10790 0x0+150 0x0+150 RW +0x8
+ +TLS +0x0+758 0x0+10758 0x0+10758 0x0+38 0x0+70 R +0x8
+
+ Section to Segment mapping:
+ +Segment Sections\.\.\.
+ +0+ +\.hash \.dynsym \.dynstr \.rela\.dyn \.rela\.plt \.text
+ +01 +\.tdata \.tbss \.dynamic \.got \.toc \.plt
+ +02 +\.tbss \.dynamic
+ +03 +\.tdata \.tbss
+
+Relocation section '\.rela\.dyn' at offset .* contains 11 entries:
+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
+0+712 +0+f00000048 R_PPC64_TPREL16_HA +0+108e8 \.toc \+ 40
+0+722 +0+1500000045 R_PPC64_TPREL16 +0+60 le0 \+ 0
+0+726 +0+1800000048 R_PPC64_TPREL16_HA +0+68 le1 \+ 0
+0+108e8 +0+1400000044 R_PPC64_DTPMOD64 +0+ gd \+ 0
+0+108f0 +0+140000004e R_PPC64_DTPREL64 +0+ gd \+ 0
+0+108f8 +0+1900000044 R_PPC64_DTPMOD64 +0+ ld \+ 0
+0+10908 +0+2100000044 R_PPC64_DTPMOD64 +0+38 gd0 \+ 0
+0+10910 +0+210000004e R_PPC64_DTPREL64 +0+38 gd0 \+ 0
+0+10918 +0+1700000044 R_PPC64_DTPMOD64 +0+40 ld0 \+ 0
+0+10928 +0+1c0000004e R_PPC64_DTPREL64 +0+50 ld2 \+ 0
+0+10930 +0+2200000049 R_PPC64_TPREL64 +0+58 ie0 \+ 0
+
+Relocation section '\.rela\.plt' at offset 0x6a0 contains 1 entries:
+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
+0+10950 +0+1600000015 R_PPC64_JMP_SLOT +0+ __tls_get_addr \+ 0
+
+Symbol table '\.dynsym' contains 35 entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+ +0: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND
+ +1: 0+120 +0 SECTION LOCAL +DEFAULT +1
+ +2: 0+1f8 +0 SECTION LOCAL +DEFAULT +2
+ +3: 0+540 +0 SECTION LOCAL +DEFAULT +3
+ +4: 0+598 +0 SECTION LOCAL +DEFAULT +4
+ +5: 0+6a0 +0 SECTION LOCAL +DEFAULT +5
+ +6: 0+6b8 +0 SECTION LOCAL +DEFAULT +6
+ +7: 0+10758 +0 SECTION LOCAL +DEFAULT +7
+ +8: 0+10758 +0 SECTION LOCAL +DEFAULT +8
+ +9: 0+10758 +0 SECTION LOCAL +DEFAULT +9
+ +10: 0+10790 +0 SECTION LOCAL +DEFAULT +10
+ +11: 0+10790 +0 SECTION LOCAL +DEFAULT +11
+ +12: 0+108e0 +0 SECTION LOCAL +DEFAULT +12
+ +13: 0+108e0 +0 SECTION LOCAL +DEFAULT +13
+ +14: 0+108e0 +0 SECTION LOCAL +DEFAULT +14
+ +15: 0+108e8 +0 SECTION LOCAL +DEFAULT +15
+ +16: 0+10938 +0 SECTION LOCAL +DEFAULT +16
+ +17: 0+10938 +0 SECTION LOCAL +DEFAULT +17
+ +18: 0+10968 +0 SECTION LOCAL +DEFAULT +18
+ +19: 0+10790 +0 OBJECT +GLOBAL DEFAULT +ABS _DYNAMIC
+ +20: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND gd
+ +21: 0+60 +0 TLS +GLOBAL DEFAULT +10 le0
+ +22: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND __tls_get_addr
+ +23: 0+40 +0 TLS +GLOBAL DEFAULT +10 ld0
+ +24: 0+68 +0 TLS +GLOBAL DEFAULT +10 le1
+ +25: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND ld
+ +26: 0+6d4 +0 NOTYPE +GLOBAL DEFAULT +6 _start
+ +27: 0+10968 +0 NOTYPE +GLOBAL DEFAULT +ABS __end
+ +28: 0+50 +0 TLS +GLOBAL DEFAULT +10 ld2
+ +29: 0+48 +0 TLS +GLOBAL DEFAULT +10 ld1
+ +30: 0+10938 +0 NOTYPE +GLOBAL DEFAULT +ABS __bss_start
+ +31: 0+10938 +0 NOTYPE +GLOBAL DEFAULT +ABS _edata
+ +32: 0+10968 +0 NOTYPE +GLOBAL DEFAULT +ABS _end
+ +33: 0+38 +0 TLS +GLOBAL DEFAULT +10 gd0
+ +34: 0+58 +0 TLS +GLOBAL DEFAULT +10 ie0
+
+Symbol table '\.symtab' contains 47 entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+ +0: 0+ +0 NOTYPE +LOCAL +DEFAULT +UND
+ +1: 0+120 +0 SECTION LOCAL +DEFAULT +1
+ +2: 0+1f8 +0 SECTION LOCAL +DEFAULT +2
+ +3: 0+540 +0 SECTION LOCAL +DEFAULT +3
+ +4: 0+598 +0 SECTION LOCAL +DEFAULT +4
+ +5: 0+6a0 +0 SECTION LOCAL +DEFAULT +5
+ +6: 0+6b8 +0 SECTION LOCAL +DEFAULT +6
+ +7: 0+10758 +0 SECTION LOCAL +DEFAULT +7
+ +8: 0+10758 +0 SECTION LOCAL +DEFAULT +8
+ +9: 0+10758 +0 SECTION LOCAL +DEFAULT +9
+ +10: 0+10790 +0 SECTION LOCAL +DEFAULT +10
+ +11: 0+10790 +0 SECTION LOCAL +DEFAULT +11
+ +12: 0+108e0 +0 SECTION LOCAL +DEFAULT +12
+ +13: 0+108e0 +0 SECTION LOCAL +DEFAULT +13
+ +14: 0+108e0 +0 SECTION LOCAL +DEFAULT +14
+ +15: 0+108e8 +0 SECTION LOCAL +DEFAULT +15
+ +16: 0+10938 +0 SECTION LOCAL +DEFAULT +16
+ +17: 0+10938 +0 SECTION LOCAL +DEFAULT +17
+ +18: 0+10968 +0 SECTION LOCAL +DEFAULT +18
+ +19: 0+ +0 SECTION LOCAL +DEFAULT +19
+ +20: 0+ +0 SECTION LOCAL +DEFAULT +20
+ +21: 0+ +0 SECTION LOCAL +DEFAULT +21
+ +22: 0+ +0 TLS +LOCAL +DEFAULT +9 gd4
+ +23: 0+8 +0 TLS +LOCAL +DEFAULT +9 ld4
+ +24: 0+10 +0 TLS +LOCAL +DEFAULT +9 ld5
+ +25: 0+18 +0 TLS +LOCAL +DEFAULT +9 ld6
+ +26: 0+20 +0 TLS +LOCAL +DEFAULT +9 ie4
+ +27: 0+28 +0 TLS +LOCAL +DEFAULT +9 le4
+ +28: 0+30 +0 TLS +LOCAL +DEFAULT +9 le5
+ +29: 0+10930 +0 NOTYPE +LOCAL +DEFAULT +15 \.Lie0
+ +30: 0+6b8 +0 NOTYPE +LOCAL +DEFAULT +6 \.__tls_get_addr
+ +31: 0+10790 +0 OBJECT +GLOBAL DEFAULT +ABS _DYNAMIC
+ +32: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND gd
+ +33: 0+60 +0 TLS +GLOBAL DEFAULT +10 le0
+ +34: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND __tls_get_addr
+ +35: 0+40 +0 TLS +GLOBAL DEFAULT +10 ld0
+ +36: 0+68 +0 TLS +GLOBAL DEFAULT +10 le1
+ +37: 0+ +0 NOTYPE +GLOBAL DEFAULT +UND ld
+ +38: 0+6d4 +0 NOTYPE +GLOBAL DEFAULT +6 _start
+ +39: 0+10968 +0 NOTYPE +GLOBAL DEFAULT +ABS __end
+ +40: 0+50 +0 TLS +GLOBAL DEFAULT +10 ld2
+ +41: 0+48 +0 TLS +GLOBAL DEFAULT +10 ld1
+ +42: 0+10938 +0 NOTYPE +GLOBAL DEFAULT +ABS __bss_start
+ +43: 0+10938 +0 NOTYPE +GLOBAL DEFAULT +ABS _edata
+ +44: 0+10968 +0 NOTYPE +GLOBAL DEFAULT +ABS _end
+ +45: 0+38 +0 TLS +GLOBAL DEFAULT +10 gd0
+ +46: 0+58 +0 TLS +GLOBAL DEFAULT +10 ie0
diff --git a/ld/testsuite/ld-powerpc/tlstocso.t b/ld/testsuite/ld-powerpc/tlstocso.t
new file mode 100644
index 0000000..298a5bc
--- /dev/null
+++ b/ld/testsuite/ld-powerpc/tlstocso.t
@@ -0,0 +1,13 @@
+#source: tlstoc.s
+#as: -a64
+#ld: -shared -melf64ppc
+#objdump: -sj.tdata
+#target: powerpc64*-*-*
+
+.*: +file format elf64-powerpc
+
+Contents of section \.tdata:
+ 10758 12345678 9abcdef0 23456789 abcdef01 .*
+ 10768 3456789a bcdef012 456789ab cdef0123 .*
+ 10778 56789abc def01234 6789abcd ef012345 .*
+ 10788 789abcde f0123456 .*