aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaz Kojima <kkojima@rr.iij4u.or.jp>2002-10-11 14:44:55 +0000
committerKaz Kojima <kkojima@rr.iij4u.or.jp>2002-10-11 14:44:55 +0000
commit6c381eeb71e6f61062fb64795097e144d48fa798 (patch)
tree12b7b3e030baa928d152f3d6a3fa9eed99edb1a8
parent94a03f18b830422643115cfdae48aed9cdc5c485 (diff)
downloadgdb-6c381eeb71e6f61062fb64795097e144d48fa798.zip
gdb-6c381eeb71e6f61062fb64795097e144d48fa798.tar.gz
gdb-6c381eeb71e6f61062fb64795097e144d48fa798.tar.bz2
* ld-sh/rd-sh.exp: If the test matches *-dso.d, copy the output
of linker to the file tmpdir/*-dso.so. * ld-sh/tlsbin.s, ld-sh/tlsbinpic.s, ld-sh/tlslib.s: New. * ld-sh/tlsbin-0-dso.d: New. * ld-sh/tlsbin-1.d: New. * ld-sh/tlsbin-2.d: New. * ld-sh/tlsbin-3.d: New. * ld-sh/tlsbin-4.d: New. * ld-sh/tlspic1.s, ld-sh/tlspic2.s: New. * ld-sh/tlspic-1.d: New. * ld-sh/tlspic-2.d: New. * ld-sh/tlspic-3.d: New. * ld-sh/tlspic-4.d: New.
-rw-r--r--ld/testsuite/ChangeLog16
-rw-r--r--ld/testsuite/ld-sh/rd-sh.exp10
-rw-r--r--ld/testsuite/ld-sh/tlsbin-0-dso.d9
-rw-r--r--ld/testsuite/ld-sh/tlsbin-1.d296
-rw-r--r--ld/testsuite/ld-sh/tlsbin-2.d145
-rw-r--r--ld/testsuite/ld-sh/tlsbin-3.d12
-rw-r--r--ld/testsuite/ld-sh/tlsbin-4.d12
-rw-r--r--ld/testsuite/ld-sh/tlsbin.s90
-rw-r--r--ld/testsuite/ld-sh/tlsbinpic.s206
-rw-r--r--ld/testsuite/ld-sh/tlslib.s20
-rw-r--r--ld/testsuite/ld-sh/tlspic-1.d292
-rw-r--r--ld/testsuite/ld-sh/tlspic-2.d132
-rw-r--r--ld/testsuite/ld-sh/tlspic-3.d15
-rw-r--r--ld/testsuite/ld-sh/tlspic-4.d12
-rw-r--r--ld/testsuite/ld-sh/tlspic1.s267
-rw-r--r--ld/testsuite/ld-sh/tlspic2.s5
16 files changed, 1539 insertions, 0 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 3a681f6..536b479 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,19 @@
+2002-10-11 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * ld-sh/rd-sh.exp: If the test matches *-dso.d, copy the output
+ of linker to the file tmpdir/*-dso.so.
+ * ld-sh/tlsbin.s, ld-sh/tlsbinpic.s, ld-sh/tlslib.s: New.
+ * ld-sh/tlsbin-0-dso.d: New.
+ * ld-sh/tlsbin-1.d: New.
+ * ld-sh/tlsbin-2.d: New.
+ * ld-sh/tlsbin-3.d: New.
+ * ld-sh/tlsbin-4.d: New.
+ * ld-sh/tlspic1.s, ld-sh/tlspic2.s: New.
+ * ld-sh/tlspic-1.d: New.
+ * ld-sh/tlspic-2.d: New.
+ * ld-sh/tlspic-3.d: New.
+ * ld-sh/tlspic-4.d: New.
+
2002-10-10 Jakub Jelinek <jakub@redhat.com>
* ld-i386/combreloc.s: New test.
diff --git a/ld/testsuite/ld-sh/rd-sh.exp b/ld/testsuite/ld-sh/rd-sh.exp
index 5bc9a0c..7060d02 100644
--- a/ld/testsuite/ld-sh/rd-sh.exp
+++ b/ld/testsuite/ld-sh/rd-sh.exp
@@ -33,4 +33,14 @@ foreach shtest $rd_test_list {
# We need to strip the ".d", but can leave the dirname.
verbose [file rootname $shtest]
run_dump_test [file rootname $shtest]
+ if [string match $srcdir/$subdir/*-dso.d $shtest] {
+ # Copy the output of the DSO-createing test to .so file.
+ # Notice that a DSO-creating test must preceed the tests
+ # which need that DSO in sort-order by name.
+ set cmd "cp tmpdir/dump tmpdir/[file rootname [file tail $shtest]].so"
+ send_log "$cmd\n"
+ set cmdret [catch "exec $cmd" comp_output]
+ send_log "$comp_output\n"
+ # FIXME: What if it fails? Need we do something?
+ }
}
diff --git a/ld/testsuite/ld-sh/tlsbin-0-dso.d b/ld/testsuite/ld-sh/tlsbin-0-dso.d
new file mode 100644
index 0000000..dc3eaa6
--- /dev/null
+++ b/ld/testsuite/ld-sh/tlsbin-0-dso.d
@@ -0,0 +1,9 @@
+#source: tlslib.s
+#as: -little
+#ld: -shared -EL
+#objdump: -drj.text
+#target: sh*-*-linux* sh*-*-netbsd*
+
+.*: +file format elf32-sh.*
+
+#pass
diff --git a/ld/testsuite/ld-sh/tlsbin-1.d b/ld/testsuite/ld-sh/tlsbin-1.d
new file mode 100644
index 0000000..a6f60c2a
--- /dev/null
+++ b/ld/testsuite/ld-sh/tlsbin-1.d
@@ -0,0 +1,296 @@
+#source: tlsbinpic.s
+#source: tlsbin.s
+#as: -little
+#ld: -EL tmpdir/tlsbin-0-dso.so
+#objdump: -drj.text
+#target: sh*-*-linux* sh*-*-netbsd*
+
+.*: +file format elf32-sh.*
+
+Disassembly of section \.text:
+
+0+401000 <fn2>:
+ 401000: c6 2f mov\.l r12,@-r15
+ 401002: e6 2f mov\.l r14,@-r15
+ 401004: 22 4f sts\.l pr,@-r15
+ 401006: 5f c7 mova 401184 <fn2\+0x184>,r0
+ 401008: 5e dc mov\.l 401184 <fn2\+0x184>,r12 ! 0x[0-9a-f]+
+ 40100a: 0c 3c add r0,r12
+ 40100c: f3 6e mov r15,r14
+ 40100e: 09 00 nop
+ 401010: 09 00 nop
+ 401012: 09 00 nop
+ 401014: 09 00 nop
+ 401016: 04 d0 mov\.l 401028 <fn2\+0x28>,r0 ! 0x1c
+ 401018: 12 04 stc gbr,r4
+ 40101a: ce 00 mov\.l @\(r0,r12\),r0
+ 40101c: 4c 30 add r4,r0
+ 40101e: 09 00 nop
+ 401020: 09 00 nop
+ 401022: 05 a0 bra 401030 <fn2\+0x30>
+ 401024: 09 00 nop
+ 401026: 09 00 nop
+ 401028: 1c 00 .*[ ]*.*
+ 40102a: 00 00 .*[ ]*.*
+ 40102c: [0-9a-f]+ [0-9a-f]+ .*[ ]*.*
+ 40102e: [0-9a-f]+ [0-9a-f]+ .*[ ]*.*
+ 401030: 09 00 nop
+ 401032: 09 00 nop
+ 401034: 09 00 nop
+ 401036: 09 00 nop
+ 401038: 03 d0 mov\.l 401048 <fn2\+0x48>,r0 ! 0x14
+ 40103a: 12 04 stc gbr,r4
+ 40103c: ce 00 mov\.l @\(r0,r12\),r0
+ 40103e: 4c 30 add r4,r0
+ 401040: 09 00 nop
+ 401042: 09 00 nop
+ 401044: 04 a0 bra 401050 <fn2\+0x50>
+ 401046: 09 00 nop
+ 401048: 14 00 .*[ ]*.*
+ 40104a: 00 00 .*[ ]*.*
+ 40104c: [0-9a-f]+ [0-9a-f]+ .*[ ]*.*
+ 40104e: [0-9a-f]+ [0-9a-f]+ .*[ ]*.*
+ 401050: 09 00 nop
+ 401052: 09 00 nop
+ 401054: 09 00 nop
+ 401056: 09 00 nop
+ 401058: 03 d4 mov\.l 401068 <fn2\+0x68>,r4 ! 0x0
+ 40105a: 12 00 stc gbr,r0
+ 40105c: 4c 30 add r4,r0
+ 40105e: 09 00 nop
+ 401060: 09 00 nop
+ 401062: 09 00 nop
+ 401064: 04 a0 bra 401070 <fn2\+0x70>
+ 401066: 09 00 nop
+ 401068: 00 00 .*[ ]*.*
+ 40106a: 00 00 .*[ ]*.*
+ 40106c: [0-9a-f]+ [0-9a-f]+ .*[ ]*.*
+ 40106e: [0-9a-f]+ [0-9a-f]+ .*[ ]*.*
+ 401070: 09 00 nop
+ 401072: 09 00 nop
+ 401074: 09 00 nop
+ 401076: 09 00 nop
+ 401078: 03 d4 mov\.l 401088 <fn2\+0x88>,r4 ! 0x0
+ 40107a: 12 00 stc gbr,r0
+ 40107c: 4c 30 add r4,r0
+ 40107e: 09 00 nop
+ 401080: 09 00 nop
+ 401082: 09 00 nop
+ 401084: 04 a0 bra 401090 <fn2\+0x90>
+ 401086: 09 00 nop
+ 401088: 00 00 .*[ ]*.*
+ 40108a: 00 00 .*[ ]*.*
+ 40108c: [0-9a-f]+ [0-9a-f]+ .*[ ]*.*
+ 40108e: [0-9a-f]+ [0-9a-f]+ .*[ ]*.*
+ 401090: 09 00 nop
+ 401092: 09 00 nop
+ 401094: 09 00 nop
+ 401096: 09 00 nop
+ 401098: 03 d4 mov\.l 4010a8 <fn2\+0xa8>,r4 ! 0x0
+ 40109a: 12 00 stc gbr,r0
+ 40109c: 4c 30 add r4,r0
+ 40109e: 09 00 nop
+ 4010a0: 09 00 nop
+ 4010a2: 09 00 nop
+ 4010a4: 04 a0 bra 4010b0 <fn2\+0xb0>
+ 4010a6: 09 00 nop
+ 4010a8: 00 00 .*[ ]*.*
+ 4010aa: 00 00 .*[ ]*.*
+ 4010ac: [0-9a-f]+ [0-9a-f]+ .*[ ]*.*
+ 4010ae: [0-9a-f]+ [0-9a-f]+ .*[ ]*.*
+ 4010b0: 09 00 nop
+ 4010b2: 09 00 nop
+ 4010b4: 09 00 nop
+ 4010b6: 09 00 nop
+ 4010b8: 12 00 stc gbr,r0
+ 4010ba: 09 00 nop
+ 4010bc: 09 00 nop
+ 4010be: 09 00 nop
+ 4010c0: 09 00 nop
+ 4010c2: 09 00 nop
+ 4010c4: 04 a0 bra 4010d0 <fn2\+0xd0>
+ 4010c6: 09 00 nop
+ 4010c8: 00 00 .*[ ]*.*
+ 4010ca: 00 00 .*[ ]*.*
+ 4010cc: [0-9a-f]+ [0-9a-f]+ .*[ ]*.*
+ 4010ce: [0-9a-f]+ [0-9a-f]+ .*[ ]*.*
+ 4010d0: 09 00 nop
+ 4010d2: 09 00 nop
+ 4010d4: 2c d1 mov\.l 401188 <fn2\+0x188>,r1 ! 0x0
+ 4010d6: 0c 31 add r0,r1
+ 4010d8: 09 00 nop
+ 4010da: 09 00 nop
+ 4010dc: 2b d2 mov\.l 40118c <fn2\+0x18c>,r2 ! 0x0
+ 4010de: 0c 32 add r0,r2
+ 4010e0: 09 00 nop
+ 4010e2: 09 00 nop
+ 4010e4: 09 00 nop
+ 4010e6: 09 00 nop
+ 4010e8: 12 00 stc gbr,r0
+ 4010ea: 09 00 nop
+ 4010ec: 09 00 nop
+ 4010ee: 09 00 nop
+ 4010f0: 09 00 nop
+ 4010f2: 09 00 nop
+ 4010f4: 04 a0 bra 401100 <fn2\+0x100>
+ 4010f6: 09 00 nop
+ 4010f8: 00 00 .*[ ]*.*
+ 4010fa: 00 00 .*[ ]*.*
+ 4010fc: [0-9a-f]+ [0-9a-f]+ .*[ ]*.*
+ 4010fe: [0-9a-f]+ [0-9a-f]+ .*[ ]*.*
+ 401100: 09 00 nop
+ 401102: 09 00 nop
+ 401104: 22 d1 mov\.l 401190 <fn2\+0x190>,r1 ! 0x0
+ 401106: 0c 31 add r0,r1
+ 401108: 09 00 nop
+ 40110a: 09 00 nop
+ 40110c: 21 d2 mov\.l 401194 <fn2\+0x194>,r2 ! 0x0
+ 40110e: 0c 32 add r0,r2
+ 401110: 09 00 nop
+ 401112: 09 00 nop
+ 401114: 09 00 nop
+ 401116: 09 00 nop
+ 401118: 02 d0 mov\.l 401124 <fn2\+0x124>,r0 ! 0x14
+ 40111a: 12 01 stc gbr,r1
+ 40111c: ce 00 mov\.l @\(r0,r12\),r0
+ 40111e: 03 a0 bra 401128 <fn2\+0x128>
+ 401120: 0c 31 add r0,r1
+ 401122: 09 00 nop
+ 401124: 14 00 .*[ ]*.*
+ 401126: 00 00 .*[ ]*.*
+ 401128: 09 00 nop
+ 40112a: 09 00 nop
+ 40112c: 09 00 nop
+ 40112e: 09 00 nop
+ 401130: 02 d0 mov\.l 40113c <fn2\+0x13c>,r0 ! 0x18
+ 401132: 12 01 stc gbr,r1
+ 401134: ce 00 mov\.l @\(r0,r12\),r0
+ 401136: 03 a0 bra 401140 <fn2\+0x140>
+ 401138: 1c 30 add r1,r0
+ 40113a: 09 00 nop
+ 40113c: 18 00 .*[ ]*.*
+ 40113e: 00 00 .*[ ]*.*
+ 401140: 09 00 nop
+ 401142: 09 00 nop
+ 401144: 09 00 nop
+ 401146: 09 00 nop
+ 401148: 02 d0 mov\.l 401154 <fn2\+0x154>,r0 ! 0x0
+ 40114a: 12 01 stc gbr,r1
+ 40114c: 09 00 nop
+ 40114e: 03 a0 bra 401158 <fn2\+0x158>
+ 401150: 0c 31 add r0,r1
+ 401152: 09 00 nop
+ 401154: 00 00 .*[ ]*.*
+ 401156: 00 00 .*[ ]*.*
+ 401158: 09 00 nop
+ 40115a: 09 00 nop
+ 40115c: 09 00 nop
+ 40115e: 09 00 nop
+ 401160: 02 d0 mov\.l 40116c <fn2\+0x16c>,r0 ! 0x0
+ 401162: 12 01 stc gbr,r1
+ 401164: 09 00 nop
+ 401166: 03 a0 bra 401170 <fn2\+0x170>
+ 401168: 0c 31 add r0,r1
+ 40116a: 09 00 nop
+ 40116c: 00 00 .*[ ]*.*
+ 40116e: 00 00 .*[ ]*.*
+ 401170: 09 00 nop
+ 401172: 09 00 nop
+ 401174: 09 00 nop
+ 401176: 09 00 nop
+ 401178: e3 6f mov r14,r15
+ 40117a: 26 4f lds\.l @r15\+,pr
+ 40117c: f6 6e mov\.l @r15\+,r14
+ 40117e: 0b 00 rts
+ 401180: f6 6c mov\.l @r15\+,r12
+ 401182: 09 00 nop
+ 401184: 3c 1f .*[ ]*.*
+ 401186: 01 00 .*[ ]*.*
+ \.\.\.
+
+00402000 <_start>:
+ 402000: c6 2f mov\.l r12,@-r15
+ 402002: e6 2f mov\.l r14,@-r15
+ 402004: f3 6e mov r15,r14
+ 402006: 27 c7 mova 4020a4 <_start\+0xa4>,r0
+ 402008: 26 dc mov\.l 4020a4 <_start\+0xa4>,r12 ! 0x[0-9a-f]+
+ 40200a: 0c 3c add r0,r12
+ 40200c: 09 00 nop
+ 40200e: 09 00 nop
+ 402010: 09 00 nop
+ 402012: 09 00 nop
+ 402014: 02 d0 mov\.l 402020 <_start\+0x20>,r0 ! 0x10
+ 402016: 12 01 stc gbr,r1
+ 402018: ce 00 mov\.l @\(r0,r12\),r0
+ 40201a: 03 a0 bra 402024 <_start\+0x24>
+ 40201c: 0c 31 add r0,r1
+ 40201e: 09 00 nop
+ 402020: 10 00 .*[ ]*.*
+ 402022: 00 00 .*[ ]*.*
+ 402024: 09 00 nop
+ 402026: 09 00 nop
+ 402028: 09 00 nop
+ 40202a: 09 00 nop
+ 40202c: 02 d0 mov\.l 402038 <_start\+0x38>,r0 ! 0x0
+ 40202e: 12 01 stc gbr,r1
+ 402030: 09 00 nop
+ 402032: 03 a0 bra 40203c <_start\+0x3c>
+ 402034: 0c 31 add r0,r1
+ 402036: 09 00 nop
+ 402038: 00 00 .*[ ]*.*
+ 40203a: 00 00 .*[ ]*.*
+ 40203c: 09 00 nop
+ 40203e: 09 00 nop
+ 402040: 09 00 nop
+ 402042: 09 00 nop
+ 402044: 02 d0 mov\.l 402050 <_start\+0x50>,r0 ! 0x0
+ 402046: 12 01 stc gbr,r1
+ 402048: 09 00 nop
+ 40204a: 03 a0 bra 402054 <_start\+0x54>
+ 40204c: 0c 31 add r0,r1
+ 40204e: 09 00 nop
+ 402050: 00 00 .*[ ]*.*
+ 402052: 00 00 .*[ ]*.*
+ 402054: 09 00 nop
+ 402056: 09 00 nop
+ 402058: 09 00 nop
+ 40205a: 09 00 nop
+ 40205c: 02 d0 mov\.l 402068 <_start\+0x68>,r0 ! 0x0
+ 40205e: 12 01 stc gbr,r1
+ 402060: 09 00 nop
+ 402062: 03 a0 bra 40206c <_start\+0x6c>
+ 402064: 0c 31 add r0,r1
+ 402066: 09 00 nop
+ 402068: 00 00 .*[ ]*.*
+ 40206a: 00 00 .*[ ]*.*
+ 40206c: 09 00 nop
+ 40206e: 09 00 nop
+ 402070: 09 00 nop
+ 402072: 09 00 nop
+ 402074: 12 01 stc gbr,r1
+ 402076: 0c d0 mov\.l 4020a8 <_start\+0xa8>,r0 ! 0x0
+ 402078: 1c 30 add r1,r0
+ 40207a: 09 00 nop
+ 40207c: 09 00 nop
+ 40207e: 09 00 nop
+ 402080: 09 00 nop
+ 402082: 12 01 stc gbr,r1
+ 402084: 09 d0 mov\.l 4020ac <_start\+0xac>,r0 ! 0x0
+ 402086: 1c 30 add r1,r0
+ 402088: 09 00 nop
+ 40208a: 09 00 nop
+ 40208c: 09 00 nop
+ 40208e: 09 00 nop
+ 402090: 12 01 stc gbr,r1
+ 402092: 07 d0 mov\.l 4020b0 <_start\+0xb0>,r0 ! 0x0
+ 402094: 1c 30 add r1,r0
+ 402096: 09 00 nop
+ 402098: 09 00 nop
+ 40209a: 09 00 nop
+ 40209c: 09 00 nop
+ 40209e: e3 6f mov r14,r15
+ 4020a0: 0b 00 rts
+ 4020a2: f6 6e mov\.l @r15\+,r14
+ 4020a4: 1c 10 .*[ ]*.*
+ 4020a6: 01 00 .*[ ]*.*
+ \.\.\.
diff --git a/ld/testsuite/ld-sh/tlsbin-2.d b/ld/testsuite/ld-sh/tlsbin-2.d
new file mode 100644
index 0000000..bde8440
--- /dev/null
+++ b/ld/testsuite/ld-sh/tlsbin-2.d
@@ -0,0 +1,145 @@
+#source: tlsbinpic.s
+#source: tlsbin.s
+#as: -little
+#ld: -EL tmpdir/tlsbin-0-dso.so
+#readelf: -Ssrl
+#target: sh*-*-linux* sh*-*-netbsd*
+
+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\] +NULL +0+ 0+ 0+ 0+ +0 +0 +0
+ \[ 1\] \.interp +.*
+ \[ 2\] \.hash +.*
+ \[ 3\] \.dynsym +.*
+ \[ 4\] \.dynstr +.*
+ \[ 5\] \.rela\.dyn +.*
+ \[ 6\] \.rela\.plt +.*
+ \[ 7\] \.plt +.*
+ \[ 8\] \.text +PROGBITS +0+401000 .*
+ \[ 9\] \.data +.*
+ \[10\] \.tdata +PROGBITS +0+413000 [0-9a-f]+ 0+018 00 WAT 0 0 1
+ \[11\] \.tbss +NOBITS +0+413018 [0-9a-f]+ 0+010 00 WAT 0 0 1
+ \[12\] \.dynamic +DYNAMIC +0+413018 .*
+#...
+ \[[0-9a-f]+\] \.got +PROGBITS +0+4130c0 .*
+ \[[0-9a-f]+\] \.sbss +.*
+ \[[0-9a-f]+\] \.bss +.*
+#...
+ \[[0-9a-f]+\] \.shstrtab +.*
+ \[[0-9a-f]+\] \.symtab +.*
+ \[[0-9a-f]+\] \.strtab +.*
+Key to Flags:
+.*
+.*
+.*
+
+Elf file type is EXEC \(Executable file\)
+Entry point 0x402000
+There are [0-9]+ program headers, starting at offset [0-9]+
+
+Program Headers:
+ Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
+ PHDR.*
+ INTERP.*
+.*Requesting program interpreter.*
+ LOAD.*
+ LOAD.*
+ DYNAMIC.*
+ TLS +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+18 0x0+28 R +0x1
+
+ Section to Segment mapping:
+ Segment Sections\.\.\.
+ 00 +
+ 01 +\.interp *
+ 02 +\.interp \.hash \.dynsym \.dynstr \.rela\.dyn \.rela\.plt \.plt \.text *
+ 03 +\.tdata \.tbss \.dynamic \.got *
+ 04 +\.tbss \.dynamic *
+ 05 +\.tdata \.tbss *
+
+Relocation section '\.rela\.dyn' at offset 0x[0-9a-f]+ contains 19 entries:
+ Offset +Info +Type +Sym\.Value +Sym\. Name \+ Addend
+0+401068 00000097 R_SH_TLS_TPOFF32 +0+00
+0+401088 00000097 R_SH_TLS_TPOFF32 +0+08
+0+4010a8 00000097 R_SH_TLS_TPOFF32 +0+10
+0+401154 00000097 R_SH_TLS_TPOFF32 +0+00
+0+40116c 00000097 R_SH_TLS_TPOFF32 +0+10
+0+401188 00000097 R_SH_TLS_TPOFF32 +0+08
+0+40118c 00000097 R_SH_TLS_TPOFF32 +0+0c
+0+401190 00000097 R_SH_TLS_TPOFF32 +0+10
+0+401194 00000097 R_SH_TLS_TPOFF32 +0+14
+0+402038 00000097 R_SH_TLS_TPOFF32 +0+18
+0+402050 00000097 R_SH_TLS_TPOFF32 +0+24
+0+402068 00000097 R_SH_TLS_TPOFF32 +0+14
+0+4020a8 00000097 R_SH_TLS_TPOFF32 +0+00
+0+4020ac 00000097 R_SH_TLS_TPOFF32 +0+20
+0+4020b0 00000097 R_SH_TLS_TPOFF32 +0+10
+0+4130d0 00000197 R_SH_TLS_TPOFF32 +0+ +sG3 \+ 0
+0+4130d4 00000397 R_SH_TLS_TPOFF32 +0+ +sG2 \+ 0
+0+4130d8 00000497 R_SH_TLS_TPOFF32 +0+ +sG4 \+ 0
+0+4130dc 0000[0-9a-f]+97 R_SH_TLS_TPOFF32 +0+ +sG1 \+ 0
+
+Relocation section '\.rela\.plt' at offset 0x[0-9a-f]+ contains 1 entries:
+ Offset +Info +Type +Sym\.Value +Sym\. Name \+ Addend
+0+4130cc 000005a4 R_SH_JMP_SLOT +[0-9a-f]+ +__tls_get_addr \+ 0
+
+Symbol table '\.dynsym' contains [0-9]+ entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+ +0: 0+ +0 NOTYPE +LOCAL +DEFAULT UND *
+ +1: 0+ +0 TLS +GLOBAL DEFAULT UND sG3
+ +2: [0-9a-f]+ +0 OBJECT GLOBAL DEFAULT ABS _DYNAMIC
+ +3: 0+ +0 TLS +GLOBAL DEFAULT UND sG2
+ +4: 0+ +0 TLS +GLOBAL DEFAULT UND sG4
+ +5: [0-9a-f]+ +0 FUNC +GLOBAL DEFAULT UND __tls_get_addr
+#...
+ +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT UND sG1
+#...
+
+Symbol table '\.symtab' contains [0-9]+ entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+ +0: 0+ +0 NOTYPE LOCAL DEFAULT UND *
+ +1: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +1 *
+ +2: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +2 *
+ +3: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +3 *
+ +4: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +4 *
+ +5: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +5 *
+ +6: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +6 *
+ +7: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +7 *
+ +8: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +8 *
+ +9: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +9 *
+ +10: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +10 *
+ +11: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +11 *
+ +12: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +12 *
+ +13: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +13 *
+ +14: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +14 *
+ +15: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +15 *
+ +16: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +16 *
+ +17: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +17 *
+ +18: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +18 *
+#...
+ +[0-9]+: 00000008 +0 TLS +LOCAL DEFAULT +10 sl1
+ +[0-9]+: 0000000c +0 TLS +LOCAL DEFAULT +10 sl2
+ +[0-9]+: 00000020 +0 TLS +LOCAL DEFAULT +11 bl1
+ +[0-9]+: 00000024 +0 TLS +LOCAL DEFAULT +11 bl2
+ +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT UND sG3
+ +[0-9]+: [0-9a-f]+ +0 OBJECT GLOBAL DEFAULT ABS _DYNAMIC
+ +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT UND sG2
+ +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT UND sG4
+ +[0-9]+: [0-9a-f]+ +0 FUNC +GLOBAL DEFAULT UND __tls_get_addr
+ +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT +10 sg1
+ +[0-9]+: 0+402000 +0 FUNC +GLOBAL DEFAULT +8 _start
+#...
+ +[0-9]+: 0+401000 +0 FUNC +GLOBAL DEFAULT +8 fn2
+#...
+ +[0-9]+: 00000004 +0 TLS +GLOBAL DEFAULT +10 sg2
+ +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT UND sG1
+ +[0-9]+: 00000010 +0 TLS +GLOBAL HIDDEN +10 sh1
+ +[0-9]+: 004130e0 +0 NOTYPE GLOBAL DEFAULT ABS _edata
+ +[0-9]+: [0-9a-f]+ +0 OBJECT GLOBAL DEFAULT ABS _GLOBAL_OFFSET_TABLE_
+ +[0-9]+: [0-9a-f]+ +0 NOTYPE GLOBAL DEFAULT ABS _end
+ +[0-9]+: 00000014 +0 TLS +GLOBAL HIDDEN +10 sh2
+ +[0-9]+: 0000001c +0 TLS +GLOBAL DEFAULT +11 bg2
+ +[0-9]+: 00000018 +0 TLS +GLOBAL DEFAULT +11 bg1
+ +[0-9]+: [0-9a-f]+ +0 NOTYPE GLOBAL DEFAULT +9 __data_start
+#pass
diff --git a/ld/testsuite/ld-sh/tlsbin-3.d b/ld/testsuite/ld-sh/tlsbin-3.d
new file mode 100644
index 0000000..59600d4
--- /dev/null
+++ b/ld/testsuite/ld-sh/tlsbin-3.d
@@ -0,0 +1,12 @@
+#source: tlsbinpic.s
+#source: tlsbin.s
+#as: -little
+#ld: -EL tmpdir/tlsbin-0-dso.so
+#objdump: -sj.got
+#target: sh*-*-linux* sh*-*-netbsd*
+
+.*: +file format elf32-sh.*
+
+Contents of section \.got:
+ 4130c0 [0-9a-f]+ 00000000 00000000 [0-9a-f]+ .*
+ 4130d0 00000000 00000000 00000000 00000000 .*
diff --git a/ld/testsuite/ld-sh/tlsbin-4.d b/ld/testsuite/ld-sh/tlsbin-4.d
new file mode 100644
index 0000000..25e0875
--- /dev/null
+++ b/ld/testsuite/ld-sh/tlsbin-4.d
@@ -0,0 +1,12 @@
+#source: tlsbinpic.s
+#source: tlsbin.s
+#as: -little
+#ld: -EL tmpdir/tlsbin-0-dso.so
+#objdump: -sj.tdata
+#target: sh*-*-linux* sh*-*-netbsd*
+
+.*: +file format elf32-sh.*
+
+Contents of section .tdata:
+ 413000 11000000 12000000 41000000 42000000 .*
+ 413010 01010000 02010000 +.*
diff --git a/ld/testsuite/ld-sh/tlsbin.s b/ld/testsuite/ld-sh/tlsbin.s
new file mode 100644
index 0000000..642eb3d
--- /dev/null
+++ b/ld/testsuite/ld-sh/tlsbin.s
@@ -0,0 +1,90 @@
+ .section ".tbss", "awT", @nobits
+ .globl bg1, bg2
+bg1: .space 4
+bg2: .space 4
+bl1: .space 4
+bl2: .space 4
+ .text
+ .globl _start
+ .type _start,@function
+_start:
+ mov.l r12,@-r15
+ mov.l r14,@-r15
+ mov r15,r14
+ ! Set up .GOT pointer for non-pic @gottpoff sequences
+ mova .L3,r0
+ mov.l .L3,r12
+ add r0,r12
+ nop;nop;nop;nop
+
+ ! @GOTTPOFF IE against global var
+ mov.l 1f,r0
+ stc gbr,r1
+ mov.l @(r0,r12),r0
+ bra 2f
+ add r0,r1
+ .align 2
+1: .long sG3@GOTTPOFF
+2:
+ nop;nop;nop;nop
+
+ ! @GOTTPOFF IE -> LE against global var defined in exec
+ mov.l 1f,r0
+ stc gbr,r1
+ mov.l @(r0,r12),r0
+ bra 2f
+ add r0,r1
+ .align 2
+1: .long bg1@GOTTPOFF
+2:
+ nop;nop;nop;nop
+
+ ! @GOTTPOFF IE -> LE against local var
+ mov.l 1f,r0
+ stc gbr,r1
+ mov.l @(r0,r12),r0
+ bra 2f
+ add r0,r1
+ .align 2
+1: .long bl2@GOTTPOFF
+2:
+ nop;nop;nop;nop
+
+ ! @GOTTPOFF IE -> LE against hidden but not local var
+ mov.l 1f,r0
+ stc gbr,r1
+ mov.l @(r0,r12),r0
+ bra 2f
+ add r0,r1
+ .align 2
+1: .long sh2@GOTTPOFF
+2:
+ nop;nop;nop;nop
+
+ ! LE @TPOFF, global var defined in exec
+ stc gbr,r1
+ mov.l .L4,r0
+ add r1,r0
+ nop;nop;nop;nop
+
+ ! LE @TPOFF, local var
+ stc gbr,r1
+ mov.l .L5,r0
+ add r1,r0
+ nop;nop;nop;nop
+
+ ! LE @TPOFF, hidden var defined in exec
+ stc gbr,r1
+ mov.l .L6,r0
+ add r1,r0
+ nop;nop;nop;nop
+
+ mov r14,r15
+ rts
+ mov.l @r15+,r14
+
+ .align 2
+.L3: .long _GLOBAL_OFFSET_TABLE_
+.L4: .long sg1@TPOFF
+.L5: .long bl1@TPOFF
+.L6: .long sh1@TPOFF
diff --git a/ld/testsuite/ld-sh/tlsbinpic.s b/ld/testsuite/ld-sh/tlsbinpic.s
new file mode 100644
index 0000000..cb8b361
--- /dev/null
+++ b/ld/testsuite/ld-sh/tlsbinpic.s
@@ -0,0 +1,206 @@
+ ! Force .got aligned to 4K, so it very likely gets at 0x413000
+ .data
+ .balign 4096
+ .section ".tdata", "awT", @progbits
+ .globl sg1, sg2
+ .globl sh1, sh2
+ .hidden sh1, sh2
+sg1: .long 17
+sg2: .long 18
+sl1: .long 65
+sl2: .long 66
+sh1: .long 257
+sh2: .long 258
+ ! Force .text aligned to 4K, so it very likely gets at 0x401000.
+ .text
+ .balign 4096
+ .globl fn2
+ .type fn2,@function
+fn2:
+ mov.l r12,@-r15
+ mov.l r14,@-r15
+ sts.l pr,@-r15
+ mova .L3,r0
+ mov.l .L3,r12
+ add r0,r12
+ mov r15,r14
+ nop;nop;nop;nop
+
+ ! GD -> IE because variable is not defined in executable
+ mov.l 1f,r4
+ mova 2f,r0
+ mov.l 2f,r1
+ add r0,r1
+ jsr @r1
+ add r12,r4
+ bra 3f
+ nop
+ .align 2
+1: .long sG1@TLSGD
+2: .long __tls_get_addr@PLT
+3:
+ nop;nop;nop;nop
+
+ ! GD -> IE because variable is not defined in executable where
+ ! the variable is referenced through @gottpoff too
+ mov.l 1f,r4
+ mova 2f,r0
+ mov.l 2f,r1
+ add r0,r1
+ jsr @r1
+ add r12,r4
+ bra 3f
+ nop
+ .align 2
+1: .long sG2@TLSGD
+2: .long __tls_get_addr@PLT
+3:
+ nop;nop;nop;nop
+
+ ! GD -> LE with global variable defined in executable
+ mov.l 1f,r4
+ mova 2f,r0
+ mov.l 2f,r1
+ add r0,r1
+ jsr @r1
+ add r12,r4
+ bra 3f
+ nop
+ .align 2
+1: .long sg1@TLSGD
+2: .long __tls_get_addr@PLT
+3:
+ nop;nop;nop;nop
+
+ ! GD -> LE with local variable defined in executable
+ mov.l 1f,r4
+ mova 2f,r0
+ mov.l 2f,r1
+ add r0,r1
+ jsr @r1
+ add r12,r4
+ bra 3f
+ nop
+ .align 2
+1: .long sl1@TLSGD
+2: .long __tls_get_addr@PLT
+3:
+ nop;nop;nop;nop
+
+ ! GD -> LE with hidden variable defined in executable
+ mov.l 1f,r4
+ mova 2f,r0
+ mov.l 2f,r1
+ add r0,r1
+ jsr @r1
+ add r12,r4
+ bra 3f
+ nop
+ .align 2
+1: .long sh1@TLSGD
+2: .long __tls_get_addr@PLT
+3:
+ nop;nop;nop;nop
+
+ ! LD -> LE with local variable defined in executable
+ mov.l 1f,r4
+ mova 2f,r0
+ mov.l 2f,r1
+ add r0,r1
+ jsr @r1
+ add r12,r4
+ bra 3f
+ nop
+ .align 2
+1: .long sl1@TLSLDM
+2: .long __tls_get_addr@PLT
+3:
+ nop;nop
+ mov.l .L4,r1
+ add r0,r1
+ nop;nop
+ mov.l .L5,r2
+ add r0,r2
+ nop;nop;nop;nop
+
+ ! LD -> LE against hidden variables
+ mov.l 1f,r4
+ mova 2f,r0
+ mov.l 2f,r1
+ add r0,r1
+ jsr @r1
+ add r12,r4
+ bra 3f
+ nop
+ .align 2
+1: .long sh1@TLSLDM
+2: .long __tls_get_addr@PLT
+3:
+ nop;nop
+ mov.l .L6,r1
+ add r0,r1
+ nop;nop
+ mov.l .L7,r2
+ add r0,r2
+ nop;nop;nop;nop
+
+ ! @GOTTPOFF IE against global var
+ mov.l 1f,r0
+ stc gbr,r1
+ mov.l @(r0,r12),r0
+ bra 2f
+ add r0,r1
+ .align 2
+1: .long sG2@GOTTPOFF
+2:
+ nop;nop;nop;nop
+
+ ! @GOTTPOFF IE against global var
+ mov.l 1f,r0
+ stc gbr,r1
+ mov.l @(r0,r12),r0
+ bra 2f
+ add r1,r0
+ .align 2
+1: .long sG4@GOTTPOFF
+2:
+ nop;nop;nop;nop
+
+ ! @GOTTPOFF IE -> LE against global var defined in exec
+ mov.l 1f,r0
+ stc gbr,r1
+ mov.l @(r0,r12),r0
+ bra 2f
+ add r0,r1
+ .align 2
+1: .long sg1@GOTTPOFF
+2:
+ nop;nop;nop;nop
+
+ ! @GOTTPOFF IE -> LE against hidden var
+ mov.l 1f,r0
+ stc gbr,r1
+ mov.l @(r0,r12),r0
+ bra 2f
+ add r0,r1
+ .align 2
+1: .long sh1@GOTTPOFF
+2:
+ nop;nop;nop;nop
+
+ mov r14,r15
+ lds.l @r15+,pr
+ mov.l @r15+,r14
+ rts
+ mov.l @r15+,r12
+
+ .align 2
+.L3: .long _GLOBAL_OFFSET_TABLE_
+.L4: .long sl1@DTPOFF
+.L5: .long sl2@DTPOFF
+.L6: .long sh1@DTPOFF
+.L7: .long sh2@DTPOFF
+ ! Fill page with 0.
+ .space .L8-.
+ .balign 4096
+.L8:
diff --git a/ld/testsuite/ld-sh/tlslib.s b/ld/testsuite/ld-sh/tlslib.s
new file mode 100644
index 0000000..35b6c70
--- /dev/null
+++ b/ld/testsuite/ld-sh/tlslib.s
@@ -0,0 +1,20 @@
+ .section ".tdata", "awT", @progbits
+ .globl sG1, sG2, sG3, sG4, sG5, sG6, sG7, sG8
+sG1: .long 513
+sG2: .long 514
+sG3: .long 515
+sG4: .long 516
+sG5: .long 517
+sG6: .long 518
+sG7: .long 519
+sG8: .long 520
+
+ .text
+ .align 1
+ ! Dummy.
+ .globl __tls_get_addr
+ .type __tls_get_addr,@function
+__tls_get_addr:
+ rts
+ nop
+
diff --git a/ld/testsuite/ld-sh/tlspic-1.d b/ld/testsuite/ld-sh/tlspic-1.d
new file mode 100644
index 0000000..decb161
--- /dev/null
+++ b/ld/testsuite/ld-sh/tlspic-1.d
@@ -0,0 +1,292 @@
+#source: tlspic1.s
+#source: tlspic2.s
+#as: -little
+#ld: -shared -EL
+#objdump: -drj.text
+#target: sh*-*-linux* sh*-*-netbsd*
+
+.*: +file format elf32-sh.*
+
+Disassembly of section \.text:
+
+[0-9a-f]+ <fn1>:
+ [0-9a-f]+: c6 2f mov\.l r12,@-r15
+ [0-9a-f]+: e6 2f mov\.l r14,@-r15
+ [0-9a-f]+: 22 4f sts\.l pr,@-r15
+ [0-9a-f]+: 83 c7 mova [0-9a-f]+ <fn1\+0x214>,r0
+ [0-9a-f]+: 82 dc mov\.l [0-9a-f]+ <fn1\+0x214>,r12 ! 0x[0-9a-f]+
+ [0-9a-f]+: 0c 3c add r0,r12
+ [0-9a-f]+: f3 6e mov r15,r14
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 04 d4 mov\.l [0-9a-f]+ <fn1\+0x28>,r4 ! 0x30
+ [0-9a-f]+: 04 c7 mova [0-9a-f]+ <fn1\+0x2c>,r0
+ [0-9a-f]+: 04 d1 mov\.l [0-9a-f]+ <fn1\+0x2c>,r1 ! 0x[0-9a-f]+
+ [0-9a-f]+: 0c 31 add r0,r1
+ [0-9a-f]+: 0b 41 jsr @r1
+ [0-9a-f]+: cc 34 add r12,r4
+ [0-9a-f]+: 05 a0 bra [0-9a-f]+ <fn1\+0x30>
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 30 00 .*[ ]*.*
+ [0-9a-f]+: 00 00 .*[ ]*.*
+ [0-9a-f]+: [0-9a-f]+ [0-9a-f]+ .*[ ]*.*
+ [0-9a-f]+: [0-9a-f]+ [0-9a-f]+ .*[ ]*.*
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 09 00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c 31 add r0,r1
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 18 00 .*[ ]*.*
+ [0-9a-f]+: 00 00 .*[ ]*.*
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 02 d0 mov\.l [0-9a-f]+ <fn1\+0x1e4>,r0 ! 0x44
+ [0-9a-f]+: 12 01 stc gbr,r1
+ [0-9a-f]+: ce 00 mov\.l @\(r0,r12\),r0
+ [0-9a-f]+: 03 a0 bra [0-9a-f]+ <fn1\+0x1e8>
+ [0-9a-f]+: 0c 31 add r0,r1
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 44 00 .*[ ]*.*
+ [0-9a-f]+: 00 00 .*[ ]*.*
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 02 d0 mov\.l [0-9a-f]+ <fn1\+0x1fc>,r0 ! 0x2c
+ [0-9a-f]+: 12 01 stc gbr,r1
+ [0-9a-f]+: ce 00 mov\.l @\(r0,r12\),r0
+ [0-9a-f]+: 03 a0 bra [0-9a-f]+ <fn1\+0x200>
+ [0-9a-f]+: 0c 31 add r0,r1
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 2c 00 .*[ ]*.*
+ [0-9a-f]+: 00 00 .*[ ]*.*
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: e3 6f mov r14,r15
+ [0-9a-f]+: 26 4f lds\.l @r15\+,pr
+ [0-9a-f]+: f6 6e mov\.l @r15\+,r14
+ [0-9a-f]+: 0b 00 rts
+ [0-9a-f]+: f6 6c mov\.l @r15\+,r12
+ [0-9a-f]+: 09 00 nop
+ [0-9a-f]+: cc 00 .*[ ]*.*
+ [0-9a-f]+: 01 00 .*[ ]*.*
+ [0-9a-f]+: 08 00 .*[ ]*.*
+ [0-9a-f]+: 00 00 .*[ ]*.*
+ [0-9a-f]+: 0c 00 .*[ ]*.*
+ [0-9a-f]+: 00 00 .*[ ]*.*
+ [0-9a-f]+: 10 00 .*[ ]*.*
+ [0-9a-f]+: 00 00 .*[ ]*.*
+ [0-9a-f]+: 14 00 .*[ ]*.*
+ [0-9a-f]+: 00 00 .*[ ]*.*
+ [0-9a-f]+: 18 00 .*[ ]*.*
+ [0-9a-f]+: 00 00 .*[ ]*.*
+ [0-9a-f]+: 1c 00 .*[ ]*.*
+ \.\.\.
diff --git a/ld/testsuite/ld-sh/tlspic-2.d b/ld/testsuite/ld-sh/tlspic-2.d
new file mode 100644
index 0000000..66199e0
--- /dev/null
+++ b/ld/testsuite/ld-sh/tlspic-2.d
@@ -0,0 +1,132 @@
+#source: tlspic1.s
+#source: tlspic2.s
+#as: -little
+#ld: -shared -EL
+#readelf: -Ssrl
+#target: sh*-*-linux* sh*-*-netbsd*
+
+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\] +NULL +0+ 0+ 0+ 0+ +0 +0 +0
+ \[ 1\] \.hash +.*
+ \[ 2\] \.dynsym +.*
+ \[ 3\] \.dynstr +.*
+ \[ 4\] \.rela\.dyn +.*
+ \[ 5\] \.rela\.plt +.*
+ \[ 6\] \.plt +.*
+ \[ 7\] \.text +PROGBITS +0+[0-9a-f]+ .*
+ \[ 8\] \.data +.*
+ \[ 9\] \.tdata +PROGBITS +0+[0-9a-f]+ [0-9a-f]+ 0+018 00 WAT 0 0 1
+ \[10\] \.tbss +NOBITS +0+[0-9a-f]+ [0-9a-f]+ 0+008 00 WAT 0 0 1
+ \[11\] \.dynamic +DYNAMIC +0+[0-9a-f]+ .*
+#...
+ \[[0-9a-f]+\] \.got +PROGBITS +0+[0-9a-f]+ .*
+ \[[0-9a-f]+\] \.sbss +.*
+ \[[0-9a-f]+\] \.bss +.*
+#...
+ \[[0-9a-f]+\] \.shstrtab +.*
+ \[[0-9a-f]+\] \.symtab +.*
+ \[[0-9a-f]+\] \.strtab +.*
+Key to Flags:
+.*
+.*
+.*
+
+Elf file type is DYN \(Shared object file\)
+Entry point 0x[0-9a-f]+
+There are 4 program headers, starting at offset [0-9]+
+
+Program Headers:
+ Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align
+ LOAD.*
+ LOAD.*
+ DYNAMIC.*
+ TLS +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+18 0x0+20 R +0x1
+
+ Section to Segment mapping:
+ Segment Sections\.\.\.
+ 00 +\.hash \.dynsym \.dynstr \.rela\.dyn \.rela\.plt \.plt \.text *
+ 01 +\.tdata \.tbss \.dynamic \.got *
+ 02 +\.tbss \.dynamic *
+ 03 +\.tdata \.tbss *
+
+Relocation section '\.rela\.dyn' at offset 0x[0-9a-f]+ contains 10 entries:
+ Offset +Info +Type +Sym\.Value +Sym\. Name \+ Addend
+0+[0-9a-f]+ 00000095 R_SH_TLS_DTPMOD32 +0+00
+0+[0-9a-f]+ 00000097 R_SH_TLS_TPOFF32 +0+0c
+0+[0-9a-f]+ 00000095 R_SH_TLS_DTPMOD32 +0+00
+0+[0-9a-f]+ 00000095 R_SH_TLS_DTPMOD32 +0+00
+0+[0-9a-f]+ 00000097 R_SH_TLS_TPOFF32 +0+1c
+0+[0-9a-f]+ 00000095 R_SH_TLS_DTPMOD32 +0+00
+0+[0-9a-f]+ 00000097 R_SH_TLS_TPOFF32 +0+14
+0+[0-9a-f]+ 0000[0-9a-f]+95 R_SH_TLS_DTPMOD32 +0+ +sg1 \+ 0
+0+[0-9a-f]+ 0000[0-9a-f]+96 R_SH_TLS_DTPOFF32 +0+ +sg1 \+ 0
+0+[0-9a-f]+ 0000[0-9a-f]+97 R_SH_TLS_TPOFF32 +0+04 +sg2 \+ 0
+
+Relocation section '\.rela\.plt' at offset 0x[0-9a-f]+ contains 1 entries:
+ Offset +Info +Type +Sym\.Value +Sym\. Name \+ Addend
+0+[0-9a-f]+ 0000[0-9a-f]+a4 R_SH_JMP_SLOT +[0-9a-f]+ +__tls_get_addr \+ 0
+
+Symbol table '\.dynsym' contains [0-9]+ entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+ +0: 0+ +0 NOTYPE +LOCAL +DEFAULT UND *
+ +1: [0-9a-f]+ +0 SECTION LOCAL DEFAULT 1 *
+ +2: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +2 *
+ +3: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +3 *
+ +4: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +4 *
+ +5: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +5 *
+ +6: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +6 *
+ +7: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +7 *
+ +8: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +8 *
+ +9: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +9 *
+ +10: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +10 *
+ +11: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +11 *
+ +12: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +12 *
+ +13: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +13 *
+ +14: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +14 *
+#...
+ +[0-9a-f]+: [0-9a-f]+ +0 NOTYPE GLOBAL DEFAULT UND __tls_get_addr
+ +[0-9a-f]+: 0+00 +0 TLS +GLOBAL DEFAULT +9 sg1
+#...
+ +[0-9a-f]+: [0-9a-f]+ +0 FUNC +GLOBAL DEFAULT +7 fn1
+#...
+ +[0-9a-f]+: 0+04 +0 TLS +GLOBAL DEFAULT +9 sg2
+#...
+
+Symbol table '\.symtab' contains [0-9]+ entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+ +0: 0+ +0 NOTYPE LOCAL DEFAULT UND *
+ +1: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +1 *
+ +2: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +2 *
+ +3: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +3 *
+ +4: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +4 *
+ +5: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +5 *
+ +6: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +6 *
+ +7: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +7 *
+ +8: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +8 *
+ +9: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +9 *
+ +10: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +10 *
+ +11: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +11 *
+ +12: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +12 *
+ +13: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +13 *
+ +14: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +14 *
+ +15: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +15 *
+ +16: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +16 *
+ +17: [0-9a-f]+ +0 SECTION LOCAL DEFAULT +17 *
+#...
+ +[0-9]+: 0+08 +0 TLS +LOCAL DEFAULT +9 sl1
+ +[0-9]+: 0+0c +0 TLS +LOCAL DEFAULT +9 sl2
+ +[0-9]+: 0+18 +0 TLS +LOCAL HIDDEN +10 sH1
+ +[0-9]+: 0+1c +0 TLS +LOCAL HIDDEN +10 sH2
+ +[0-9]+: 0+10 +0 TLS +LOCAL HIDDEN +9 sh1
+ +[0-9]+: 0+14 +0 TLS +LOCAL HIDDEN +9 sh2
+#...
+ +[0-9]+: [0-9a-f]+ +0 NOTYPE GLOBAL DEFAULT UND __tls_get_addr
+ +[0-9]+: 0+00 +0 TLS +GLOBAL DEFAULT +9 sg1
+#...
+ +[0-9]+: [0-9a-f]+ +0 FUNC GLOBAL DEFAULT +7 fn1
+#...
+ +[0-9]+: 0+04 +0 TLS +GLOBAL DEFAULT +9 sg2
+#pass
diff --git a/ld/testsuite/ld-sh/tlspic-3.d b/ld/testsuite/ld-sh/tlspic-3.d
new file mode 100644
index 0000000..6e79989
--- /dev/null
+++ b/ld/testsuite/ld-sh/tlspic-3.d
@@ -0,0 +1,15 @@
+#source: tlspic1.s
+#source: tlspic2.s
+#as: -little
+#ld: -shared -EL
+#objdump: -sj.got
+#target: sh*-*-linux* sh*-*-netbsd*
+
+.*: +file format elf32-sh.*
+
+Contents of section \.got:
+ [0-9a-f]+ [0-9a-f]+ 00000000 00000000 [0-9a-f]+ .*
+ [0-9a-f]+ 00000000 08000000 00000000 00000000 .*
+ [0-9a-f]+ 00000000 00000000 18000000 00000000 .*
+ [0-9a-f]+ 00000000 00000000 00000000 00000000 .*
+ [0-9a-f]+ 10000000 00000000 +.*
diff --git a/ld/testsuite/ld-sh/tlspic-4.d b/ld/testsuite/ld-sh/tlspic-4.d
new file mode 100644
index 0000000..263c5d6
--- /dev/null
+++ b/ld/testsuite/ld-sh/tlspic-4.d
@@ -0,0 +1,12 @@
+#source: tlspic1.s
+#source: tlspic2.s
+#as: -little
+#ld: -shared -EL
+#objdump: -sj.tdata
+#target: sh*-*-linux* sh*-*-netbsd*
+
+.*: +file format elf32-sh.*
+
+Contents of section \.tdata:
+ [0-9a-f]+ 11000000 12000000 41000000 42000000 .*
+ [0-9a-f]+ 01010000 02010000 +.*
diff --git a/ld/testsuite/ld-sh/tlspic1.s b/ld/testsuite/ld-sh/tlspic1.s
new file mode 100644
index 0000000..153709a
--- /dev/null
+++ b/ld/testsuite/ld-sh/tlspic1.s
@@ -0,0 +1,267 @@
+ .section ".tdata", "awT", @progbits
+ .globl sg1, sg2
+ .globl sh1, sh2
+ .hidden sh1, sh2
+sg1: .long 17
+sg2: .long 18
+sl1: .long 65
+sl2: .long 66
+sh1: .long 257
+sh2: .long 258
+ .text
+ .align 1
+ .globl fn1
+ .type fn1,@function
+fn1:
+ mov.l r12,@-r15
+ mov.l r14,@-r15
+ sts.l pr,@-r15
+ mova .L3,r0
+ mov.l .L3,r12
+ add r0,r12
+ mov r15,r14
+ nop;nop;nop;nop
+
+ ! GD
+ mov.l 1f,r4
+ mova 2f,r0
+ mov.l 2f,r1
+ add r0,r1
+ jsr @r1
+ add r12,r4
+ bra 3f
+ nop
+ .align 2
+1: .long sg1@TLSGD
+2: .long __tls_get_addr@PLT
+3:
+ nop;nop;nop;nop
+
+ ! GD -> IE because variable is referenced through @GOTTPOFF too
+ mov.l 1f,r4
+ mova 2f,r0
+ mov.l 2f,r1
+ add r0,r1
+ jsr @r1
+ add r12,r4
+ bra 3f
+ nop
+ .align 2
+1: .long sg2@TLSGD
+2: .long __tls_get_addr@PLT
+3:
+ nop;nop;nop;nop
+
+ ! GD against local variable
+ mov.l 1f,r4
+ mova 2f,r0
+ mov.l 2f,r1
+ add r0,r1
+ jsr @r1
+ add r12,r4
+ bra 3f
+ nop
+ .align 2
+1: .long sl1@TLSGD
+2: .long __tls_get_addr@PLT
+3:
+ nop;nop;nop;nop
+
+ ! GD -> IE against local variable referenced through @GOTTPOFF too
+ mov.l 1f,r4
+ mova 2f,r0
+ mov.l 2f,r1
+ add r0,r1
+ jsr @r1
+ add r12,r4
+ bra 3f
+ nop
+ .align 2
+1: .long sl2@TLSGD
+2: .long __tls_get_addr@PLT
+3:
+ nop;nop;nop;nop
+
+ ! GD against hidden and local variable
+ mov.l 1f,r4
+ mova 2f,r0
+ mov.l 2f,r1
+ add r0,r1
+ jsr @r1
+ add r12,r4
+ bra 3f
+ nop
+ .align 2
+1: .long sh1@TLSGD
+2: .long __tls_get_addr@PLT
+3:
+ nop;nop;nop;nop
+
+ ! GD -> IE against hidden and local variable referenced through
+ ! @GOTTPOFF too
+ mov.l 1f,r4
+ mova 2f,r0
+ mov.l 2f,r1
+ add r0,r1
+ jsr @r1
+ add r12,r4
+ bra 3f
+ nop
+ .align 2
+1: .long sh2@TLSGD
+2: .long __tls_get_addr@PLT
+3:
+ nop;nop;nop;nop
+
+ ! GD against hidden but not local variable
+ mov.l 1f,r4
+ mova 2f,r0
+ mov.l 2f,r1
+ add r0,r1
+ jsr @r1
+ add r12,r4
+ bra 3f
+ nop
+ .align 2
+1: .long sH1@TLSGD
+2: .long __tls_get_addr@PLT
+3:
+ nop;nop;nop;nop
+
+ ! GD -> IE against hidden but not local variable referenced through
+ ! @GOTTPOFF too
+ mov.l 1f,r4
+ mova 2f,r0
+ mov.l 2f,r1
+ add r0,r1
+ jsr @r1
+ add r12,r4
+ bra 3f
+ nop
+ .align 2
+1: .long sH2@TLSGD
+2: .long __tls_get_addr@PLT
+3:
+ nop;nop;nop;nop
+
+ ! LD
+ mov.l 1f,r4
+ mova 2f,r0
+ mov.l 2f,r1
+ add r0,r1
+ jsr @r1
+ add r12,r4
+ bra 3f
+ nop
+ .align 2
+1: .long sl1@TLSLDM
+2: .long __tls_get_addr@PLT
+3:
+ nop;nop
+ mov.l .L4,r1
+ add r0,r1
+ nop;nop
+ mov.l .L5,r2
+ add r0,r2
+ nop;nop;nop;nop
+
+ ! LD against hidden and local variables
+ mov.l 1f,r4
+ mova 2f,r0
+ mov.l 2f,r1
+ add r0,r1
+ jsr @r1
+ add r12,r4
+ bra 3f
+ nop
+ .align 2
+1: .long sl1@TLSLDM
+2: .long __tls_get_addr@PLT
+3:
+ nop;nop
+ mov.l .L6,r1
+ add r0,r1
+ nop;nop
+ mov.l .L7,r2
+ add r0,r2
+ nop;nop;nop;nop
+
+ ! LD against hidden but not local variables
+ mov.l 1f,r4
+ mova 2f,r0
+ mov.l 2f,r1
+ add r0,r1
+ jsr @r1
+ add r12,r4
+ bra 3f
+ nop
+ .align 2
+1: .long sH1@TLSLDM
+2: .long __tls_get_addr@PLT
+3:
+ nop;nop
+ mov.l .L8,r1
+ add r0,r1
+ nop;nop
+ mov.l .L9,r2
+ add r0,r2
+ nop;nop;nop;nop
+
+ ! @GOTTPOFF IE against global var
+ mov.l 1f,r0
+ stc gbr,r1
+ mov.l @(r0,r12),r0
+ bra 2f
+ add r0,r1
+ .align 2
+1: .long sg2@GOTTPOFF
+2:
+ nop;nop;nop;nop
+
+ ! @GOTTPOFF IE against local var
+ mov.l 1f,r0
+ stc gbr,r1
+ mov.l @(r0,r12),r0
+ bra 2f
+ add r0,r1
+ .align 2
+1: .long sl2@GOTTPOFF
+2:
+ nop;nop;nop;nop
+
+ ! @GOTTPOFF IE against hidden and local var
+ mov.l 1f,r0
+ stc gbr,r1
+ mov.l @(r0,r12),r0
+ bra 2f
+ add r0,r1
+ .align 2
+1: .long sh2@GOTTPOFF
+2:
+ nop;nop;nop;nop
+
+ ! @GOTTPOFF IE against hidden but not local var
+ mov.l 1f,r0
+ stc gbr,r1
+ mov.l @(r0,r12),r0
+ bra 2f
+ add r0,r1
+ .align 2
+1: .long sH2@GOTTPOFF
+2:
+ nop;nop;nop;nop
+
+ mov r14,r15
+ lds.l @r15+,pr
+ mov.l @r15+,r14
+ rts
+ mov.l @r15+,r12
+
+ .align 2
+.L3: .long _GLOBAL_OFFSET_TABLE_
+.L4: .long sl1@DTPOFF
+.L5: .long sl1@DTPOFF + 4
+.L6: .long sh1@DTPOFF
+.L7: .long sh2@DTPOFF
+.L8: .long sH1@DTPOFF
+.L9: .long sH2@DTPOFF
diff --git a/ld/testsuite/ld-sh/tlspic2.s b/ld/testsuite/ld-sh/tlspic2.s
new file mode 100644
index 0000000..35319ba
--- /dev/null
+++ b/ld/testsuite/ld-sh/tlspic2.s
@@ -0,0 +1,5 @@
+ .section ".tbss", "awT", @nobits
+ .globl sH1, sH2
+ .hidden sH1, sH2
+sH1: .space 4
+sH2: .space 4