summaryrefslogtreecommitdiff
path: root/ld/testsuite/ld-cris
diff options
context:
space:
mode:
authorHans-Peter Nilsson <hp@axis.com>2008-11-25 04:10:48 +0000
committerHans-Peter Nilsson <hp@axis.com>2008-11-25 04:10:48 +0000
commit8e9d9b02168bde16b22793d4ea17bc0288708dc0 (patch)
tree581a82a40056736bcd888eee1996f41e5553f7b9 /ld/testsuite/ld-cris
parente1a261a1643ac622213ef67790474f121c0c8ffc (diff)
downloadbinutils-redhat-8e9d9b02168bde16b22793d4ea17bc0288708dc0.tar.gz
* ld-cris/got7.s, ld-cris/init.s, ld-cris/pic-gc-72.d,
ld-cris/pic-gc-72.s, ld-cris/pic-gc-73.d, ld-cris/pic-gc-73.s, ld-cris/tls-dso-x1x2-1.d, ld-cris/tls-dso-xz-1.d, ld-cris/tls-dtprelm.s, ld-cris/tls-e-20.d, ld-cris/tls-e-20a.d, ld-cris/tls-e-21.d, ld-cris/tls-e-22.d, ld-cris/tls-e-23.d, ld-cris/tls-e-66.d, ld-cris/tls-err-20x.d, ld-cris/tls-err-24.d, ld-cris/tls-err-25.d, ld-cris/tls-err-26.d, ld-cris/tls-err-27.d, ld-cris/tls-err-28.d, ld-cris/tls-err-29.d, ld-cris/tls-err-31.d, ld-cris/tls-err-33.d, ld-cris/tls-err-35.d, ld-cris/tls-err-37.d, ld-cris/tls-err-39.d, ld-cris/tls-err-40.d, ld-cris/tls-err-41.d, ld-cris/tls-err-43.d, ld-cris/tls-err-44.d, ld-cris/tls-err-45.d, ld-cris/tls-err-47.d, ld-cris/tls-err-48.d, ld-cris/tls-err-49.d, ld-cris/tls-err-51.d, ld-cris/tls-err-52.d, ld-cris/tls-err-53.d, ld-cris/tls-err-55.d, ld-cris/tls-err-55.s, ld-cris/tls-err-56.d, ld-cris/tls-err-56.s, ld-cris/tls-err-62.d, ld-cris/tls-err-62.s, ld-cris/tls-err-65.d, ld-cris/tls-err-67.d, ld-cris/tls-gc-68.d, ld-cris/tls-gc-69.d, ld-cris/tls-gc-70.d, ld-cris/tls-gc-71.d, ld-cris/tls-gc-71.s, ld-cris/tls-gc-75.d, ld-cris/tls-gc-76.d, ld-cris/tls-gc-76.s, ld-cris/tls-gd-1.d, ld-cris/tls-gd-1.s, ld-cris/tls-gd-1h.d, ld-cris/tls-gd-2.d, ld-cris/tls-gd-2.s, ld-cris/tls-gd-2h.d, ld-cris/tls-gd-3.d, ld-cris/tls-gd-3.s, ld-cris/tls-gd-3h.d, ld-cris/tls-gdgotrelm.s, ld-cris/tls-global-74.d, ld-cris/tls-gottprelm.s, ld-cris/tls-hx.s, ld-cris/tls-hx1x2.s, ld-cris/tls-ie-10.d, ld-cris/tls-ie-10.s, ld-cris/tls-ie-11.d, ld-cris/tls-ie-11.s, ld-cris/tls-ie-8.d, ld-cris/tls-ie-8.s, ld-cris/tls-ie-9.d, ld-cris/tls-ie-9.s, ld-cris/tls-ld-4.d, ld-cris/tls-ld-4.s, ld-cris/tls-ld-5.d, ld-cris/tls-ld-5.s, ld-cris/tls-ld-6.d, ld-cris/tls-ld-6.s, ld-cris/tls-ld-7.d, ld-cris/tls-ld-7.s, ld-cris/tls-ldgd-14.d, ld-cris/tls-ldgd-14.s, ld-cris/tls-ldgd-15.d, ld-cris/tls-ldgd-15.s, ld-cris/tls-ldgde-14.d, ld-cris/tls-ldgde-15.d, ld-cris/tls-ldgdex-14.d, ld-cris/tls-ldgdex-15.d, ld-cris/tls-ldgdx-14.d, ld-cris/tls-ldgdx-15.d, ld-cris/tls-le-12.d, ld-cris/tls-le-12.s, ld-cris/tls-le-12s.d, ld-cris/tls-le-12s.s, ld-cris/tls-le-13.d, ld-cris/tls-le-13.s, ld-cris/tls-le-13s.d, ld-cris/tls-le-13s.s, ld-cris/tls-legd-16.d, ld-cris/tls-legd-16.s, ld-cris/tls-legd-17.d, ld-cris/tls-legdx-16.d, ld-cris/tls-legdx-17.d, ld-cris/tls-leie-18.d, ld-cris/tls-leie-19.d, ld-cris/tls-leie-19.s, ld-cris/tls-local-54.d, ld-cris/tls-local-54.s, ld-cris/tls-local-57.d, ld-cris/tls-local-57.s, ld-cris/tls-local-58.d, ld-cris/tls-local-58.s, ld-cris/tls-local-59.d, ld-cris/tls-local-59.s, ld-cris/tls-local-60.d, ld-cris/tls-local-61.d, ld-cris/tls-local-63.d, ld-cris/tls-local-64.d, ld-cris/tls-ok-30.d, ld-cris/tls-ok-32.d, ld-cris/tls-ok-34.d, ld-cris/tls-ok-36.d, ld-cris/tls-tprelm.s, ld-cris/tls-und-38.d, ld-cris/tls-und-42.d, ld-cris/tls-und-46.d, ld-cris/tls-und-50.d, ld-cris/tls-x.s, ld-cris/tls-x1x2.s, ld-cris/tls-z.s, ld-cris/tls128.s, ld-cris/tls128g.s: New tests.
Diffstat (limited to 'ld/testsuite/ld-cris')
-rw-r--r--ld/testsuite/ld-cris/got7.s21
-rw-r--r--ld/testsuite/ld-cris/init.s6
-rw-r--r--ld/testsuite/ld-cris/pic-gc-72.d28
-rw-r--r--ld/testsuite/ld-cris/pic-gc-72.s3
-rw-r--r--ld/testsuite/ld-cris/pic-gc-73.d26
-rw-r--r--ld/testsuite/ld-cris/pic-gc-73.s5
-rw-r--r--ld/testsuite/ld-cris/tls-dso-x1x2-1.d16
-rw-r--r--ld/testsuite/ld-cris/tls-dso-xz-1.d18
-rw-r--r--ld/testsuite/ld-cris/tls-dtprelm.s26
-rw-r--r--ld/testsuite/ld-cris/tls-e-20.d71
-rw-r--r--ld/testsuite/ld-cris/tls-e-20a.d110
-rw-r--r--ld/testsuite/ld-cris/tls-e-21.d39
-rw-r--r--ld/testsuite/ld-cris/tls-e-22.d39
-rw-r--r--ld/testsuite/ld-cris/tls-e-23.d38
-rw-r--r--ld/testsuite/ld-cris/tls-e-66.d37
-rw-r--r--ld/testsuite/ld-cris/tls-err-20x.d11
-rw-r--r--ld/testsuite/ld-cris/tls-err-24.d7
-rw-r--r--ld/testsuite/ld-cris/tls-err-25.d7
-rw-r--r--ld/testsuite/ld-cris/tls-err-26.d8
-rw-r--r--ld/testsuite/ld-cris/tls-err-27.d8
-rw-r--r--ld/testsuite/ld-cris/tls-err-28.d7
-rw-r--r--ld/testsuite/ld-cris/tls-err-29.d7
-rw-r--r--ld/testsuite/ld-cris/tls-err-31.d6
-rw-r--r--ld/testsuite/ld-cris/tls-err-33.d6
-rw-r--r--ld/testsuite/ld-cris/tls-err-35.d7
-rw-r--r--ld/testsuite/ld-cris/tls-err-37.d7
-rw-r--r--ld/testsuite/ld-cris/tls-err-39.d7
-rw-r--r--ld/testsuite/ld-cris/tls-err-40.d6
-rw-r--r--ld/testsuite/ld-cris/tls-err-41.d7
-rw-r--r--ld/testsuite/ld-cris/tls-err-43.d7
-rw-r--r--ld/testsuite/ld-cris/tls-err-44.d8
-rw-r--r--ld/testsuite/ld-cris/tls-err-45.d7
-rw-r--r--ld/testsuite/ld-cris/tls-err-47.d7
-rw-r--r--ld/testsuite/ld-cris/tls-err-48.d6
-rw-r--r--ld/testsuite/ld-cris/tls-err-49.d7
-rw-r--r--ld/testsuite/ld-cris/tls-err-51.d7
-rw-r--r--ld/testsuite/ld-cris/tls-err-52.d8
-rw-r--r--ld/testsuite/ld-cris/tls-err-53.d7
-rw-r--r--ld/testsuite/ld-cris/tls-err-55.d6
-rw-r--r--ld/testsuite/ld-cris/tls-err-55.s8
-rw-r--r--ld/testsuite/ld-cris/tls-err-56.d7
-rw-r--r--ld/testsuite/ld-cris/tls-err-56.s9
-rw-r--r--ld/testsuite/ld-cris/tls-err-62.d7
-rw-r--r--ld/testsuite/ld-cris/tls-err-62.s9
-rw-r--r--ld/testsuite/ld-cris/tls-err-65.d7
-rw-r--r--ld/testsuite/ld-cris/tls-err-67.d9
-rw-r--r--ld/testsuite/ld-cris/tls-gc-68.d33
-rw-r--r--ld/testsuite/ld-cris/tls-gc-69.d34
-rw-r--r--ld/testsuite/ld-cris/tls-gc-70.d34
-rw-r--r--ld/testsuite/ld-cris/tls-gc-71.d32
-rw-r--r--ld/testsuite/ld-cris/tls-gc-71.s2
-rw-r--r--ld/testsuite/ld-cris/tls-gc-75.d36
-rw-r--r--ld/testsuite/ld-cris/tls-gc-76.d38
-rw-r--r--ld/testsuite/ld-cris/tls-gc-76.s23
-rw-r--r--ld/testsuite/ld-cris/tls-gd-1.d54
-rw-r--r--ld/testsuite/ld-cris/tls-gd-1.s8
-rw-r--r--ld/testsuite/ld-cris/tls-gd-1h.d50
-rw-r--r--ld/testsuite/ld-cris/tls-gd-2.d54
-rw-r--r--ld/testsuite/ld-cris/tls-gd-2.s9
-rw-r--r--ld/testsuite/ld-cris/tls-gd-2h.d50
-rw-r--r--ld/testsuite/ld-cris/tls-gd-3.d39
-rw-r--r--ld/testsuite/ld-cris/tls-gd-3.s8
-rw-r--r--ld/testsuite/ld-cris/tls-gd-3h.d39
-rw-r--r--ld/testsuite/ld-cris/tls-gdgotrelm.s28
-rw-r--r--ld/testsuite/ld-cris/tls-global-74.d28
-rw-r--r--ld/testsuite/ld-cris/tls-gottprelm.s28
-rw-r--r--ld/testsuite/ld-cris/tls-hx.s8
-rw-r--r--ld/testsuite/ld-cris/tls-hx1x2.s15
-rw-r--r--ld/testsuite/ld-cris/tls-ie-10.d54
-rw-r--r--ld/testsuite/ld-cris/tls-ie-10.s8
-rw-r--r--ld/testsuite/ld-cris/tls-ie-11.d60
-rw-r--r--ld/testsuite/ld-cris/tls-ie-11.s9
-rw-r--r--ld/testsuite/ld-cris/tls-ie-8.d54
-rw-r--r--ld/testsuite/ld-cris/tls-ie-8.s8
-rw-r--r--ld/testsuite/ld-cris/tls-ie-9.d60
-rw-r--r--ld/testsuite/ld-cris/tls-ie-9.s9
-rw-r--r--ld/testsuite/ld-cris/tls-ld-4.d50
-rw-r--r--ld/testsuite/ld-cris/tls-ld-4.s8
-rw-r--r--ld/testsuite/ld-cris/tls-ld-5.d51
-rw-r--r--ld/testsuite/ld-cris/tls-ld-5.s10
-rw-r--r--ld/testsuite/ld-cris/tls-ld-6.d50
-rw-r--r--ld/testsuite/ld-cris/tls-ld-6.s8
-rw-r--r--ld/testsuite/ld-cris/tls-ld-7.d51
-rw-r--r--ld/testsuite/ld-cris/tls-ld-7.s9
-rw-r--r--ld/testsuite/ld-cris/tls-ldgd-14.d71
-rw-r--r--ld/testsuite/ld-cris/tls-ldgd-14.s8
-rw-r--r--ld/testsuite/ld-cris/tls-ldgd-15.d72
-rw-r--r--ld/testsuite/ld-cris/tls-ldgd-15.s9
-rw-r--r--ld/testsuite/ld-cris/tls-ldgde-14.d61
-rw-r--r--ld/testsuite/ld-cris/tls-ldgde-15.d61
-rw-r--r--ld/testsuite/ld-cris/tls-ldgdex-14.d54
-rw-r--r--ld/testsuite/ld-cris/tls-ldgdex-15.d54
-rw-r--r--ld/testsuite/ld-cris/tls-ldgdx-14.d55
-rw-r--r--ld/testsuite/ld-cris/tls-ldgdx-15.d56
-rw-r--r--ld/testsuite/ld-cris/tls-le-12.d38
-rw-r--r--ld/testsuite/ld-cris/tls-le-12.s8
-rw-r--r--ld/testsuite/ld-cris/tls-le-12s.d38
-rw-r--r--ld/testsuite/ld-cris/tls-le-12s.s8
-rw-r--r--ld/testsuite/ld-cris/tls-le-13.d41
-rw-r--r--ld/testsuite/ld-cris/tls-le-13.s9
-rw-r--r--ld/testsuite/ld-cris/tls-le-13s.d40
-rw-r--r--ld/testsuite/ld-cris/tls-le-13s.s9
-rw-r--r--ld/testsuite/ld-cris/tls-legd-16.d59
-rw-r--r--ld/testsuite/ld-cris/tls-legd-16.s8
-rw-r--r--ld/testsuite/ld-cris/tls-legd-17.d58
-rw-r--r--ld/testsuite/ld-cris/tls-legdx-16.d52
-rw-r--r--ld/testsuite/ld-cris/tls-legdx-17.d54
-rw-r--r--ld/testsuite/ld-cris/tls-leie-18.d47
-rw-r--r--ld/testsuite/ld-cris/tls-leie-19.d58
-rw-r--r--ld/testsuite/ld-cris/tls-leie-19.s8
-rw-r--r--ld/testsuite/ld-cris/tls-local-54.d27
-rw-r--r--ld/testsuite/ld-cris/tls-local-54.s3
-rw-r--r--ld/testsuite/ld-cris/tls-local-57.d23
-rw-r--r--ld/testsuite/ld-cris/tls-local-57.s3
-rw-r--r--ld/testsuite/ld-cris/tls-local-58.d24
-rw-r--r--ld/testsuite/ld-cris/tls-local-58.s4
-rw-r--r--ld/testsuite/ld-cris/tls-local-59.d25
-rw-r--r--ld/testsuite/ld-cris/tls-local-59.s6
-rw-r--r--ld/testsuite/ld-cris/tls-local-60.d33
-rw-r--r--ld/testsuite/ld-cris/tls-local-61.d32
-rw-r--r--ld/testsuite/ld-cris/tls-local-63.d31
-rw-r--r--ld/testsuite/ld-cris/tls-local-64.d37
-rw-r--r--ld/testsuite/ld-cris/tls-ok-30.d29
-rw-r--r--ld/testsuite/ld-cris/tls-ok-32.d23
-rw-r--r--ld/testsuite/ld-cris/tls-ok-34.d28
-rw-r--r--ld/testsuite/ld-cris/tls-ok-36.d16
-rw-r--r--ld/testsuite/ld-cris/tls-tprelm.s26
-rw-r--r--ld/testsuite/ld-cris/tls-und-38.d27
-rw-r--r--ld/testsuite/ld-cris/tls-und-42.d26
-rw-r--r--ld/testsuite/ld-cris/tls-und-46.d27
-rw-r--r--ld/testsuite/ld-cris/tls-und-50.d26
-rw-r--r--ld/testsuite/ld-cris/tls-x.s7
-rw-r--r--ld/testsuite/ld-cris/tls-x1x2.s13
-rw-r--r--ld/testsuite/ld-cris/tls-z.s7
-rw-r--r--ld/testsuite/ld-cris/tls128.s8
-rw-r--r--ld/testsuite/ld-cris/tls128g.s9
136 files changed, 3415 insertions, 0 deletions
diff --git a/ld/testsuite/ld-cris/got7.s b/ld/testsuite/ld-cris/got7.s
new file mode 100644
index 0000000000..60ee466080
--- /dev/null
+++ b/ld/testsuite/ld-cris/got7.s
@@ -0,0 +1,21 @@
+; Just something defining 7 variables @ 4 bytes and requesting GOT
+; entries for each of them.
+
+ .text
+ .global got7fn
+ .type got7fn,@function
+got7fn:
+ .irpc n,1234567
+ move.d got7var\n:GOT,$r10
+ .endr
+.Lfe:
+ .size dsofn5,.Lfe-got7fn
+
+ .irpc n,1234567
+ .data
+ .global got7var\n
+ .type got7var\n,@object
+ .size got7var\n,4
+got7var\n:
+ .dword 0
+ .endr
diff --git a/ld/testsuite/ld-cris/init.s b/ld/testsuite/ld-cris/init.s
new file mode 100644
index 0000000000..b65ec44531
--- /dev/null
+++ b/ld/testsuite/ld-cris/init.s
@@ -0,0 +1,6 @@
+ .global _init
+ .type _init,@function
+_init:
+ nop
+.Lfe3:
+ .size _init,.Lfe3-_init
diff --git a/ld/testsuite/ld-cris/pic-gc-72.d b/ld/testsuite/ld-cris/pic-gc-72.d
new file mode 100644
index 0000000000..7c30980c3b
--- /dev/null
+++ b/ld/testsuite/ld-cris/pic-gc-72.d
@@ -0,0 +1,28 @@
+#source: pic-gc-72.s
+#source: expdref1.s
+#source: expdyn1.s
+#as: --pic --no-underscore --em=criself -I$srcdir/$subdir
+#ld: --shared -m crislinux --gc-sections
+#objdump: -s -t -R -p -T
+
+# Exercise PIC relocs through changed GC sweep function.
+# There should be nothing left except from expdyn1.s.
+
+.*: file format elf32-cris
+#...
+DYNAMIC RELOCATION RECORDS \(none\)
+
+Contents of section .hash:
+#...
+Contents of section .dynsym:
+#...
+Contents of section .dynstr:
+#...
+Contents of section .text:
+ 0188 0f050f05 .*
+Contents of section .dynamic:
+#...
+Contents of section .got:
+ 21e4 8c210000 00000000 00000000 .*
+Contents of section .data:
+ 21f0 00000000 .*
diff --git a/ld/testsuite/ld-cris/pic-gc-72.s b/ld/testsuite/ld-cris/pic-gc-72.s
new file mode 100644
index 0000000000..e09aa8ae09
--- /dev/null
+++ b/ld/testsuite/ld-cris/pic-gc-72.s
@@ -0,0 +1,3 @@
+ .hidden export_1
+ .include "dso-2.s"
+ move.w expobj:GOT16,$r10
diff --git a/ld/testsuite/ld-cris/pic-gc-73.d b/ld/testsuite/ld-cris/pic-gc-73.d
new file mode 100644
index 0000000000..1ef22deb1b
--- /dev/null
+++ b/ld/testsuite/ld-cris/pic-gc-73.d
@@ -0,0 +1,26 @@
+#source: pic-gc-73.s
+#source: expdyn1.s
+#as: --pic --no-underscore --em=criself -I$srcdir/$subdir
+#ld: --shared -m crislinux --gc-sections
+#objdump: -s -t -R -p -T
+
+# Left-over code coverage case from pic-gc-72; local symbol.
+
+.*: file format elf32-cris
+#...
+DYNAMIC RELOCATION RECORDS \(none\)
+
+Contents of section .hash:
+#...
+Contents of section .dynsym:
+#...
+Contents of section .dynstr:
+#...
+Contents of section .text:
+ 016e 0f050f05 .*
+Contents of section .dynamic:
+#...
+Contents of section .got:
+ 21cc 74210000 00000000 00000000 .*
+Contents of section .data:
+ 21d8 00000000 .*
diff --git a/ld/testsuite/ld-cris/pic-gc-73.s b/ld/testsuite/ld-cris/pic-gc-73.s
new file mode 100644
index 0000000000..6fd72dbc20
--- /dev/null
+++ b/ld/testsuite/ld-cris/pic-gc-73.s
@@ -0,0 +1,5 @@
+ .hidden export_1
+ .include "dso-2.s"
+dsofn:
+ .type dsofn,@function
+ move.w expobj:GOT16,$r10
diff --git a/ld/testsuite/ld-cris/tls-dso-x1x2-1.d b/ld/testsuite/ld-cris/tls-dso-x1x2-1.d
new file mode 100644
index 0000000000..b5397481ac
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-dso-x1x2-1.d
@@ -0,0 +1,16 @@
+#source: tls-hx.s
+#source: tls-x1x2.s
+#as: --no-underscore --em=criself
+#ld: -m crislinux --shared
+#objdump: -T
+
+# A DSO providing the TLS variables x1 and x2.
+
+.*: file format elf32-cris
+
+DYNAMIC SYMBOL TABLE:
+#...
+0+8 g D \.tdata 0+4 x2
+#...
+0+4 g D \.tdata 0+4 x1
+#...
diff --git a/ld/testsuite/ld-cris/tls-dso-xz-1.d b/ld/testsuite/ld-cris/tls-dso-xz-1.d
new file mode 100644
index 0000000000..9a33b78cc9
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-dso-xz-1.d
@@ -0,0 +1,18 @@
+#source: tls128.s
+#source: tls-hx1x2.s
+#source: tls-x.s
+#source: tls-z.s
+#as: --no-underscore --em=criself
+#ld: -m crislinux --shared
+#objdump: -T
+
+# A DSO providing the TLS variables x and z.
+
+.*: file format elf32-cris
+
+DYNAMIC SYMBOL TABLE:
+#...
+0+88 g D \.tdata 0+4 x
+#...
+0+8c g D \.tdata 0+4 z
+#...
diff --git a/ld/testsuite/ld-cris/tls-dtprelm.s b/ld/testsuite/ld-cris/tls-dtprelm.s
new file mode 100644
index 0000000000..f69724b867
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-dtprelm.s
@@ -0,0 +1,26 @@
+ .text
+
+ .ifndef r
+ .set r,1
+ .endif
+
+ .global tlsdsofndtprelm
+ .type tlsdsofndtprelm,@function
+ .p2align 1
+tlsdsofndtprelm:
+ move.w x:DTPREL16,$r10
+.Lfe:
+ .size tlsdsofndtprelm,.Lfe-tlsdsofndtprelm
+
+ .globl z
+ .section .tdata,"awT",@progbits
+ .p2align 2
+ .type z,@object
+ .size z,r
+z:
+ .fill r,1,42
+
+ .type x,@object
+ .size x,1
+x:
+ .byte 42
diff --git a/ld/testsuite/ld-cris/tls-e-20.d b/ld/testsuite/ld-cris/tls-e-20.d
new file mode 100644
index 0000000000..d4d4116b08
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-e-20.d
@@ -0,0 +1,71 @@
+#source: start1.s
+#source: tls-gd-2.s --pic
+#source: tls-hx.s
+#source: tls-ld-6.s --pic
+#source: tls-ie-10.s --pic
+#source: tls-hx1x2.s --pic
+#as: --no-underscore --em=criself -I$srcdir/$subdir
+#ld: -m crislinux
+#objdump: -d -s -h -t -r -p
+
+# Check that we have proper NPTL/TLS markings and GOT for an
+# executable with a R_CRIS_32_GOT_GD, a R_CRIS_DTPREL and a
+# R_CRIS_32_GOT_TPREL.
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+80000 paddr 0x0+80000 align 2\*\*13
+ filesz 0x0+b0 memsz 0x0+b0 flags r-x
+ LOAD off 0x0+b0 vaddr 0x0+820b0 paddr 0x0+820b0 align 2\*\*13
+ filesz 0x0+2c memsz 0x0+2c flags rw-
+ TLS off 0x0+b0 vaddr 0x0+820b0 paddr 0x0+820b0 align 2\*\*2
+ filesz 0x0+c memsz 0x0+c flags r--
+private flags = 0:
+
+Sections:
+Idx Name Size VMA LMA File off Algn
+ 0 \.text 0000001c 00080094 00080094 00000094 2\*\*1
+ CONTENTS, ALLOC, LOAD, READONLY, CODE
+ 1 \.tdata 0000000c 000820b0 000820b0 000000b0 2\*\*2
+ CONTENTS, ALLOC, LOAD, DATA, THREAD_LOCAL
+ 2 \.got 00000020 000820bc 000820bc 000000bc 2\*\*2
+ CONTENTS, ALLOC, LOAD, DATA
+SYMBOL TABLE:
+0+80094 l d \.text 0+ \.text
+0+820b0 l d \.tdata 0+ \.tdata
+0+820bc l d \.got 0+ \.got
+0+820bc l O \.got 0+ \.hidden _GLOBAL_OFFSET_TABLE_
+0+ g \.tdata 0+4 \.hidden x
+0+80098 g F \.text 0+6 tlsdsofn2
+0+8 g \.tdata 0+4 \.hidden x2
+0+80094 g \.text 0+ _start
+0+820dc g \*ABS\* 0+ __bss_start
+0+800a0 g F \.text 0+6 tlsdsofn
+0+4 g \.tdata 0+4 \.hidden x1
+0+820dc g \*ABS\* 0+ _edata
+0+820e0 g \*ABS\* 0+ _end
+0+800a8 g F \.text 0+6 tlsdsofn10
+
+Contents of section \.text:
+#...
+Contents of section \.tdata:
+ 820b0 28000000 29000000 2a000000 .*
+Contents of section \.got:
+ 820bc 00000000 00000000 00000000 01000000 .*
+ 820cc 00000000 00000000 01000000 00000000 .*
+
+Disassembly of section \.text:
+
+00080094 <_start>:
+ 80094: 41b2 moveq 1,\$r11
+#...
+00080098 <tlsdsofn2>:
+ 80098: 6fae 1800 0000 move\.d 18 <x2\+0x10>,\$r10
+#...
+000800a0 <tlsdsofn>:
+ 800a0: 6fae 0000 0000 move\.d 0 <x>,\$r10
+#...
+000800a8 <tlsdsofn10>:
+ 800a8: 6fae 1400 0000 move\.d 14 <x2\+0xc>,\$r10
+#...
diff --git a/ld/testsuite/ld-cris/tls-e-20a.d b/ld/testsuite/ld-cris/tls-e-20a.d
new file mode 100644
index 0000000000..fe4909e9d8
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-e-20a.d
@@ -0,0 +1,110 @@
+#source: start1.s
+#source: got7.s
+#source: tls128.s
+#source: tls-gd-2.s
+#source: tls-ld-6.s
+#source: tls-ie-10.s
+#source: tls-hx.s
+#source: tls-hx1x2.s
+#as: --no-underscore --em=criself -I$srcdir/$subdir --pic
+#ld: -m crislinux
+#objdump: -d -s -h -t -r -p
+
+# Like tls-e-20.d but with an offset for all TLS GOT entries, and an
+# offset for all TLS data we care about. Offsets different for TLS
+# than for GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+80000 paddr 0x0+80000 align 2\*\*13
+ filesz 0x0+dc memsz 0x0+dc flags r-x
+ LOAD off 0x0+dc vaddr 0x0+820dc paddr 0x0+820dc align 2\*\*13
+ filesz 0x0+e4 memsz 0x0+e4 flags rw-
+ TLS off 0x0+dc vaddr 0x0+820dc paddr 0x0+820dc align 2\*\*2
+ filesz 0x0+8c memsz 0x0+8c flags r--
+private flags = 0:
+
+Sections:
+Idx Name Size VMA LMA File off Algn
+ 0 \.text 0+48 0+80094 0+80094 0+94 2\*\*1
+ CONTENTS, ALLOC, LOAD, READONLY, CODE
+ 1 \.tdata 0+8c 0+820dc 0+820dc 0+dc 2\*\*2
+ CONTENTS, ALLOC, LOAD, DATA, THREAD_LOCAL
+ 2 \.got 0+3c 0+82168 0+82168 0+168 2\*\*2
+ CONTENTS, ALLOC, LOAD, DATA
+ 3 \.data 0+1c 0+821a4 0+821a4 0+1a4 2\*\*0
+ CONTENTS, ALLOC, LOAD, DATA
+SYMBOL TABLE:
+0+80094 l d \.text 0+ \.text
+0+820dc l d \.tdata 0+ \.tdata
+0+82168 l d \.got 0+ \.got
+0+821a4 l d \.data 0+ \.data
+0+ l \.tdata 0+80 tls128
+0+82168 l O \.got 0+ \.hidden _GLOBAL_OFFSET_TABLE_
+0+80 g \.tdata 0+4 \.hidden x
+0+800c4 g F \.text 0+6 tlsdsofn2
+0+821b4 g O \.data 0+4 got7var5
+0+88 g \.tdata 0+4 \.hidden x2
+0+821ac g O \.data 0+4 got7var3
+0+821bc g O \.data 0+4 got7var7
+0+80098 g F \.text 0+ got7fn
+0+821b8 g O \.data 0+4 got7var6
+0+80094 g \.text 0+ _start
+0+821c0 g \*ABS\* 0+ __bss_start
+0+821a4 g O \.data 0+4 got7var1
+0+821b0 g O \.data 0+4 got7var4
+0+800cc g F \.text 0+6 tlsdsofn
+0+84 g \.tdata 0+4 \.hidden x1
+0+821c0 g \*ABS\* 0+ _edata
+0+821c0 g \*ABS\* 0+ _end
+0+821a8 g O \.data 0+4 got7var2
+0+800d4 g F \.text 0+6 tlsdsofn10
+
+Contents of section \.text:
+#...
+Contents of section \.tdata:
+ 820dc 2f000000 00000000 00000000 00000000 .*
+ 820ec 00000000 00000000 00000000 00000000 .*
+ 820fc 00000000 00000000 00000000 00000000 .*
+ 8210c 00000000 00000000 00000000 00000000 .*
+ 8211c 00000000 00000000 00000000 00000000 .*
+ 8212c 00000000 00000000 00000000 00000000 .*
+ 8213c 00000000 00000000 00000000 00000000 .*
+ 8214c 00000000 00000000 00000000 00000000 .*
+ 8215c 28000000 29000000 2a000000 .*
+Contents of section \.got:
+ 82168 00000000 00000000 00000000 01000000 .*
+ 82178 00000000 80000000 01000000 80000000 .*
+ 82188 b4210800 ac210800 bc210800 b8210800 .*
+ 82198 a4210800 b0210800 a8210800 .*
+Contents of section \.data:
+ 821a4 00000000 00000000 00000000 00000000 .*
+ 821b4 00000000 00000000 00000000 .*
+
+Disassembly of section \.text:
+
+00080094 <_start>:
+ 80094: 41b2 moveq 1,\$r11
+#...
+00080098 <got7fn>:
+ 80098: 6fae 3000 0000 move\.d 30 <tls128\+0x30>,\$r10
+ 8009e: 6fae 3800 0000 move\.d 38 <tls128\+0x38>,\$r10
+ 800a4: 6fae 2400 0000 move\.d 24 <tls128\+0x24>,\$r10
+ 800aa: 6fae 3400 0000 move\.d 34 <tls128\+0x34>,\$r10
+ 800b0: 6fae 2000 0000 move\.d 20 <tls128\+0x20>,\$r10
+ 800b6: 6fae 2c00 0000 move\.d 2c <tls128\+0x2c>,\$r10
+ 800bc: 6fae 2800 0000 move\.d 28 <tls128\+0x28>,\$r10
+#...
+
+000800c4 <tlsdsofn2>:
+ 800c4: 6fae 1800 0000 move\.d 18 <tls128\+0x18>,\$r10
+#...
+
+000800cc <tlsdsofn>:
+ 800cc: 6fae 8000 0000 move\.d 80 <x>,\$r10
+#...
+
+000800d4 <tlsdsofn10>:
+ 800d4: 6fae 1400 0000 move\.d 14 <tls128\+0x14>,\$r10
+#...
diff --git a/ld/testsuite/ld-cris/tls-e-21.d b/ld/testsuite/ld-cris/tls-e-21.d
new file mode 100644
index 0000000000..fa56b9faad
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-e-21.d
@@ -0,0 +1,39 @@
+#source: start1.s
+#source: tls128.s
+#source: tls-gd-2.s
+#source: tls-hx.s
+#as: --no-underscore --em=criself --pic
+#ld: -m crislinux
+#objdump: -d -s -t -r -p
+
+# Check that we have proper NPTL/TLS markings and GOT for an
+# executable with a single R_CRIS_32_GOT_GD.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off 0x0+a0 vaddr 0x0+820a0 paddr 0x0+820a0 align 2\*\*2
+ filesz 0x0+84 memsz 0x0+84 flags r--
+private flags = 0:
+#...
+SYMBOL TABLE:
+#...
+0+80 g \.tdata 0+4 \.hidden x
+#...
+Contents of section \.text:
+#...
+Contents of section \.tdata:
+#...
+Contents of section \.got:
+ 82124 00000000 00000000 00000000 01000000 .*
+ 82134 80000000 .*
+
+Disassembly of section \.text:
+
+00080094 <_start>:
+ 80094: 41b2 moveq 1,\$r11
+#...
+00080098 <tlsdsofn2>:
+ 80098: 6fae 0c00 0000 move\.d c <tls128\+0xc>,\$r10
+#...
diff --git a/ld/testsuite/ld-cris/tls-e-22.d b/ld/testsuite/ld-cris/tls-e-22.d
new file mode 100644
index 0000000000..93ab45da7b
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-e-22.d
@@ -0,0 +1,39 @@
+#source: start1.s
+#source: tls128.s
+#source: tls-ld-6.s
+#source: tls-hx.s
+#as: --no-underscore --em=criself --pic -I$srcdir/$subdir
+#ld: -m crislinux
+#objdump: -d -s -t -r -p
+
+# Check that we have proper NPTL/TLS markings and GOT for an
+# executable with a single R_CRIS_DTPREL.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off 0x0+a0 vaddr 0x0+820a0 paddr 0x0+820a0 align 2\*\*2
+ filesz 0x0+84 memsz 0x0+84 flags r--
+private flags = 0:
+#...
+SYMBOL TABLE:
+#...
+0+80 g \.tdata 0+4 \.hidden x
+#...
+Contents of section \.text:
+#...
+Contents of section \.tdata:
+#...
+Contents of section \.got:
+ 82124 00000000 00000000 00000000 01000000 .*
+ 82134 00000000 .*
+
+Disassembly of section \.text:
+
+00080094 <_start>:
+ 80094: 41b2 moveq 1,\$r11
+#...
+00080098 <tlsdsofn>:
+ 80098: 6fae 8000 0000 move\.d 80 <x>,\$r10
+#...
diff --git a/ld/testsuite/ld-cris/tls-e-23.d b/ld/testsuite/ld-cris/tls-e-23.d
new file mode 100644
index 0000000000..3ac46399ed
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-e-23.d
@@ -0,0 +1,38 @@
+#source: start1.s
+#source: tls128.s
+#source: tls-ie-10.s
+#source: tls-hx.s
+#as: --no-underscore --em=criself --pic -I$srcdir/$subdir
+#ld: -m crislinux
+#objdump: -d -s -t -r -p
+
+# Check that we have proper NPTL/TLS markings and GOT for an
+# executable with a single R_CRIS_32_GOT_TPREL.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off 0x0+a0 vaddr 0x0+820a0 paddr 0x0+820a0 align 2\*\*2
+ filesz 0x0+84 memsz 0x0+84 flags r--
+private flags = 0:
+#...
+SYMBOL TABLE:
+#...
+0+80 g \.tdata 0+4 \.hidden x
+#...
+Contents of section \.text:
+#...
+Contents of section \.tdata:
+#...
+Contents of section \.got:
+ 82124 00000000 00000000 00000000 80000000 .*
+
+Disassembly of section \.text:
+
+00080094 <_start>:
+ 80094: 41b2 moveq 1,\$r11
+#...
+00080098 <tlsdsofn10>:
+ 80098: 6fae 0c00 0000 move\.d c <tls128\+0xc>,\$r10
+#...
diff --git a/ld/testsuite/ld-cris/tls-e-66.d b/ld/testsuite/ld-cris/tls-e-66.d
new file mode 100644
index 0000000000..a073b94037
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-e-66.d
@@ -0,0 +1,37 @@
+#source: start1.s
+#source: tls-le-12s.s
+#source: tls-z.s
+#as: --no-underscore --em=criself -I$srcdir/$subdir
+#ld: -m crislinux
+#objdump: -d -s -t -r -p -h
+
+# Check that we have proper NPTL/TLS markings and no GOT for an
+# executable with a single R_CRIS_16_TPREL.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off 0x0+9c vaddr 0x0+8209c paddr 0x0+8209c align 2\*\*2
+ filesz 0x0+4 memsz 0x0+4 flags r--
+private flags = 0:
+#...
+ 1 .tdata .*
+ CONTENTS.*
+SYMBOL TABLE:
+#...
+0+ g \.tdata 0+4 z
+#...
+Contents of section \.text:
+#...
+Contents of section \.tdata:
+#...
+
+Disassembly of section \.text:
+
+00080094 <_start>:
+ 80094: 41b2 moveq 1,\$r11
+#...
+00080098 <tlsfn12>:
+ 80098: 5fac 0000 movu\.w 0x0,\$r10
+#...
diff --git a/ld/testsuite/ld-cris/tls-err-20x.d b/ld/testsuite/ld-cris/tls-err-20x.d
new file mode 100644
index 0000000000..75e3b030b9
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-20x.d
@@ -0,0 +1,11 @@
+#source: init.s
+#source: tls-ie-9.s --pic
+#source: tls-ld-6.s --pic
+#source: tls-ie-10.s --pic
+#source: tls-hx.s --pic
+#as: --no-underscore --em=criself
+#ld: -m crislinux
+#error: \A[^\n]*: warning: cannot find entry symbol _start; defaulting to [0-9a-f]*\n[^\n]*: In function `tlsdsofn9':\n[^\n]*: undefined reference to `x1'\n[^\n]*: In function `tlsdsofn9':\n[^n]*: undefined reference to `x2'\Z
+
+# Code coverage case similar to tls-e-20.d, except with an undefined
+# reference.
diff --git a/ld/testsuite/ld-cris/tls-err-24.d b/ld/testsuite/ld-cris/tls-err-24.d
new file mode 100644
index 0000000000..e1bc88bafc
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-24.d
@@ -0,0 +1,7 @@
+#source: tls-le-12s.s
+#source: tls-z.s
+#as: --no-underscore --em=criself
+#ld: --shared -m crislinux
+#error: \A[^\n]*\.o, [^\n]*\n[^\n]*mixup[^\n]*\n[^\n]*Invalid operation\Z
+
+# Check that R_CRIS_16_TPREL in input to a DSO is flagged as an error.
diff --git a/ld/testsuite/ld-cris/tls-err-25.d b/ld/testsuite/ld-cris/tls-err-25.d
new file mode 100644
index 0000000000..df5ca6b9c6
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-25.d
@@ -0,0 +1,7 @@
+#source: tls-le-12.s
+#source: tls-z.s
+#as: --no-underscore --em=criself
+#ld: --shared -m crislinux
+#error: \A[^\n]*\.o, [^\n]*\n[^\n]*mixup[^\n]*\n[^\n]*Invalid operation\Z
+
+# Check that R_CRIS_32_TPREL in input to a DSO is flagged as an error.
diff --git a/ld/testsuite/ld-cris/tls-err-26.d b/ld/testsuite/ld-cris/tls-err-26.d
new file mode 100644
index 0000000000..71ecc9bac4
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-26.d
@@ -0,0 +1,8 @@
+#source: tls-ld-4.s
+#source: tls-x.s
+#as: --no-underscore --em=criself --pic
+#ld: --shared -m crislinux
+#error: \A[^\n]*\.o,[^\n]*mixup[^\n]*\n[^\n]*Bad value\Z
+
+# Check that R_CRIS_16_DTPREL on non-module-local symbol in input to a
+# DSO is flagged as an error.
diff --git a/ld/testsuite/ld-cris/tls-err-27.d b/ld/testsuite/ld-cris/tls-err-27.d
new file mode 100644
index 0000000000..3d40b0325b
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-27.d
@@ -0,0 +1,8 @@
+#source: tls-ld-6.s
+#source: tls-x.s
+#as: --no-underscore --em=criself --pic
+#ld: --shared -m crislinux
+#error: \A[^\n]*\.o,[^\n]*mixup[^\n]*\n[^\n]*Bad value\Z
+
+# Check that R_CRIS_32_DTPREL on non-module-local symbol in input to a
+# DSO is flagged as an error.
diff --git a/ld/testsuite/ld-cris/tls-err-28.d b/ld/testsuite/ld-cris/tls-err-28.d
new file mode 100644
index 0000000000..d7bfa9d740
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-28.d
@@ -0,0 +1,7 @@
+#source: tls-gd-3.s
+#source: tls-x.s
+#as: --no-underscore --em=criself
+#ld: --shared -m crislinux
+#error: \A[^\n]*\.o, [^\n]*\n[^\n]*mixup[^\n]*\n[^\n]*Invalid operation\Z
+
+# Check that a R_CRIS_32_GD in input to a DSO is flagged as an error.
diff --git a/ld/testsuite/ld-cris/tls-err-29.d b/ld/testsuite/ld-cris/tls-err-29.d
new file mode 100644
index 0000000000..1024ea8953
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-29.d
@@ -0,0 +1,7 @@
+#source: init.s
+#source: tls-gdgotrelm.s --defsym r=8192
+#as: --no-underscore --em=criself --pic
+#ld: --shared -m crislinux
+#error: \A[^\n]*\.o: In function[^\n]*\n[^\n]*truncated[^\n]*\n[^\n]*too many[^\n]*\Z
+
+# Check that overflow for R_CRIS_16_GOT_GD is flagged as an error.
diff --git a/ld/testsuite/ld-cris/tls-err-31.d b/ld/testsuite/ld-cris/tls-err-31.d
new file mode 100644
index 0000000000..b95fa54d5c
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-31.d
@@ -0,0 +1,6 @@
+#source: tls-dtprelm.s --defsym r=32768
+#as: --no-underscore --em=criself --pic
+#ld: --shared -m crislinux
+#error: \A[^\n]*\.o: In function[^\n]*\n[^\n]*truncated[^\n]*\n[^\n]*too big[^\n]*\Z
+
+# Check that overflow for R_CRIS_16_DTPREL is flagged as an error.
diff --git a/ld/testsuite/ld-cris/tls-err-33.d b/ld/testsuite/ld-cris/tls-err-33.d
new file mode 100644
index 0000000000..6872bbd4af
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-33.d
@@ -0,0 +1,6 @@
+#source: tls-gottprelm.s --defsym r=8190
+#as: --no-underscore --em=criself --pic
+#ld: --shared -m crislinux
+#error: \A[^\n]*\.o: In function[^\n]*\n[^\n]*truncated[^\n]*\n[^\n]*too many[^\n]*\Z
+
+# Check that overflow for R_CRIS_16_GOT_TPREL is flagged as an error.
diff --git a/ld/testsuite/ld-cris/tls-err-35.d b/ld/testsuite/ld-cris/tls-err-35.d
new file mode 100644
index 0000000000..9aa7b87bba
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-35.d
@@ -0,0 +1,7 @@
+#source: start1.s
+#source: tls-tprelm.s --defsym r=32768
+#as: --no-underscore --em=criself
+#ld: -m crislinux
+#error: \A[^\n]*\.o: In function[^\n]*\n[^\n]*truncated[^\n]*\n[^\n]*too big[^\n]*\Z
+
+# Check that overflow for R_CRIS_16_TPREL is flagged as an error.
diff --git a/ld/testsuite/ld-cris/tls-err-37.d b/ld/testsuite/ld-cris/tls-err-37.d
new file mode 100644
index 0000000000..e2efff171b
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-37.d
@@ -0,0 +1,7 @@
+#source: start1.s
+#source: tls-gd-2.s --pic
+#as: --no-underscore --em=criself
+#ld: -m crislinux
+#error: \A[^\n]*\.o: In function[^\n]*\n[^\n]*undefined reference[^\n]*\Z
+
+# Undefined reference for a R_CRIS_32_GOT_GD in an executable.
diff --git a/ld/testsuite/ld-cris/tls-err-39.d b/ld/testsuite/ld-cris/tls-err-39.d
new file mode 100644
index 0000000000..dab70f207f
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-39.d
@@ -0,0 +1,7 @@
+#source: start1.s
+#source: tls-ld-6.s --pic
+#as: --no-underscore --em=criself
+#ld: -m crislinux
+#error: \A[^\n]*\.o: In function[^\n]*\n[^\n]*undefined reference[^\n]*\Z
+
+# Undefined reference for a R_CRIS_32_DTPREL in an executable.
diff --git a/ld/testsuite/ld-cris/tls-err-40.d b/ld/testsuite/ld-cris/tls-err-40.d
new file mode 100644
index 0000000000..ef9a18a206
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-40.d
@@ -0,0 +1,6 @@
+#source: tls-ld-6.s --pic
+#as: --no-underscore --em=criself
+#ld: -m crislinux --shared
+#error: \A[^\n]*\.o[^\n]*undefined reference[^\n]*\n[^\n]*Bad value\Z
+
+# Undefined reference for a R_CRIS_32_DTPREL in a DSO.
diff --git a/ld/testsuite/ld-cris/tls-err-41.d b/ld/testsuite/ld-cris/tls-err-41.d
new file mode 100644
index 0000000000..b751f0aaa6
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-41.d
@@ -0,0 +1,7 @@
+#source: start1.s
+#source: tls-ie-10.s --pic
+#as: --no-underscore --em=criself
+#ld: -m crislinux
+#error: \A[^\n]*\.o: In function[^\n]*\n[^\n]*undefined reference[^\n]*\Z
+
+# Undefined reference for a R_CRIS_32_GOT_TPREL in an executable.
diff --git a/ld/testsuite/ld-cris/tls-err-43.d b/ld/testsuite/ld-cris/tls-err-43.d
new file mode 100644
index 0000000000..f516c6fcbb
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-43.d
@@ -0,0 +1,7 @@
+#source: start1.s
+#source: tls-le-12.s
+#as: --no-underscore --em=criself
+#ld: -m crislinux
+#error: \A[^\n]*\.o: In function[^\n]*\n[^\n]*undefined reference[^\n]*\Z
+
+# Undefined reference for a R_CRIS_32_TPREL in an executable.
diff --git a/ld/testsuite/ld-cris/tls-err-44.d b/ld/testsuite/ld-cris/tls-err-44.d
new file mode 100644
index 0000000000..251470d82d
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-44.d
@@ -0,0 +1,8 @@
+#source: tls-le-12.s
+#as: --no-underscore --em=criself
+#ld: -m crislinux --shared
+#error: \A[^\n]*\.o, [^\n]*\n[^\n]*mixup[^\n]*\n[^\n]*Invalid operation\Z
+
+# Undefined reference for a R_CRIS_32_TPREL in a DSO (where it's
+# invalid in the first place anyway, so we should see the same
+# behavior as for that test, tls-err-25.d).
diff --git a/ld/testsuite/ld-cris/tls-err-45.d b/ld/testsuite/ld-cris/tls-err-45.d
new file mode 100644
index 0000000000..be847baf64
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-45.d
@@ -0,0 +1,7 @@
+#source: start1.s
+#source: tls-gd-1.s --pic
+#as: --no-underscore --em=criself
+#ld: -m crislinux
+#error: \A[^\n]*\.o: In function[^\n]*\n[^\n]*undefined reference[^\n]*\Z
+
+# Undefined reference for a R_CRIS_16_GOT_GD in an executable.
diff --git a/ld/testsuite/ld-cris/tls-err-47.d b/ld/testsuite/ld-cris/tls-err-47.d
new file mode 100644
index 0000000000..d9a1a30482
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-47.d
@@ -0,0 +1,7 @@
+#source: start1.s
+#source: tls-ld-4.s --pic
+#as: --no-underscore --em=criself
+#ld: -m crislinux
+#error: \A[^\n]*\.o: In function[^\n]*\n[^\n]*undefined reference[^\n]*\Z
+
+# Undefined reference for a R_CRIS_16_DTPREL in an executable.
diff --git a/ld/testsuite/ld-cris/tls-err-48.d b/ld/testsuite/ld-cris/tls-err-48.d
new file mode 100644
index 0000000000..9165fcd6f2
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-48.d
@@ -0,0 +1,6 @@
+#source: tls-ld-4.s --pic
+#as: --no-underscore --em=criself
+#ld: -m crislinux --shared
+#error: \A[^\n]*\.o[^\n]*undefined reference[^\n]*\n[^\n]*Bad value\Z
+
+# Undefined reference for a R_CRIS_16_DTPREL in a DSO.
diff --git a/ld/testsuite/ld-cris/tls-err-49.d b/ld/testsuite/ld-cris/tls-err-49.d
new file mode 100644
index 0000000000..6ff4ba5d3c
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-49.d
@@ -0,0 +1,7 @@
+#source: start1.s
+#source: tls-ie-8.s --pic
+#as: --no-underscore --em=criself
+#ld: -m crislinux
+#error: \A[^\n]*\.o: In function[^\n]*\n[^\n]*undefined reference[^\n]*\Z
+
+# Undefined reference for a R_CRIS_16_GOT_TPREL in an executable.
diff --git a/ld/testsuite/ld-cris/tls-err-51.d b/ld/testsuite/ld-cris/tls-err-51.d
new file mode 100644
index 0000000000..8e71cc50f0
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-51.d
@@ -0,0 +1,7 @@
+#source: start1.s
+#source: tls-le-12s.s
+#as: --no-underscore --em=criself
+#ld: -m crislinux
+#error: \A[^\n]*\.o: In function[^\n]*\n[^\n]*undefined reference[^\n]*\Z
+
+# Undefined reference for a R_CRIS_16_TPREL in an executable.
diff --git a/ld/testsuite/ld-cris/tls-err-52.d b/ld/testsuite/ld-cris/tls-err-52.d
new file mode 100644
index 0000000000..cf0bbbcd00
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-52.d
@@ -0,0 +1,8 @@
+#source: tls-le-12s.s
+#as: --no-underscore --em=criself
+#ld: -m crislinux --shared
+#error: \A[^\n]*\.o, [^\n]*\n[^\n]*mixup[^\n]*\n[^\n]*Invalid operation\Z
+
+# Undefined reference for a R_CRIS_16_TPREL in a DSO (where it's
+# invalid in the first place anyway, so we should see the same
+# behavior as for that test, tls-err-24.d).
diff --git a/ld/testsuite/ld-cris/tls-err-53.d b/ld/testsuite/ld-cris/tls-err-53.d
new file mode 100644
index 0000000000..1ae3d42312
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-53.d
@@ -0,0 +1,7 @@
+#source: start1.s
+#source: tls-ld-4.s
+#as: --no-underscore --em=criself --pic
+#ld: -m crislinux tmpdir/tls-dso-xz-1.so
+#error: \A[^\n]*\.o,[^\n]*mixup[^\n]*\n[^\n]*Bad value\Z
+
+# R_CRIS_16_DTPREL in executable against symbol from DSO.
diff --git a/ld/testsuite/ld-cris/tls-err-55.d b/ld/testsuite/ld-cris/tls-err-55.d
new file mode 100644
index 0000000000..08f77f3ebd
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-55.d
@@ -0,0 +1,6 @@
+#source: tls-err-55.s
+#as: --pic --no-underscore --em=criself -I$srcdir/$subdir
+#ld: --shared -m crislinux
+#error: \A[^\n]*\.o[^\n]*relocation R_CRIS_32_GOT_GD with non-zero addend 42 against symbol `tls128'[^\n]*\n[^\n]*Bad value\Z
+
+# Check that non-zero addend on a R_CRIS_32_GOT_GD is flagged as an error.
diff --git a/ld/testsuite/ld-cris/tls-err-55.s b/ld/testsuite/ld-cris/tls-err-55.s
new file mode 100644
index 0000000000..aadae0ded7
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-55.s
@@ -0,0 +1,8 @@
+ .text
+ .global tlsdsofn2
+ .type tlsdsofn2,@function
+ .p2align 1
+tlsdsofn2:
+ move.d tls128+42:GDGOTREL,$r10
+.Lfe1:
+ .size tlsdsofn2,.Lfe1-tlsdsofn2
diff --git a/ld/testsuite/ld-cris/tls-err-56.d b/ld/testsuite/ld-cris/tls-err-56.d
new file mode 100644
index 0000000000..2d592a634f
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-56.d
@@ -0,0 +1,7 @@
+#source: tls-err-56.s
+#as: --pic --no-underscore --em=criself -I$srcdir/$subdir
+#ld: --shared -m crislinux
+#error: \A[^\n]*\.o[^\n]*relocation R_CRIS_32_GOT_GD with non-zero addend 42 against symbol `tls128'[^\n]*\n[^\n]*Bad value\Z
+
+# Check that non-zero addend on a R_CRIS_32_GOT_GD is flagged as an error.
+# The difference to tls-err-55.d is that this one refers to a local symbol.
diff --git a/ld/testsuite/ld-cris/tls-err-56.s b/ld/testsuite/ld-cris/tls-err-56.s
new file mode 100644
index 0000000000..b8a0443d27
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-56.s
@@ -0,0 +1,9 @@
+ .include "tls128.s"
+ .text
+ .global tlsdsofn2
+ .type tlsdsofn2,@function
+ .p2align 1
+tlsdsofn2:
+ move.d tls128+42:GDGOTREL,$r10
+.Lfe1:
+ .size tlsdsofn2,.Lfe1-tlsdsofn2
diff --git a/ld/testsuite/ld-cris/tls-err-62.d b/ld/testsuite/ld-cris/tls-err-62.d
new file mode 100644
index 0000000000..4434120355
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-62.d
@@ -0,0 +1,7 @@
+#source: tls-err-62.s
+#as: --pic --no-underscore --em=criself -I$srcdir/$subdir
+#ld: --shared -m crislinux
+#error: \A[^\n]*\.o[^\n]*relocation R_CRIS_32_GOT_TPREL with non-zero addend 42 against symbol `tls128'[^\n]*\n[^\n]*Bad value\Z
+
+# Check that non-zero addend on a R_CRIS_32_GOT_TPREL is flagged as an
+# error, local symbol.
diff --git a/ld/testsuite/ld-cris/tls-err-62.s b/ld/testsuite/ld-cris/tls-err-62.s
new file mode 100644
index 0000000000..b378dc5a8c
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-62.s
@@ -0,0 +1,9 @@
+ .include "tls128.s"
+ .text
+ .global tlsdsofn2
+ .type tlsdsofn2,@function
+ .p2align 1
+tlsdsofn2:
+ move.d tls128+42:TPOFFGOT,$r10
+.Lfe1:
+ .size tlsdsofn2,.Lfe1-tlsdsofn2
diff --git a/ld/testsuite/ld-cris/tls-err-65.d b/ld/testsuite/ld-cris/tls-err-65.d
new file mode 100644
index 0000000000..23c880f0a8
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-65.d
@@ -0,0 +1,7 @@
+#source: start1.s
+#source: tls-le-12s.s
+#as: --no-underscore --em=criself
+#ld: -m crislinux tmpdir/tls-dso-xz-1.so
+#error: \A[^\n]*\.o,[^\n]*mixup[^\n]*\n[^\n]*Bad value\Z
+
+# R_CRIS_16_TPREL in executable against symbol from DSO.
diff --git a/ld/testsuite/ld-cris/tls-err-67.d b/ld/testsuite/ld-cris/tls-err-67.d
new file mode 100644
index 0000000000..0a0020b159
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-err-67.d
@@ -0,0 +1,9 @@
+#source: init.s
+#source: tls-gdgotrelm.s --defsym r=8203
+#as: --no-underscore --em=criself --pic
+#ld: --shared -m crislinux
+#error: \A[^\n]*\.o: In[^\n]*\n[^\n]*truncated[^\n]*\n[^\n]*too many[^\n]*\n[^\n]*\.o: In[^\n]*\n[^\n]*truncated[^\n]*\n[^\n]*too many[^\n]*\n[^\n]*\.o: In[^\n]*\n[^\n]*truncated[^\n]*\n[^\n]*too many[^\n]*\n[^\n]*\.o: In[^\n]*\n[^\n]*truncated[^\n]*\n[^\n]*too many[^\n]*\n[^\n]*\.o: In[^\n]*\n[^\n]*truncated[^\n]*\n[^\n]*too many[^\n]*\n[^\n]*\.o: In[^\n]*\n[^\n]*truncated[^\n]*\n[^\n]*too many[^\n]*\n[^\n]*\.o: In[^\n]*\n[^\n]*truncated[^\n]*\n[^\n]*too many[^\n]*\n[^\n]*\.o: In[^\n]*\n[^\n]*truncated[^\n]*\n[^\n]*too many[^\n]*\n[^\n]*\.o: In[^\n]*\n[^\n]*truncated[^\n]*\n[^\n]*too many[^\n]*\n[^\n]*\.o: In[^\n]*\n[^\n]*truncated[^\n]*\n[^\n]*too many[^\n]*\n[^\n]*\.o: In[^\n]*\n[^\n]*omitted[^\n]*\Z
+
+# Check that the error messages get the right number of appended
+# explanations with default values when bailing out and omitting
+# further error messages for overflows.
diff --git a/ld/testsuite/ld-cris/tls-gc-68.d b/ld/testsuite/ld-cris/tls-gc-68.d
new file mode 100644
index 0000000000..cfed0e5a5e
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-gc-68.d
@@ -0,0 +1,33 @@
+#source: start1.s
+#source: tls-x.s
+#source: tls-local-58.s
+#as: --pic --no-underscore --em=criself -I$srcdir/$subdir
+#ld: -m crislinux --gc-sections
+#objdump: -s -t -r -p
+
+# An executable with a R_CRIS_32_GOT_GD and a R_CRIS_16_GOT_GD against
+# the same local symbol, gc:ed. Check that we have nothing left but
+# the start symbol and its code. Can't get rid of the GOT just yet.
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+80000 paddr 0x0+80000 align 2\*\*13
+ filesz 0x0+78 memsz 0x0+78 flags r-x
+ LOAD off 0x0+78 vaddr 0x0+82078 paddr 0x0+82078 align 2\*\*13
+ filesz 0x0+c memsz 0x0+c flags rw-
+private flags = 0:
+
+SYMBOL TABLE:
+0+80074 l d .text 0+ .text
+0+82078 l d .got 0+ .got
+0+82078 l O .got 0+ .hidden _GLOBAL_OFFSET_TABLE_
+0+80074 g .text 0+ _start
+0+82084 g \*ABS\* 0+ __bss_start
+0+82084 g \*ABS\* 0+ _edata
+0+820a0 g \*ABS\* 0+ _end
+
+Contents of section .text:
+ 80074 41b20+ .*
+Contents of section .got:
+ 82078 0+ 0+ 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-gc-69.d b/ld/testsuite/ld-cris/tls-gc-69.d
new file mode 100644
index 0000000000..dd9b30a3c7
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-gc-69.d
@@ -0,0 +1,34 @@
+#source: start1.s
+#source: tls-x.s
+#source: tls-local-59.s
+#as: --pic --no-underscore --em=criself -I$srcdir/$subdir
+#ld: -m crislinux --gc-sections
+#objdump: -s -t -r -p
+
+# An executable with a R_CRIS_32_GOT_GD, a R_CRIS_16_GOT_GD, a
+# R_CRIS_32_GOT_TPREL and a R_CRIS_16_GOT_TPREL against the same local
+# symbol, gc:ed. Check that we have nothing left but the start symbol
+# and its code. Can't get rid of the GOT just yet.
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+80000 paddr 0x0+80000 align 2\*\*13
+ filesz 0x0+78 memsz 0x0+78 flags r-x
+ LOAD off 0x0+78 vaddr 0x0+82078 paddr 0x0+82078 align 2\*\*13
+ filesz 0x0+c memsz 0x0+c flags rw-
+private flags = 0:
+
+SYMBOL TABLE:
+0+80074 l d .text 0+ .text
+0+82078 l d .got 0+ .got
+0+82078 l O .got 0+ .hidden _GLOBAL_OFFSET_TABLE_
+0+80074 g .text 0+ _start
+0+82084 g \*ABS\* 0+ __bss_start
+0+82084 g \*ABS\* 0+ _edata
+0+820a0 g \*ABS\* 0+ _end
+
+Contents of section .text:
+ 80074 41b20+ .*
+Contents of section .got:
+ 82078 0+ 0+ 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-gc-70.d b/ld/testsuite/ld-cris/tls-gc-70.d
new file mode 100644
index 0000000000..048b7e9286
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-gc-70.d
@@ -0,0 +1,34 @@
+#source: start1.s
+#source: tls128.s
+#source: tls-gd-3.s
+#source: tls-x.s
+#as: --no-underscore --em=criself
+#ld: -m crislinux --gc-sections
+#objdump: -s -t -r -p
+
+# An executable with a single R_CRIS_32_GD, with gc. Check that we
+# have nothing left but the start symbol and its code. Can't get rid
+# of the GOT just yet.
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+80000 paddr 0x0+80000 align 2\*\*13
+ filesz 0x0+78 memsz 0x0+78 flags r-x
+ LOAD off 0x0+78 vaddr 0x0+82078 paddr 0x0+82078 align 2\*\*13
+ filesz 0x0+c memsz 0x0+c flags rw-
+private flags = 0:
+
+SYMBOL TABLE:
+0+80074 l d .text 0+ .text
+0+82078 l d .got 0+ .got
+0+82078 l O .got 0+ .hidden _GLOBAL_OFFSET_TABLE_
+0+80074 g .text 0+ _start
+0+82084 g \*ABS\* 0+ __bss_start
+0+82084 g \*ABS\* 0+ _edata
+0+820a0 g \*ABS\* 0+ _end
+
+Contents of section .text:
+ 80074 41b20+ .*
+Contents of section .got:
+ 82078 0+ 0+ 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-gc-71.d b/ld/testsuite/ld-cris/tls-gc-71.d
new file mode 100644
index 0000000000..3ee73fc3af
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-gc-71.d
@@ -0,0 +1,32 @@
+#source: tls-gc-71.s
+#source: init.s
+#source: tls128g.s
+#source: tls-hx.s
+#as: --pic --no-underscore --em=criself -I$srcdir/$subdir
+#ld: --shared -m crislinux --gc-sections
+#objdump: -s -t -R -p -T
+
+# DSO with a single R_CRIS_16_DTPREL against a hidden symbol, gc:ed.
+# Check that we still have the other, global, TLS variable.
+
+.*: file format elf32-cris
+#...
+ TLS off .*
+ filesz 0x0+80 memsz 0x0+80 flags r--
+#...
+DYNAMIC SYMBOL TABLE:
+0+18e l d .text 0+ .text
+0+2194 l d .tdata 0+ .tdata
+0+18e g DF .text 0+2 _init
+0+2280 g D \*ABS\* 0+ __bss_start
+0+ g D .tdata 0+80 tls128
+0+2280 g D \*ABS\* 0+ _edata
+0+2280 g D \*ABS\* 0+ _end
+
+DYNAMIC RELOCATION RECORDS \(none\)
+#...
+Contents of section .text:
+ 018e 0f050000 .*
+#...
+Contents of section .got:
+ 2274 14220000 00000000 00000000 .*
diff --git a/ld/testsuite/ld-cris/tls-gc-71.s b/ld/testsuite/ld-cris/tls-gc-71.s
new file mode 100644
index 0000000000..a4d6798000
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-gc-71.s
@@ -0,0 +1,2 @@
+ .hidden tlsdsofn
+ .include "tls-ld-4.s"
diff --git a/ld/testsuite/ld-cris/tls-gc-75.d b/ld/testsuite/ld-cris/tls-gc-75.d
new file mode 100644
index 0000000000..de387dbe2d
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-gc-75.d
@@ -0,0 +1,36 @@
+#source: start1.s
+#source: tls-x.s
+#source: tls-gd-2.s
+#source: tls-ie-10.s
+#source: tls-gd-1.s
+#source: tls-ie-8.s
+#as: --pic --no-underscore --em=criself -I$srcdir/$subdir
+#ld: -m crislinux --gc-sections
+#objdump: -s -t -r -p
+
+# An executable with a R_CRIS_32_GOT_GD, a R_CRIS_16_GOT_GD, a
+# R_CRIS_32_GOT_TPREL and a R_CRIS_16_GOT_TPREL against the same
+# symbol, gc:ed. Check that we have proper NPTL/TLS markings and GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+80000 paddr 0x0+80000 align 2\*\*13
+ filesz 0x0+78 memsz 0x0+78 flags r-x
+ LOAD off 0x0+78 vaddr 0x0+82078 paddr 0x0+82078 align 2\*\*13
+ filesz 0x0+c memsz 0x0+c flags rw-
+private flags = 0:
+
+SYMBOL TABLE:
+0+80074 l d .text 0+ .text
+0+82078 l d .got 0+ .got
+0+82078 l O .got 0+ .hidden _GLOBAL_OFFSET_TABLE_
+0+80074 g .text 0+ _start
+0+82084 g \*ABS\* 0+ __bss_start
+0+82084 g \*ABS\* 0+ _edata
+0+820a0 g \*ABS\* 0+ _end
+
+Contents of section .text:
+ 80074 41b20+ .*
+Contents of section .got:
+ 82078 0+ 0+ 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-gc-76.d b/ld/testsuite/ld-cris/tls-gc-76.d
new file mode 100644
index 0000000000..49a2dda446
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-gc-76.d
@@ -0,0 +1,38 @@
+#as: --pic --no-underscore --em=criself -I$srcdir/$subdir
+#ld: -m crislinux --gc-sections -u gc76fn
+#source: start1.s
+#source: tls-gc-76.s
+#source: tls-hx.s
+#objdump: -s -t -r -p
+
+# Executable with a single R_CRIS_32_DTPREL, gc:ed away.
+# A GOT reference through a local symbol to a variable survives gc.
+
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+80000 paddr 0x0+80000 align 2\*\*13
+ filesz 0x0+80 memsz 0x0+80 flags r-x
+ LOAD off 0x0+80 vaddr 0x0+82080 paddr 0x0+82080 align 2\*\*13
+ filesz 0x0+14 memsz 0x0+14 flags rw-
+private flags = 0:
+
+SYMBOL TABLE:
+0+80074 l d .text 0+ .text
+0+82080 l d .got 0+ .got
+0+82090 l d .data 0+ .data
+0+82090 l O .data 0+4 gc76var
+0+82080 l O .got 0+ .hidden _GLOBAL_OFFSET_TABLE_
+0+80074 g .text 0+ _start
+0+82094 g \*ABS\* 0+ __bss_start
+0+82094 g \*ABS\* 0+ _edata
+0+820a0 g \*ABS\* 0+ _end
+0+80078 g F .text 0+6 gc76fn
+
+Contents of section .text:
+ 80074 41b20+ 6fae0c00 0+ .*
+Contents of section .got:
+ 82080 0+ 0+ 0+ 90200800 .*
+Contents of section .data:
+ 82090 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-gc-76.s b/ld/testsuite/ld-cris/tls-gc-76.s
new file mode 100644
index 0000000000..980defd4ed
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-gc-76.s
@@ -0,0 +1,23 @@
+ .text
+ .global gc76fn
+ .type gc76fn,@function
+gc76fn:
+ move.d gc76var:GOT,$r10
+.Lfe:
+ .size gc76fn,.Lfe-gc76fn
+
+ .data
+ .type gc76var,@object
+ .size gc76var,4
+gc76var:
+ .dword 0
+
+ .section .text.2,"ax"
+ .global tlsdsofn
+ .type tlsdsofn,@function
+ .p2align 1
+tlsdsofn:
+ move.d x:DTPREL,$r10
+ move.d x:DTPREL,$r10
+.Lfe2:
+ .size tlsdsofn,.Lfe2-tlsdsofn
diff --git a/ld/testsuite/ld-cris/tls-gd-1.d b/ld/testsuite/ld-cris/tls-gd-1.d
new file mode 100644
index 0000000000..25de32d0f1
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-gd-1.d
@@ -0,0 +1,54 @@
+#as: --pic --no-underscore --em=criself
+#ld: --shared -m crislinux
+#source: tls-gd-1.s
+#source: tls128.s
+#source: tls-x.s
+#objdump: -s -t -R -p -T
+
+# DSO with a single R_CRIS_16_GOT_GD. Check that we have proper
+# NPTL/TLS markings and GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+ paddr 0x0+ align 2\*\*13
+ filesz 0x0+1a0 memsz 0x0+1a0 flags r-x
+ LOAD off 0x0+1a0 vaddr 0x0+21a0 paddr 0x0+21a0 align 2\*\*13
+ filesz 0x0+108 memsz 0x0+108 flags rw-
+ DYNAMIC off 0x0+224 vaddr 0x0+2224 paddr 0x0+2224 align 2\*\*2
+ filesz 0x0+70 memsz 0x0+70 flags rw-
+ TLS off 0x0+1a0 vaddr 0x0+21a0 paddr 0x0+21a0 align 2\*\*2
+ filesz 0x0+84 memsz 0x0+84 flags r--
+
+Dynamic Section:
+ HASH 0x0+b4
+ STRTAB 0x0+168
+ SYMTAB 0x0+e8
+ STRSZ 0x0+25
+ SYMENT 0x0+10
+ RELA 0x0+190
+ RELASZ 0x0+c
+ RELAENT 0x0+c
+private flags = 0:
+
+SYMBOL TABLE:
+#...
+0+80 g \.tdata 0+4 x
+#...
+DYNAMIC SYMBOL TABLE:
+#...
+0+80 g D \.tdata 0+4 x
+#...
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+22a0 R_CRIS_DTP x
+
+Contents of section \.hash:
+#...
+Contents of section \.text:
+ 019c 5fae0c00 .*
+#...
+Contents of section \.got:
+ 2294 24220+ 0+ 0+ 0+ .*
+ 22a4 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-gd-1.s b/ld/testsuite/ld-cris/tls-gd-1.s
new file mode 100644
index 0000000000..cd3f021060
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-gd-1.s
@@ -0,0 +1,8 @@
+ .text
+ .global tlsdsofn0
+ .type tlsdsofn0,@function
+ .p2align 1
+tlsdsofn0:
+ move.w x:GDGOTREL16,$r10
+.Lfe:
+ .size tlsdsofn0,.Lfe-tlsdsofn0
diff --git a/ld/testsuite/ld-cris/tls-gd-1h.d b/ld/testsuite/ld-cris/tls-gd-1h.d
new file mode 100644
index 0000000000..9e8fab3881
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-gd-1h.d
@@ -0,0 +1,50 @@
+#as: --pic --no-underscore --em=criself
+#ld: --shared -m crislinux
+#source: tls-gd-1.s
+#source: tls128g.s
+#source: tls-hx.s
+#objdump: -s -t -R -p
+
+# DSO with a single R_CRIS_16_GOT_GD against a hidden symbol. Check
+# that we have proper NPTL/TLS markings and GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+ paddr 0x0+ align 2\*\*13
+ filesz 0x0+1a4 memsz 0x0+1a4 flags r-x
+ LOAD off 0x0+1a4 vaddr 0x0+21a4 paddr 0x0+21a4 align 2\*\*13
+ filesz 0x0+108 memsz 0x0+108 flags rw-
+ DYNAMIC off 0x0+228 vaddr 0x0+2228 paddr 0x0+2228 align 2\*\*2
+ filesz 0x0+70 memsz 0x0+70 flags rw-
+ TLS off 0x0+1a4 vaddr 0x0+21a4 paddr 0x0+21a4 align 2\*\*2
+ filesz 0x0+84 memsz 0x0+84 flags r--
+
+Dynamic Section:
+ HASH 0x0+b4
+ STRTAB 0x0+168
+ SYMTAB 0x0+e8
+ STRSZ 0x0+2a
+ SYMENT 0x0+10
+ RELA 0x0+194
+ RELASZ 0x0+c
+ RELAENT 0x0+c
+private flags = 0:
+
+SYMBOL TABLE:
+#...
+0+80 l \.tdata 0+4 \.hidden x
+#...
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+22a4 R_CRIS_DTP \*ABS\*\+0x0+80
+
+Contents of section \.hash:
+#...
+Contents of section \.text:
+ 01a0 5fae0c00 .*
+#...
+Contents of section \.got:
+ 2298 28220+ 0+ 0+ 0+ .*
+ 22a8 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-gd-2.d b/ld/testsuite/ld-cris/tls-gd-2.d
new file mode 100644
index 0000000000..2f2546e6b6
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-gd-2.d
@@ -0,0 +1,54 @@
+#as: --pic --no-underscore --em=criself
+#ld: --shared -m crislinux
+#source: tls-gd-2.s
+#source: tls128g.s
+#source: tls-x.s
+#objdump: -s -t -R -p -T
+
+# DSO with a single R_CRIS_32_GOT_GD. Check that we have proper
+# NPTL/TLS markings and GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+ paddr 0x0+ align 2\*\*13
+ filesz 0x0+1bc memsz 0x0+1bc flags r-x
+ LOAD off 0x0+1bc vaddr 0x0+21bc paddr 0x0+21bc align 2\*\*13
+ filesz 0x0+108 memsz 0x0+108 flags rw-
+ DYNAMIC off 0x0+240 vaddr 0x0+2240 paddr 0x0+2240 align 2\*\*2
+ filesz 0x0+70 memsz 0x0+70 flags rw-
+ TLS off 0x0+1bc vaddr 0x0+21bc paddr 0x0+21bc align 2\*\*2
+ filesz 0x0+84 memsz 0x0+84 flags r--
+
+Dynamic Section:
+ HASH 0x0+b4
+ STRTAB 0x0+17c
+ SYMTAB 0x0+ec
+ STRSZ 0x0+2c
+ SYMENT 0x0+10
+ RELA 0x0+1a8
+ RELASZ 0x0+c
+ RELAENT 0x0+c
+private flags = 0:
+
+SYMBOL TABLE:
+#...
+0+80 g \.tdata 0+4 x
+#...
+DYNAMIC SYMBOL TABLE:
+#...
+0+80 g D \.tdata 0+4 x
+#...
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+22bc R_CRIS_DTP x
+
+Contents of section \.hash:
+#...
+Contents of section \.text:
+ 01b4 6fae0c00 00000000 .*
+#...
+Contents of section \.got:
+ 22b0 40220+ 0+ 0+ 0+ .*
+ 22c0 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-gd-2.s b/ld/testsuite/ld-cris/tls-gd-2.s
new file mode 100644
index 0000000000..07e8cf51b9
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-gd-2.s
@@ -0,0 +1,9 @@
+ .text
+ .global tlsdsofn2
+ .type tlsdsofn2,@function
+ .p2align 1
+tlsdsofn2:
+ move.d x:GDGOTREL,$r10
+.Lfe2:
+ .size tlsdsofn2,.Lfe2-tlsdsofn2
+
diff --git a/ld/testsuite/ld-cris/tls-gd-2h.d b/ld/testsuite/ld-cris/tls-gd-2h.d
new file mode 100644
index 0000000000..ed2803c21a
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-gd-2h.d
@@ -0,0 +1,50 @@
+#as: --pic --no-underscore --em=criself
+#ld: --shared -m crislinux
+#source: tls-gd-2.s
+#source: tls128g.s
+#source: tls-hx.s
+#objdump: -s -t -R -p
+
+# DSO with a single R_CRIS_32_GOT_GD against a hidden symbol. Check
+# that we have proper NPTL/TLS markings and GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+ paddr 0x0+ align 2\*\*13
+ filesz 0x0+1a8 memsz 0x0+1a8 flags r-x
+ LOAD off 0x0+1a8 vaddr 0x0+21a8 paddr 0x0+21a8 align 2\*\*13
+ filesz 0x0+108 memsz 0x0+108 flags rw-
+ DYNAMIC off 0x0+22c vaddr 0x0+222c paddr 0x0+222c align 2\*\*2
+ filesz 0x0+70 memsz 0x0+70 flags rw-
+ TLS off 0x0+1a8 vaddr 0x0+21a8 paddr 0x0+21a8 align 2\*\*2
+ filesz 0x0+84 memsz 0x0+84 flags r--
+
+Dynamic Section:
+ HASH 0x0+b4
+ STRTAB 0x0+168
+ SYMTAB 0x0+e8
+ STRSZ 0x0+2a
+ SYMENT 0x0+10
+ RELA 0x0+194
+ RELASZ 0x0+c
+ RELAENT 0x0+c
+private flags = 0:
+
+SYMBOL TABLE:
+#...
+0+80 l \.tdata 0+4 \.hidden x
+#...
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+22a8 R_CRIS_DTP \*ABS\*\+0x0+80
+
+Contents of section \.hash:
+#...
+Contents of section \.text:
+ 01a0 6fae0c00 00000000 .*
+#...
+Contents of section \.got:
+ 229c 2c220+ 0+ 0+ 0+ .*
+ 22ac 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-gd-3.d b/ld/testsuite/ld-cris/tls-gd-3.d
new file mode 100644
index 0000000000..b2de85103b
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-gd-3.d
@@ -0,0 +1,39 @@
+#source: start1.s
+#source: tls128.s
+#source: tls-gd-3.s
+#source: tls-x.s
+#as: --no-underscore --em=criself
+#ld: -m crislinux
+#objdump: -d -s -t -r -p
+
+# Check that we have proper NPTL/TLS markings and GOT for an
+# executable with a single R_CRIS_32_GD.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off 0x0+a0 vaddr 0x0+820a0 paddr 0x0+820a0 align 2\*\*2
+ filesz 0x0+84 memsz 0x0+84 flags r--
+private flags = 0:
+#...
+SYMBOL TABLE:
+#...
+0+80 g \.tdata 0+4 x
+#...
+Contents of section \.text:
+#...
+Contents of section \.tdata:
+#...
+Contents of section \.got:
+ 82124 00000000 00000000 00000000 01000000 .*
+ 82134 80000000 .*
+
+Disassembly of section \.text:
+
+00080094 <_start>:
+ 80094: 41b2 moveq 1,\$r11
+#...
+00080098 <tlsfn>:
+ 80098: 6fae 3021 0800 move\.d [^>]+>,\$r10
+#...
diff --git a/ld/testsuite/ld-cris/tls-gd-3.s b/ld/testsuite/ld-cris/tls-gd-3.s
new file mode 100644
index 0000000000..c427a4532b
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-gd-3.s
@@ -0,0 +1,8 @@
+ .text
+ .global tlsfn
+ .type tlsfn,@function
+ .p2align 1
+tlsfn:
+ move.d x:GD,$r10
+.Lfe1:
+ .size tlsfn,.Lfe1-tlsfn
diff --git a/ld/testsuite/ld-cris/tls-gd-3h.d b/ld/testsuite/ld-cris/tls-gd-3h.d
new file mode 100644
index 0000000000..78f109da8f
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-gd-3h.d
@@ -0,0 +1,39 @@
+#source: start1.s
+#source: tls128.s
+#source: tls-gd-3.s
+#source: tls-hx.s
+#as: --no-underscore --em=criself
+#ld: -m crislinux
+#objdump: -d -s -t -r -p
+
+# Check that we have proper NPTL/TLS markings and GOT for an
+# executable with a single R_CRIS_32_GD against a hidden symbol.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off 0x0+a0 vaddr 0x0+820a0 paddr 0x0+820a0 align 2\*\*2
+ filesz 0x0+84 memsz 0x0+84 flags r--
+private flags = 0:
+#...
+SYMBOL TABLE:
+#...
+0+80 g \.tdata 0+4 \.hidden x
+#...
+Contents of section \.text:
+#...
+Contents of section \.tdata:
+#...
+Contents of section \.got:
+ 82124 00000000 00000000 00000000 01000000 .*
+ 82134 80000000 .*
+
+Disassembly of section \.text:
+
+00080094 <_start>:
+ 80094: 41b2 moveq 1,\$r11
+#...
+00080098 <tlsfn>:
+ 80098: 6fae 3021 0800 move\.d [^>]+>,\$r10
+#...
diff --git a/ld/testsuite/ld-cris/tls-gdgotrelm.s b/ld/testsuite/ld-cris/tls-gdgotrelm.s
new file mode 100644
index 0000000000..50310eaa9b
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-gdgotrelm.s
@@ -0,0 +1,28 @@
+ .text
+
+ .ifndef r
+ .set r,1
+ .endif
+
+ .macro doit
+ .global tlsdsofngdgotrelm\@
+ .type tlsdsofngdgotrelm\@,@function
+ .p2align 1
+tlsdsofngdgotrelm\@:
+ move.w x\@:GDGOTREL16,$r10
+.Lfe\@:
+ .size tlsdsofngdgotrelm\@,.Lfe\@-tlsdsofngdgotrelm\@
+
+ .globl x\@
+ .section .tdata,"awT",@progbits
+ .p2align 0
+ .type x\@, @object
+ .size x\@, 1
+x\@:
+ .byte 40
+ .previous
+ .endm
+
+ .rept r
+ doit
+ .endr
diff --git a/ld/testsuite/ld-cris/tls-global-74.d b/ld/testsuite/ld-cris/tls-global-74.d
new file mode 100644
index 0000000000..964246ef8a
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-global-74.d
@@ -0,0 +1,28 @@
+#source: start1.s
+#source: tls-x.s
+#source: tls-gd-2.s
+#source: tls-ie-10.s
+#source: tls-gd-1.s
+#source: tls-ie-8.s
+#as: --pic --no-underscore --em=criself -I$srcdir/$subdir
+#ld: -m crislinux
+#objdump: -s -t -r -p
+
+# An executable with a R_CRIS_32_GOT_GD, a R_CRIS_16_GOT_GD, a
+# R_CRIS_32_GOT_TPREL and a R_CRIS_16_GOT_TPREL against the same
+# symbol. Check that we have proper NPTL/TLS markings and GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off .*
+ filesz 0x0+4 memsz 0x0+4 flags r--
+#...
+Contents of section .text:
+ 80094 41b20000 6fae1000 0+ 6fae0c0+ .*
+ 800a4 0+ 5fae1000 5fae0c00 .*
+#...
+Contents of section \.got:
+ 820b4 0+ 0+ 0+ 0+ .*
+ 820c4 010+ 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-gottprelm.s b/ld/testsuite/ld-cris/tls-gottprelm.s
new file mode 100644
index 0000000000..2853b314fd
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-gottprelm.s
@@ -0,0 +1,28 @@
+ .text
+
+ .ifndef r
+ .set r,1
+ .endif
+
+ .macro doit
+ .global tlsdsofngottprelm\@
+ .type tlsdsofngottprelm\@,@function
+ .p2align 1
+tlsdsofngottprelm\@:
+ move.w x\@:TPOFFGOT16,$r10
+.Lfe\@:
+ .size tlsdsofngottprelm\@,.Lfe\@-tlsdsofngottprelm\@
+
+ .globl x\@
+ .section .tdata,"awT",@progbits
+ .p2align 0
+ .type x\@, @object
+ .size x\@, 1
+x\@:
+ .byte 40
+ .previous
+ .endm
+
+ .rept r
+ doit
+ .endr
diff --git a/ld/testsuite/ld-cris/tls-hx.s b/ld/testsuite/ld-cris/tls-hx.s
new file mode 100644
index 0000000000..8e83164758
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-hx.s
@@ -0,0 +1,8 @@
+ .hidden x
+ .globl x
+ .section .tdata,"awT",@progbits
+ .p2align 2
+ .type x, @object
+ .size x, 4
+x:
+ .long 40
diff --git a/ld/testsuite/ld-cris/tls-hx1x2.s b/ld/testsuite/ld-cris/tls-hx1x2.s
new file mode 100644
index 0000000000..1964504d55
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-hx1x2.s
@@ -0,0 +1,15 @@
+ .hidden x1
+ .globl x1
+ .section .tdata,"awT",@progbits
+ .p2align 2
+ .type x1, @object
+ .size x1, 4
+x1:
+ .long 41
+ .hidden x2
+ .globl x2
+ .p2align 2
+ .type x2, @object
+ .size x2, 4
+x2:
+ .long 42
diff --git a/ld/testsuite/ld-cris/tls-ie-10.d b/ld/testsuite/ld-cris/tls-ie-10.d
new file mode 100644
index 0000000000..869173c343
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ie-10.d
@@ -0,0 +1,54 @@
+#as: --pic --no-underscore --em=criself
+#ld: --shared -m crislinux
+#source: tls-ie-10.s
+#source: tls128g.s
+#source: tls-x.s
+#objdump: -s -t -R -p -T
+
+# DSO with a single R_CRIS_32_GOT_TPREL. Check that we have proper
+# NPTL/TLS markings and GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+ paddr 0x0+ align 2\*\*13
+ filesz 0x0+1c0 memsz 0x0+1c0 flags r-x
+ LOAD off 0x0+1c0 vaddr 0x0+21c0 paddr 0x0+21c0 align 2\*\*13
+ filesz 0x0+10c memsz 0x0+10c flags rw-
+ DYNAMIC off 0x0+244 vaddr 0x0+2244 paddr 0x0+2244 align 2\*\*2
+ filesz 0x0+78 memsz 0x0+78 flags rw-
+ TLS off 0x0+1c0 vaddr 0x0+21c0 paddr 0x0+21c0 align 2\*\*2
+ filesz 0x0+84 memsz 0x0+84 flags r--
+
+Dynamic Section:
+ HASH 0x0+b4
+ STRTAB 0x0+17c
+ SYMTAB 0x0+ec
+ STRSZ 0x0+2d
+ SYMENT 0x0+10
+ RELA 0x0+1ac
+ RELASZ 0x0+c
+ RELAENT 0x0+c
+ FLAGS 0x0+10
+private flags = 0:
+
+SYMBOL TABLE:
+#...
+0+80 g \.tdata 0+4 x
+#...
+DYNAMIC SYMBOL TABLE:
+#...
+0+80 g D \.tdata 0+4 x
+#...
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+22c8 R_CRIS_32_TPREL x
+
+Contents of section \.hash:
+#...
+Contents of section \.text:
+ 01b8 6fae0c00 00000000 .*
+#...
+Contents of section \.got:
+ 22bc 44220+ 0+ 0+ 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-ie-10.s b/ld/testsuite/ld-cris/tls-ie-10.s
new file mode 100644
index 0000000000..a8667cd7a5
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ie-10.s
@@ -0,0 +1,8 @@
+ .text
+ .global tlsdsofn10
+ .type tlsdsofn10,@function
+ .p2align 1
+tlsdsofn10:
+ move.d x:TPOFFGOT,$r10
+.Lfe10:
+ .size tlsdsofn10,.Lfe10-tlsdsofn10
diff --git a/ld/testsuite/ld-cris/tls-ie-11.d b/ld/testsuite/ld-cris/tls-ie-11.d
new file mode 100644
index 0000000000..d326fbe739
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ie-11.d
@@ -0,0 +1,60 @@
+#as: --pic --no-underscore --em=criself
+#ld: --shared -m crislinux
+#source: tls-ie-11.s
+#source: tls128g.s
+#source: tls-x1x2.s
+#objdump: -s -t -R -p -T
+
+# DSO with two R_CRIS_32_GOT_TPREL against different symbols. Check
+# that we have proper NPTL/TLS markings and GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+ paddr 0x0+ align 2\*\*13
+ filesz 0x0+1e4 memsz 0x0+1e4 flags r-x
+ LOAD off 0x0+1e4 vaddr 0x0+21e4 paddr 0x0+21e4 align 2\*\*13
+ filesz 0x0+114 memsz 0x0+114 flags rw-
+ DYNAMIC off 0x0+26c vaddr 0x0+226c paddr 0x0+226c align 2\*\*2
+ filesz 0x0+78 memsz 0x0+78 flags rw-
+ TLS off 0x0+1e4 vaddr 0x0+21e4 paddr 0x0+21e4 align 2\*\*2
+ filesz 0x0+88 memsz 0x0+88 flags r--
+
+Dynamic Section:
+ HASH 0x0+b4
+ STRTAB 0x0+190
+ SYMTAB 0x0+f0
+ STRSZ 0x0+2f
+ SYMENT 0x0+10
+ RELA 0x0+1c0
+ RELASZ 0x0+18
+ RELAENT 0x0+c
+ FLAGS 0x0+10
+private flags = 0:
+
+SYMBOL TABLE:
+#...
+0+84 g \.tdata 0+4 x2
+#...
+0+80 g \.tdata 0+4 x1
+#...
+DYNAMIC SYMBOL TABLE:
+#...
+0+84 g D \.tdata 0+4 x2
+#...
+0+80 g D \.tdata 0+4 x1
+#...
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+22f0 R_CRIS_32_TPREL x2
+0+22f4 R_CRIS_32_TPREL x1
+
+Contents of section \.hash:
+#...
+Contents of section \.text:
+ 01d8 6fae1000 00006fbe 0c000000 .*
+#...
+Contents of section \.got:
+ 22e4 6c220+ 0+ 0+ 0+ .*
+ 22f4 00000000 .*
diff --git a/ld/testsuite/ld-cris/tls-ie-11.s b/ld/testsuite/ld-cris/tls-ie-11.s
new file mode 100644
index 0000000000..236bdbb48b
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ie-11.s
@@ -0,0 +1,9 @@
+ .text
+ .global tlsdsofn
+ .type tlsdsofn,@function
+ .p2align 1
+tlsdsofn:
+ move.d x1:TPOFFGOT,$r10
+ move.d x2:TPOFFGOT,$r11
+.Lfe11:
+ .size tlsdsofn,.Lfe11-tlsdsofn
diff --git a/ld/testsuite/ld-cris/tls-ie-8.d b/ld/testsuite/ld-cris/tls-ie-8.d
new file mode 100644
index 0000000000..3c7769b64e
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ie-8.d
@@ -0,0 +1,54 @@
+#as: --pic --no-underscore --em=criself
+#ld: --shared -m crislinux
+#source: tls-ie-8.s
+#source: tls128g.s
+#source: tls-x.s
+#objdump: -s -t -R -p -T
+
+# DSO with a single R_CRIS_16_GOT_TPREL. Check that we have proper
+# NPTL/TLS markings and GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+ paddr 0x0+ align 2\*\*13
+ filesz 0x0+1b8 memsz 0x0+1b8 flags r-x
+ LOAD off 0x0+1b8 vaddr 0x0+21b8 paddr 0x0+21b8 align 2\*\*13
+ filesz 0x0+10c memsz 0x0+10c flags rw-
+ DYNAMIC off 0x0+23c vaddr 0x0+223c paddr 0x0+223c align 2\*\*2
+ filesz 0x0+78 memsz 0x0+78 flags rw-
+ TLS off 0x0+1b8 vaddr 0x0+21b8 paddr 0x0+21b8 align 2\*\*2
+ filesz 0x0+84 memsz 0x0+84 flags r--
+
+Dynamic Section:
+ HASH 0x0+b4
+ STRTAB 0x0+17c
+ SYMTAB 0x0+ec
+ STRSZ 0x0+2b
+ SYMENT 0x0+10
+ RELA 0x0+1a8
+ RELASZ 0x0+c
+ RELAENT 0x0+c
+ FLAGS 0x0+10
+private flags = 0:
+
+SYMBOL TABLE:
+#...
+0+80 g \.tdata 0+4 x
+#...
+DYNAMIC SYMBOL TABLE:
+#...
+0+80 g D \.tdata 0+4 x
+#...
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+22c0 R_CRIS_32_TPREL x
+
+Contents of section \.hash:
+#...
+Contents of section \.text:
+ 01b4 5fae0c00 .*
+#...
+Contents of section \.got:
+ 22b4 3c220+ 0+ 0+ 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-ie-8.s b/ld/testsuite/ld-cris/tls-ie-8.s
new file mode 100644
index 0000000000..ed95939a88
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ie-8.s
@@ -0,0 +1,8 @@
+ .text
+ .global tlsdsofn
+ .type tlsdsofn,@function
+ .p2align 1
+tlsdsofn:
+ move.w x:TPOFFGOT16,$r10
+.Lfe8:
+ .size tlsdsofn,.Lfe8-tlsdsofn
diff --git a/ld/testsuite/ld-cris/tls-ie-9.d b/ld/testsuite/ld-cris/tls-ie-9.d
new file mode 100644
index 0000000000..673ae4fee8
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ie-9.d
@@ -0,0 +1,60 @@
+#as: --pic --no-underscore --em=criself
+#ld: --shared -m crislinux
+#source: tls-ie-9.s
+#source: tls128g.s
+#source: tls-x1x2.s
+#objdump: -s -t -R -p -T
+
+# DSO with two R_CRIS_16_GOT_TPREL against different symbols. Check
+# that we have proper NPTL/TLS markings and GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+ paddr 0x0+ align 2\*\*13
+ filesz 0x0+1e0 memsz 0x0+1e0 flags r-x
+ LOAD off 0x0+1e0 vaddr 0x0+21e0 paddr 0x0+21e0 align 2\*\*13
+ filesz 0x0+114 memsz 0x0+114 flags rw-
+ DYNAMIC off 0x0+268 vaddr 0x0+2268 paddr 0x0+2268 align 2\*\*2
+ filesz 0x0+78 memsz 0x0+78 flags rw-
+ TLS off 0x0+1e0 vaddr 0x0+21e0 paddr 0x0+21e0 align 2\*\*2
+ filesz 0x0+88 memsz 0x0+88 flags r--
+
+Dynamic Section:
+ HASH 0x0+b4
+ STRTAB 0x0+190
+ SYMTAB 0x0+f0
+ STRSZ 0x0+30
+ SYMENT 0x0+10
+ RELA 0x0+1c0
+ RELASZ 0x0+18
+ RELAENT 0x0+c
+ FLAGS 0x0+10
+private flags = 0:
+
+SYMBOL TABLE:
+#...
+0+84 g \.tdata 0+4 x2
+#...
+0+80 g \.tdata 0+4 x1
+#...
+DYNAMIC SYMBOL TABLE:
+#...
+0+84 g D \.tdata 0+4 x2
+#...
+0+80 g D \.tdata 0+4 x1
+#...
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+22ec R_CRIS_32_TPREL x2
+0+22f0 R_CRIS_32_TPREL x1
+
+Contents of section \.hash:
+#...
+Contents of section \.text:
+ 01d8 5fae1000 5fbe0c00 .*
+#...
+Contents of section \.got:
+ 22e0 68220+ 0+ 0+ 0+ .*
+ 22f0 00000000 .*
diff --git a/ld/testsuite/ld-cris/tls-ie-9.s b/ld/testsuite/ld-cris/tls-ie-9.s
new file mode 100644
index 0000000000..69cecd7f62
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ie-9.s
@@ -0,0 +1,9 @@
+ .text
+ .global tlsdsofn9
+ .type tlsdsofn9,@function
+ .p2align 1
+tlsdsofn9:
+ move.w x1:TPOFFGOT16,$r10
+ move.w x2:TPOFFGOT16,$r11
+.Lfe9:
+ .size tlsdsofn9,.Lfe9-tlsdsofn9
diff --git a/ld/testsuite/ld-cris/tls-ld-4.d b/ld/testsuite/ld-cris/tls-ld-4.d
new file mode 100644
index 0000000000..b87d1d48c7
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ld-4.d
@@ -0,0 +1,50 @@
+#as: --pic --no-underscore --em=criself
+#ld: --shared -m crislinux
+#source: tls-ld-4.s
+#source: tls128g.s
+#source: tls-hx.s
+#objdump: -s -t -R -p
+
+# DSO with a single R_CRIS_16_DTPREL against a hidden symbol. Check
+# that we have proper NPTL/TLS markings and GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+ paddr 0x0+ align 2\*\*13
+ filesz 0x0+1a4 memsz 0x0+1a4 flags r-x
+ LOAD off 0x0+1a4 vaddr 0x0+21a4 paddr 0x0+21a4 align 2\*\*13
+ filesz 0x0+108 memsz 0x0+108 flags rw-
+ DYNAMIC off 0x0+228 vaddr 0x0+2228 paddr 0x0+2228 align 2\*\*2
+ filesz 0x0+70 memsz 0x0+70 flags rw-
+ TLS off 0x0+1a4 vaddr 0x0+21a4 paddr 0x0+21a4 align 2\*\*2
+ filesz 0x0+84 memsz 0x0+84 flags r--
+
+Dynamic Section:
+ HASH 0x0+b4
+ STRTAB 0x0+168
+ SYMTAB 0x0+e8
+ STRSZ 0x0+29
+ SYMENT 0x0+10
+ RELA 0x0+194
+ RELASZ 0x0+c
+ RELAENT 0x0+c
+private flags = 0:
+
+SYMBOL TABLE:
+#...
+0+80 l \.tdata 0+4 \.hidden x
+#...
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+22a4 R_CRIS_DTPMOD \*ABS\*
+
+Contents of section \.hash:
+#...
+Contents of section \.text:
+ 01a0 5fae8000 .*
+#...
+Contents of section \.got:
+ 2298 28220+ 0+ 0+ 0+ .*
+ 22a8 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-ld-4.s b/ld/testsuite/ld-cris/tls-ld-4.s
new file mode 100644
index 0000000000..7990689884
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ld-4.s
@@ -0,0 +1,8 @@
+ .text
+ .global tlsdsofn
+ .type tlsdsofn,@function
+ .p2align 1
+tlsdsofn:
+ move.w x:DTPREL16,$r10
+.Lfe1:
+ .size tlsdsofn,.Lfe1-tlsdsofn
diff --git a/ld/testsuite/ld-cris/tls-ld-5.d b/ld/testsuite/ld-cris/tls-ld-5.d
new file mode 100644
index 0000000000..756f1b0570
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ld-5.d
@@ -0,0 +1,51 @@
+#as: --pic --no-underscore --em=criself
+#ld: --shared -m crislinux
+#source: tls-ld-5.s
+#source: tls128g.s
+#source: tls-hx1x2.s
+#objdump: -s -t -R -p
+
+# DSO with two R_CRIS_16_DTPRELs against different hidden symbols.
+# Check that we have proper NPTL/TLS markings and GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+ paddr 0x0+ align 2\*\*13
+ filesz 0x0+1a8 memsz 0x0+1a8 flags r-x
+ LOAD off 0x0+1a8 vaddr 0x0+21a8 paddr 0x0+21a8 align 2\*\*13
+ filesz 0x0+10c memsz 0x0+10c flags rw-
+ DYNAMIC off 0x0+230 vaddr 0x0+2230 paddr 0x0+2230 align 2\*\*2
+ filesz 0x0+70 memsz 0x0+70 flags rw-
+ TLS off 0x0+1a8 vaddr 0x0+21a8 paddr 0x0+21a8 align 2\*\*2
+ filesz 0x0+88 memsz 0x0+88 flags r--
+
+Dynamic Section:
+ HASH 0x0+b4
+ STRTAB 0x0+168
+ SYMTAB 0x0+e8
+ STRSZ 0x0+29
+ SYMENT 0x0+10
+ RELA 0x0+194
+ RELASZ 0x0+c
+ RELAENT 0x0+c
+private flags = 0:
+
+SYMBOL TABLE:
+#...
+0+84 l \.tdata 0+4 \.hidden x2
+0+80 l \.tdata 0+4 \.hidden x1
+#...
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+22ac R_CRIS_DTPMOD \*ABS\*
+
+Contents of section \.hash:
+#...
+Contents of section \.text:
+ 01a0 5fae8000 5fbe8400 .*
+#...
+Contents of section \.got:
+ 22a0 30220+ 0+ 0+ 0+ .*
+ 22b0 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-ld-5.s b/ld/testsuite/ld-cris/tls-ld-5.s
new file mode 100644
index 0000000000..910a79db45
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ld-5.s
@@ -0,0 +1,10 @@
+ .text
+ .global tlsdsofn
+ .type tlsdsofn,@function
+ .p2align 1
+tlsdsofn:
+ move.w x1:DTPREL16,$r10
+ move.w x2:DTPREL16,$r11
+.Lfe5:
+ .size tlsdsofn,.Lfe5-tlsdsofn
+
diff --git a/ld/testsuite/ld-cris/tls-ld-6.d b/ld/testsuite/ld-cris/tls-ld-6.d
new file mode 100644
index 0000000000..b178ad4c71
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ld-6.d
@@ -0,0 +1,50 @@
+#as: --pic --no-underscore --em=criself -I$srcdir/$subdir
+#ld: --shared -m crislinux
+#source: tls128g.s
+#source: tls-ld-6.s
+#source: tls-hx.s
+#objdump: -s -t -R -p
+
+# DSO with a single R_CRIS_32_DTPREL against a hidden symbol. Check
+# that we have proper NPTL/TLS markings and GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+ paddr 0x0+ align 2\*\*13
+ filesz 0x0+1a8 memsz 0x0+1a8 flags r-x
+ LOAD off 0x0+1a8 vaddr 0x0+21a8 paddr 0x0+21a8 align 2\*\*13
+ filesz 0x0+108 memsz 0x0+108 flags rw-
+ DYNAMIC off 0x0+22c vaddr 0x0+222c paddr 0x0+222c align 2\*\*2
+ filesz 0x0+70 memsz 0x0+70 flags rw-
+ TLS off 0x0+1a8 vaddr 0x0+21a8 paddr 0x0+21a8 align 2\*\*2
+ filesz 0x0+84 memsz 0x0+84 flags r--
+
+Dynamic Section:
+ HASH 0x0+b4
+ STRTAB 0x0+168
+ SYMTAB 0x0+e8
+ STRSZ 0x0+29
+ SYMENT 0x0+10
+ RELA 0x0+194
+ RELASZ 0x0+c
+ RELAENT 0x0+c
+private flags = 0:
+
+SYMBOL TABLE:
+#...
+0+80 l \.tdata 0+4 \.hidden x
+#...
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+22a8 R_CRIS_DTPMOD \*ABS\*
+
+Contents of section \.hash:
+#...
+Contents of section \.text:
+ 01a0 6fae8000 00000000 .*
+#...
+Contents of section \.got:
+ 229c 2c220+ 0+ 0+ 0+ .*
+ 22ac 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-ld-6.s b/ld/testsuite/ld-cris/tls-ld-6.s
new file mode 100644
index 0000000000..d0a98f6814
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ld-6.s
@@ -0,0 +1,8 @@
+ .text
+ .global tlsdsofn
+ .type tlsdsofn,@function
+ .p2align 1
+tlsdsofn:
+ move.d x:DTPREL,$r10
+.Lfe6:
+ .size tlsdsofn,.Lfe6-tlsdsofn
diff --git a/ld/testsuite/ld-cris/tls-ld-7.d b/ld/testsuite/ld-cris/tls-ld-7.d
new file mode 100644
index 0000000000..92fcb8842d
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ld-7.d
@@ -0,0 +1,51 @@
+#as: --pic --no-underscore --em=criself
+#ld: --shared -m crislinux
+#source: tls-ld-7.s
+#source: tls128g.s
+#source: tls-hx1x2.s
+#objdump: -s -t -R -p
+
+# DSO with two R_CRIS_32_DTPRELs against different hidden symbols.
+# Check that we have proper NPTL/TLS markings and GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+ paddr 0x0+ align 2\*\*13
+ filesz 0x0+1ac memsz 0x0+1ac flags r-x
+ LOAD off 0x0+1ac vaddr 0x0+21ac paddr 0x0+21ac align 2\*\*13
+ filesz 0x0+10c memsz 0x0+10c flags rw-
+ DYNAMIC off 0x0+234 vaddr 0x0+2234 paddr 0x0+2234 align 2\*\*2
+ filesz 0x0+70 memsz 0x0+70 flags rw-
+ TLS off 0x0+1ac vaddr 0x0+21ac paddr 0x0+21ac align 2\*\*2
+ filesz 0x0+88 memsz 0x0+88 flags r--
+
+Dynamic Section:
+ HASH 0x0+b4
+ STRTAB 0x0+168
+ SYMTAB 0x0+e8
+ STRSZ 0x0+29
+ SYMENT 0x0+10
+ RELA 0x0+194
+ RELASZ 0x0+c
+ RELAENT 0x0+c
+private flags = 0:
+
+SYMBOL TABLE:
+#...
+0+84 l \.tdata 0+4 \.hidden x2
+0+80 l \.tdata 0+4 \.hidden x1
+#...
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+22b0 R_CRIS_DTPMOD \*ABS\*
+
+Contents of section \.hash:
+#...
+Contents of section \.text:
+ 01a0 6fae80+ 0+6fbe 840+ .*
+#...
+Contents of section \.got:
+ 22a4 34220+ 0+ 0+ 0+ .*
+ 22b4 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-ld-7.s b/ld/testsuite/ld-cris/tls-ld-7.s
new file mode 100644
index 0000000000..c64c1db086
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ld-7.s
@@ -0,0 +1,9 @@
+ .text
+ .global tlsdsofn
+ .type tlsdsofn,@function
+ .p2align 1
+tlsdsofn:
+ move.d x1:DTPREL,$r10
+ move.d x2:DTPREL,$r11
+.Lfe7:
+ .size tlsdsofn,.Lfe7-tlsdsofn
diff --git a/ld/testsuite/ld-cris/tls-ldgd-14.d b/ld/testsuite/ld-cris/tls-ldgd-14.d
new file mode 100644
index 0000000000..3b101ada39
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ldgd-14.d
@@ -0,0 +1,71 @@
+#source: tls128g.s
+#source: tls-ld-5.s
+#source: tls-gd-1.s
+#source: tls-ldgd-14.s
+#source: tls-x.s
+#source: tls-z.s
+#source: tls-hx1x2.s
+#as: --pic --no-underscore --em=criself
+#ld: --shared -m crislinux
+#objdump: -s -t -R -p -T
+
+# Check that we have proper NPTL/TLS markings and GOT for two
+# R_CRIS_16_GOT_GD and two R_CRIS_16_DTPRELs against different
+# variables in a DSO.
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+ paddr 0x0+ align 2\*\*13
+ filesz 0x0+230 memsz 0x0+230 flags r-x
+ LOAD off 0x0+230 vaddr 0x0+2230 paddr 0x0+2230 align 2\*\*13
+ filesz 0x0+124 memsz 0x0+124 flags rw-
+ DYNAMIC off 0x0+2c0 vaddr 0x0+22c0 paddr 0x0+22c0 align 2\*\*2
+ filesz 0x0+70 memsz 0x0+70 flags rw-
+ TLS off 0x0+230 vaddr 0x0+2230 paddr 0x0+2230 align 2\*\*2
+ filesz 0x0+90 memsz 0x0+90 flags r--
+
+Dynamic Section:
+ HASH 0x0+b4
+ STRTAB 0x0+1b8
+ SYMTAB 0x0+f8
+ STRSZ 0x0+42
+ SYMENT 0x0+10
+ RELA 0x0+1fc
+ RELASZ 0x0+24
+ RELAENT 0x0+c
+private flags = 0:
+
+SYMBOL TABLE:
+#...
+0+8c l \.tdata 0+4 \.hidden x2
+#...
+0+88 l \.tdata 0+4 \.hidden x1
+#...
+0+80 g \.tdata 0+4 x
+#...
+0+84 g \.tdata 0+4 z
+#...
+DYNAMIC SYMBOL TABLE:
+#...
+0+80 g D \.tdata 0+4 x
+#...
+0+84 g D \.tdata 0+4 z
+#...
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+233c R_CRIS_DTPMOD \*ABS\*
+0+2344 R_CRIS_DTP x
+0+234c R_CRIS_DTP z
+
+Contents of section \.hash:
+#...
+Contents of section \.text:
+ 0220 5fae8800 5fbe8c00 5fae1400 5fae1c00 .*
+Contents of section .tdata:
+#...
+Contents of section \.got:
+ 2330 c0220+ 0+ 0+ 0+ .*
+ 2340 0+ 0+ 0+ 0+ .*
+ 2350 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-ldgd-14.s b/ld/testsuite/ld-cris/tls-ldgd-14.s
new file mode 100644
index 0000000000..3de8f87390
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ldgd-14.s
@@ -0,0 +1,8 @@
+ .text
+ .global tlsdsofn14
+ .type tlsdsofn14,@function
+ .p2align 1
+tlsdsofn14:
+ move.w z:GDGOTREL16,$r10
+.Lfe14:
+ .size tlsdsofn14,.Lfe14-tlsdsofn14
diff --git a/ld/testsuite/ld-cris/tls-ldgd-15.d b/ld/testsuite/ld-cris/tls-ldgd-15.d
new file mode 100644
index 0000000000..84d033f7d4
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ldgd-15.d
@@ -0,0 +1,72 @@
+#source: tls128g.s
+#source: tls-ld-7.s
+#source: tls-gd-2.s
+#source: tls-ldgd-15.s
+#source: tls-x.s
+#source: tls-z.s
+#source: tls-hx1x2.s
+#as: --pic --no-underscore --em=criself
+#ld: --shared -m crislinux
+#objdump: -s -t -R -p -T
+
+# Check that we have proper NPTL/TLS markings and GOT for two
+# R_CRIS_32_GOT_GD and two R_CRIS_32_DTPRELs against different
+# variables in a DSO.
+
+.*: file format elf32-cris
+
+Program Header:
+ LOAD off 0x0+ vaddr 0x0+ paddr 0x0+ align 2\*\*13
+ filesz 0x0+23c memsz 0x0+23c flags r-x
+ LOAD off 0x0+23c vaddr 0x0+223c paddr 0x0+223c align 2\*\*13
+ filesz 0x0+124 memsz 0x0+124 flags rw-
+ DYNAMIC off 0x0+2cc vaddr 0x0+22cc paddr 0x0+22cc align 2\*\*2
+ filesz 0x0+70 memsz 0x0+70 flags rw-
+ TLS off 0x0+23c vaddr 0x0+223c paddr 0x0+223c align 2\*\*2
+ filesz 0x0+90 memsz 0x0+90 flags r--
+
+Dynamic Section:
+ HASH 0x0+b4
+ STRTAB 0x0+1b8
+ SYMTAB 0x0+f8
+ STRSZ 0x0+42
+ SYMENT 0x0+10
+ RELA 0x0+1fc
+ RELASZ 0x0+24
+ RELAENT 0x0+c
+private flags = 0:
+
+SYMBOL TABLE:
+#...
+0+8c l \.tdata 0+4 \.hidden x2
+#...
+0+88 l \.tdata 0+4 \.hidden x1
+#...
+0+80 g \.tdata 0+4 x
+#...
+0+84 g \.tdata 0+4 z
+#...
+DYNAMIC SYMBOL TABLE:
+#...
+0+80 g D \.tdata 0+4 x
+#...
+0+84 g D \.tdata 0+4 z
+#...
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0+2348 R_CRIS_DTPMOD \*ABS\*
+0+2350 R_CRIS_DTP x
+0+2358 R_CRIS_DTP z
+
+Contents of section \.hash:
+#...
+Contents of section \.text:
+ 0220 6fae8800 00006fbe 8c000000 6fae1400 .*
+ 0230 0+ 6fae1c00 0+ .*
+Contents of section .tdata:
+#...
+Contents of section \.got:
+ 233c cc220+ 0+ 0+ 0+ .*
+ 234c 0+ 0+ 0+ 0+ .*
+ 235c 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-ldgd-15.s b/ld/testsuite/ld-cris/tls-ldgd-15.s
new file mode 100644
index 0000000000..2b552434d4
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ldgd-15.s
@@ -0,0 +1,9 @@
+ .text
+ .global tlsdsofn14
+ .type tlsdsofn14,@function
+ .p2align 1
+tlsdsofn14:
+ move.d z:GDGOTREL,$r10
+.Lfe15:
+ .size tlsdsofn14,.Lfe15-tlsdsofn14
+
diff --git a/ld/testsuite/ld-cris/tls-ldgde-14.d b/ld/testsuite/ld-cris/tls-ldgde-14.d
new file mode 100644
index 0000000000..87f73be7bb
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ldgde-14.d
@@ -0,0 +1,61 @@
+#source: start1.s
+#source: tls128.s
+#source: tls-ld-5.s
+#source: tls-gd-1.s
+#source: tls-ldgd-14.s
+#source: tls-x.s
+#source: tls-z.s
+#source: tls-hx1x2.s
+#as: --pic --no-underscore --em=criself
+#ld: -m crislinux
+#objdump: -d -s -h -t -r -p
+
+# Check that we have proper NPTL/TLS markings and GOT for two
+# R_CRIS_16_GOT_GD and two R_CRIS_16_DTPRELs against different
+# variables, for an executable.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off 0x0+a8 vaddr 0x0+820a8 paddr 0x0+820a8 align 2\*\*2
+ filesz 0x0+90 memsz 0x0+90 flags r--
+private flags = 0:
+#...
+ 1 .tdata .*
+ CONTENTS.*
+ 2 .got .*
+ CONTENTS.*
+SYMBOL TABLE:
+#...
+0+80 g \.tdata 0+4 x
+#...
+0+8c g .tdata 00000004 \.hidden x2
+#...
+0+84 g \.tdata 0+4 z
+#...
+0+88 g .tdata 00000004 \.hidden x1
+#...
+Contents of section \.text:
+#...
+Contents of section \.tdata:
+#...
+Contents of section \.got:
+ 82138 00000000 00000000 00000000 01000000 .*
+ 82148 00000000 01000000 80000000 01000000 .*
+ 82158 84000000 .*
+
+Disassembly of section \.text:
+
+00080094 <_start>:
+ 80094: 41b2 moveq 1,\$r11
+#...
+00080098 <tlsdsofn>:
+ 80098: 5fae 8800 move\.w 0x88,\$r10
+ 8009c: 5fbe 8c00 move\.w 0x8c,\$r11
+
+000800a0 <tlsdsofn0>:
+ 800a0: 5fae 1400 move\.w 0x14,\$r10
+
+000800a4 <tlsdsofn14>:
+ 800a4: 5fae 1c00 move\.w 0x1c,\$r10
diff --git a/ld/testsuite/ld-cris/tls-ldgde-15.d b/ld/testsuite/ld-cris/tls-ldgde-15.d
new file mode 100644
index 0000000000..ae563654d2
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ldgde-15.d
@@ -0,0 +1,61 @@
+#source: start1.s
+#source: tls128.s
+#source: tls-ld-7.s
+#source: tls-gd-2.s
+#source: tls-ldgd-15.s
+#source: tls-x.s
+#source: tls-z.s
+#source: tls-hx1x2.s
+#as: --pic --no-underscore --em=criself
+#ld: -m crislinux
+#objdump: -d -s -h -t -r -p
+
+# Check that we have proper NPTL/TLS markings and GOT for two
+# R_CRIS_32_GOT_GD and two R_CRIS_32_DTPRELs against different
+# variables, for an executable.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off 0x0+b4 vaddr 0x0+820b4 paddr 0x0+820b4 align 2\*\*2
+ filesz 0x0+90 memsz 0x0+90 flags r--
+private flags = 0:
+#...
+ 1 .tdata .*
+ CONTENTS.*
+ 2 .got .*
+ CONTENTS.*
+SYMBOL TABLE:
+#...
+0+80 g \.tdata 0+4 x
+#...
+0+8c g .tdata 00000004 \.hidden x2
+#...
+0+84 g \.tdata 0+4 z
+#...
+0+88 g .tdata 00000004 \.hidden x1
+#...
+Contents of section \.text:
+#...
+Contents of section \.tdata:
+#...
+Contents of section \.got:
+ 82144 00000000 00000000 00000000 01000000 .*
+ 82154 00000000 01000000 80000000 01000000 .*
+ 82164 84000000 .*
+
+Disassembly of section \.text:
+
+00080094 <_start>:
+ 80094: 41b2 moveq 1,\$r11
+#...
+00080098 <tlsdsofn>:
+ 80098: 6fae 8800 0000 move.d 88 <x1>,\$r10
+ 8009e: 6fbe 8c00 0000 move.d 8c <x2>,\$r11
+000800a4 <tlsdsofn2>:
+ 800a4: 6fae 1400 0000 move.d 14 <tls128\+0x14>,\$r10
+#...
+000800ac <tlsdsofn14>:
+ 800ac: 6fae 1c00 0000 move.d 1c <tls128\+0x1c>,\$r10
+#...
diff --git a/ld/testsuite/ld-cris/tls-ldgdex-14.d b/ld/testsuite/ld-cris/tls-ldgdex-14.d
new file mode 100644
index 0000000000..83d94a77eb
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ldgdex-14.d
@@ -0,0 +1,54 @@
+#source: start1.s
+#source: tls128.s
+#source: tls-ld-5.s
+#source: tls-gd-1.s
+#source: tls-ldgd-14.s
+#source: tls-hx1x2.s
+#as: --pic --no-underscore --em=criself
+#ld: -m crislinux tmpdir/tls-dso-xz-1.so
+#objdump: -s -h -t -T -R -r -p
+
+# Check that we have proper NPTL/TLS markings and GOT for two
+# R_CRIS_16_GOT_GD and two R_CRIS_16_DTPRELs against different
+# variables, for an executable, GD symbols defined elsewhere.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off .*
+ filesz 0x0+88 memsz 0x0+88 flags r--
+
+Dynamic Section:
+ NEEDED tmpdir/tls-dso-xz-1.so
+#...
+private flags = 0:
+#...
+ 8 .got .*
+ CONTENTS.*
+SYMBOL TABLE:
+#...
+0+ \*UND\* 0+ x
+#...
+0+ \*UND\* 0+ z
+#...
+DYNAMIC SYMBOL TABLE:
+0+ D \*UND\* 0+ x
+0+ D \*UND\* 0+ z
+#...
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0008230c R_CRIS_DTP x
+00082314 R_CRIS_DTP z
+
+Contents of section .interp:
+#...
+Contents of section \.text:
+ 801dc 41b20000 5fae8000 5fbe8400 5fae1400 .*
+ 801ec 5fae1c00 .*
+Contents of section \.tdata:
+#...
+Contents of section \.got:
+ 822f8 78220800 0+ 0+ 010+ .*
+ 82308 0+ 0+ 0+ 0+ .*
+ 82318 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-ldgdex-15.d b/ld/testsuite/ld-cris/tls-ldgdex-15.d
new file mode 100644
index 0000000000..fca739bf79
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ldgdex-15.d
@@ -0,0 +1,54 @@
+#source: start1.s
+#source: tls128.s
+#source: tls-ld-7.s
+#source: tls-gd-2.s
+#source: tls-ldgd-15.s
+#source: tls-hx1x2.s
+#as: --pic --no-underscore --em=criself
+#ld: -m crislinux tmpdir/tls-dso-xz-1.so
+#objdump: -s -h -t -T -R -r -p
+
+# Check that we have proper NPTL/TLS markings and GOT for two
+# R_CRIS_32_GOT_GD and two R_CRIS_32_DTPRELs against different
+# variables, for an executable, GD symbols defined elsewhere.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off .*
+ filesz 0x0+88 memsz 0x0+88 flags r--
+
+Dynamic Section:
+ NEEDED tmpdir/tls-dso-xz-1.so
+#...
+private flags = 0:
+#...
+ 8 .got .*
+ CONTENTS.*
+SYMBOL TABLE:
+#...
+0+ \*UND\* 0+ x
+#...
+0+ \*UND\* 0+ z
+#...
+DYNAMIC SYMBOL TABLE:
+0+ D \*UND\* 0+ x
+0+ D \*UND\* 0+ z
+#...
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+00082318 R_CRIS_DTP x
+00082320 R_CRIS_DTP z
+
+Contents of section \.interp:
+#...
+Contents of section \.text:
+ 801dc 41b20000 6fae8000 00006fbe 84000000 .*
+ 801ec 6fae1400 00000000 6fae1c00 00000000 .*
+Contents of section \.tdata:
+#...
+Contents of section \.got:
+ 82304 84220800 0+ 0+ 010+ .*
+ 82314 0+ 0+ 0+ 0+ .*
+ 82324 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-ldgdx-14.d b/ld/testsuite/ld-cris/tls-ldgdx-14.d
new file mode 100644
index 0000000000..53fde9c96f
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ldgdx-14.d
@@ -0,0 +1,55 @@
+#source: tls128.s
+#source: tls-ld-5.s
+#source: tls-gd-1.s
+#source: tls-ldgd-14.s
+#source: tls-hx1x2.s
+#as: --pic --no-underscore --em=criself
+#ld: --shared -m crislinux tmpdir/tls-dso-xz-1.so
+#objdump: -s -h -t -T -R -r -p
+
+# Check that we have proper NPTL/TLS markings and GOT for two
+# R_CRIS_16_GOT_GD and two R_CRIS_16_DTPRELs against different
+# variables in a DSO, GD symbols defined elsewhere.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off .*
+ filesz 0x0+88 memsz 0x0+88 flags r--
+
+Dynamic Section:
+ NEEDED tmpdir/tls-dso-xz-1.so
+#...
+private flags = 0:
+#...
+ 7 .got .*
+ CONTENTS.*
+SYMBOL TABLE:
+#...
+0+ \*UND\* 0+ x
+#...
+0+ \*UND\* 0+ z
+#...
+DYNAMIC SYMBOL TABLE:
+#...
+0+ D \*UND\* 0+ x
+#...
+0+ D \*UND\* 0+ z
+#...
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+00002338 R_CRIS_DTPMOD \*ABS\*
+00002340 R_CRIS_DTP x
+00002348 R_CRIS_DTP z
+
+Contents of section \.hash:
+#...
+Contents of section \.text:
+ 021c 5fae8000 5fbe8400 5fae1400 5fae1c00 .*
+Contents of section .tdata:
+#...
+Contents of section \.got:
+ 232c b4220+ 0+ 0+ 0+ .*
+ 233c 0+ 0+ 0+ 0+ .*
+ 234c 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-ldgdx-15.d b/ld/testsuite/ld-cris/tls-ldgdx-15.d
new file mode 100644
index 0000000000..8b0af3f736
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ldgdx-15.d
@@ -0,0 +1,56 @@
+#source: tls128.s
+#source: tls-ld-7.s
+#source: tls-gd-2.s
+#source: tls-ldgd-15.s
+#source: tls-hx1x2.s
+#as: --pic --no-underscore --em=criself
+#ld: --shared -m crislinux tmpdir/tls-dso-xz-1.so
+#objdump: -s -h -t -T -R -r -p
+
+# Check that we have proper NPTL/TLS markings and GOT for two
+# R_CRIS_32_GOT_GD and two R_CRIS_32_DTPRELs against different
+# variables in a DSO, GD symbols defined elsewhere.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off .*
+ filesz 0x0+88 memsz 0x0+88 flags r--
+
+Dynamic Section:
+ NEEDED tmpdir/tls-dso-xz-1.so
+#...
+private flags = 0:
+#...
+ 7 .got .*
+ CONTENTS.*
+SYMBOL TABLE:
+#...
+0+ \*UND\* 0+ x
+#...
+0+ \*UND\* 0+ z
+#...
+DYNAMIC SYMBOL TABLE:
+#...
+0+ D \*UND\* 0+ x
+#...
+0+ D \*UND\* 0+ z
+#...
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+00002344 R_CRIS_DTPMOD \*ABS\*
+0000234c R_CRIS_DTP x
+00002354 R_CRIS_DTP z
+
+Contents of section \.hash:
+#...
+Contents of section \.text:
+ 021c 6fae8000 00006fbe 84000000 6fae1400 .*
+ 022c 0+ 6fae1c00 0+ .*
+Contents of section .tdata:
+#...
+Contents of section \.got:
+ 2338 c0220+ 0+ 0+ 0+ .*
+ 2348 0+ 0+ 0+ 0+ .*
+ 2358 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-le-12.d b/ld/testsuite/ld-cris/tls-le-12.d
new file mode 100644
index 0000000000..cc4025a27b
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-le-12.d
@@ -0,0 +1,38 @@
+#source: start1.s
+#source: tls128.s
+#source: tls-le-12.s
+#source: tls-z.s
+#as: --no-underscore --em=criself -I$srcdir/$subdir
+#ld: -m crislinux
+#objdump: -d -s -t -r -p -h
+
+# Check that we have proper NPTL/TLS markings and no GOT for an
+# executable with a single R_CRIS_32_TPREL.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off 0x0+a0 vaddr 0x0+820a0 paddr 0x0+820a0 align 2\*\*2
+ filesz 0x0+84 memsz 0x0+84 flags r--
+private flags = 0:
+#...
+ 1 .tdata .*
+ CONTENTS.*
+SYMBOL TABLE:
+#...
+0+80 g \.tdata 0+4 z
+#...
+Contents of section \.text:
+#...
+Contents of section \.tdata:
+#...
+
+Disassembly of section \.text:
+
+00080094 <_start>:
+ 80094: 41b2 moveq 1,\$r11
+#...
+00080098 <tlsfn12>:
+ 80098: 6fae 8000 0000 move\.d 80 <z>,\$r10
+#...
diff --git a/ld/testsuite/ld-cris/tls-le-12.s b/ld/testsuite/ld-cris/tls-le-12.s
new file mode 100644
index 0000000000..18974ef9d2
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-le-12.s
@@ -0,0 +1,8 @@
+ .text
+ .global tlsfn12
+ .type tlsfn12,@function
+ .p2align 1
+tlsfn12:
+ move.d z:TPOFF,$r10
+.Lfe12:
+ .size tlsfn12,.Lfe12-tlsfn12
diff --git a/ld/testsuite/ld-cris/tls-le-12s.d b/ld/testsuite/ld-cris/tls-le-12s.d
new file mode 100644
index 0000000000..8b9fb8ff60
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-le-12s.d
@@ -0,0 +1,38 @@
+#source: start1.s
+#source: tls128.s
+#source: tls-le-12s.s
+#source: tls-z.s
+#as: --no-underscore --em=criself -I$srcdir/$subdir
+#ld: -m crislinux
+#objdump: -d -s -t -r -p -h
+
+# Check that we have proper NPTL/TLS markings and no GOT for an
+# executable with a single R_CRIS_16_TPREL.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off 0x0+9c vaddr 0x0+8209c paddr 0x0+8209c align 2\*\*2
+ filesz 0x0+84 memsz 0x0+84 flags r--
+private flags = 0:
+#...
+ 1 .tdata .*
+ CONTENTS.*
+SYMBOL TABLE:
+#...
+0+80 g \.tdata 0+4 z
+#...
+Contents of section \.text:
+#...
+Contents of section \.tdata:
+#...
+
+Disassembly of section \.text:
+
+00080094 <_start>:
+ 80094: 41b2 moveq 1,\$r11
+#...
+00080098 <tlsfn12>:
+ 80098: 5fac 8000 movu\.w 0x80,\$r10
+#...
diff --git a/ld/testsuite/ld-cris/tls-le-12s.s b/ld/testsuite/ld-cris/tls-le-12s.s
new file mode 100644
index 0000000000..8edcbf6689
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-le-12s.s
@@ -0,0 +1,8 @@
+ .text
+ .global tlsfn12
+ .type tlsfn12,@function
+ .p2align 1
+tlsfn12:
+ movu.w z:TPOFF16,$r10
+.Lfe12:
+ .size tlsfn12,.Lfe12-tlsfn12
diff --git a/ld/testsuite/ld-cris/tls-le-13.d b/ld/testsuite/ld-cris/tls-le-13.d
new file mode 100644
index 0000000000..0589eb349b
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-le-13.d
@@ -0,0 +1,41 @@
+#source: start1.s
+#source: tls128.s
+#source: tls-le-13.s
+#source: tls-x1x2.s
+#as: --no-underscore --em=criself -I$srcdir/$subdir
+#ld: -m crislinux
+#objdump: -d -s -t -r -p -h
+
+# Check that we have proper NPTL/TLS markings and GOT for an
+# executable with a single R_CRIS_32_TPREL.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off 0x0+a4 vaddr 0x0+820a4 paddr 0x0+820a4 align 2\*\*2
+ filesz 0x0+88 memsz 0x0+88 flags r--
+private flags = 0:
+#...
+ 1 .tdata .*
+ CONTENTS.*
+SYMBOL TABLE:
+#...
+0+84 g \.tdata 0+4 x2
+#...
+0+80 g \.tdata 0+4 x1
+#...
+Contents of section \.text:
+#...
+Contents of section \.tdata:
+#...
+
+Disassembly of section \.text:
+
+00080094 <_start>:
+ 80094: 41b2 moveq 1,\$r11
+#...
+00080098 <tlsfn13>:
+ 80098: 6fae 8000 0000 move\.d 80 <x1>,\$r10
+ 8009e: 6fae 8400 0000 move\.d 84 <x2>,\$r10
+#...
diff --git a/ld/testsuite/ld-cris/tls-le-13.s b/ld/testsuite/ld-cris/tls-le-13.s
new file mode 100644
index 0000000000..a1183ead1c
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-le-13.s
@@ -0,0 +1,9 @@
+ .text
+ .global tlsfn13
+ .type tlsfn13,@function
+ .p2align 1
+tlsfn13:
+ move.d x1:TPOFF,$r10
+ move.d x2:TPOFF,$r10
+.Lfe13:
+ .size tlsfn13,.Lfe13-tlsfn13
diff --git a/ld/testsuite/ld-cris/tls-le-13s.d b/ld/testsuite/ld-cris/tls-le-13s.d
new file mode 100644
index 0000000000..601ad225f2
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-le-13s.d
@@ -0,0 +1,40 @@
+#source: start1.s
+#source: tls128.s
+#source: tls-le-13s.s
+#source: tls-x1x2.s
+#as: --no-underscore --em=criself -I$srcdir/$subdir
+#ld: -m crislinux
+#objdump: -d -s -t -r -p -h
+
+# Check that we have proper NPTL/TLS markings and GOT for an
+# executable with two R_CRIS_16_TPREL, different symbols.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off 0x0+a0 vaddr 0x0+820a0 paddr 0x0+820a0 align 2\*\*2
+ filesz 0x0+88 memsz 0x0+88 flags r--
+private flags = 0:
+#...
+ 1 .tdata .*
+ CONTENTS.*
+SYMBOL TABLE:
+#...
+0+84 g \.tdata 0+4 x2
+#...
+0+80 g \.tdata 0+4 x1
+#...
+Contents of section \.text:
+#...
+Contents of section \.tdata:
+#...
+
+Disassembly of section \.text:
+
+00080094 <_start>:
+ 80094: 41b2 moveq 1,\$r11
+#...
+00080098 <tlsfn13>:
+ 80098: 5fae 8000 move\.w 0x80,\$r10
+ 8009c: 5fae 8400 move\.w 0x84,\$r10
diff --git a/ld/testsuite/ld-cris/tls-le-13s.s b/ld/testsuite/ld-cris/tls-le-13s.s
new file mode 100644
index 0000000000..09e4966330
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-le-13s.s
@@ -0,0 +1,9 @@
+ .text
+ .global tlsfn13
+ .type tlsfn13,@function
+ .p2align 1
+tlsfn13:
+ move.w x1:TPOFF16,$r10
+ move.w x2:TPOFF16,$r10
+.Lfe13s:
+ .size tlsfn13,.Lfe13s-tlsfn13
diff --git a/ld/testsuite/ld-cris/tls-legd-16.d b/ld/testsuite/ld-cris/tls-legd-16.d
new file mode 100644
index 0000000000..652504205b
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-legd-16.d
@@ -0,0 +1,59 @@
+#source: start1.s
+#source: tls128.s
+#source: tls-le-13.s
+#source: tls-gd-3.s
+#source: tls-legd-16.s
+#source: tls-x.s
+#source: tls-z.s
+#source: tls-x1x2.s
+#as: --no-underscore --em=criself
+#ld: -m crislinux
+#objdump: -d -s -h -t -r -p
+
+# Check that we have proper NPTL/TLS markings and GOT for an
+# executable with two R_CRIS_32_TPREL and two R_CRIS_32_GD, different
+# symbols.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off 0x0+b4 vaddr 0x0+820b4 paddr 0x0+820b4 align 2\*\*2
+ filesz 0x0+90 memsz 0x0+90 flags r--
+private flags = 0:
+
+#...
+ 2 .got .*
+ CONTENTS.*
+SYMBOL TABLE:
+#...
+0+80 g \.tdata 0+4 x
+#...
+0+8c g \.tdata 0+4 x2
+#...
+0+84 g \.tdata 0+4 z
+#...
+0+88 g \.tdata 0+4 x1
+#...
+Contents of section \.text:
+#...
+Contents of section \.got:
+ 82144 0+ 0+ 0+ 010+ .*
+ 82154 80+ 010+ 840+ .*
+
+Disassembly of section \.text:
+
+00080094 <_start>:
+ 80094: 41b2 moveq 1,\$r11
+#...
+00080098 <tlsfn13>:
+ 80098: 6fae 8800 0000 move.d 88 <x1>,\$r10
+ 8009e: 6fae 8c00 0000 move.d 8c <x2>,\$r10
+
+000800a4 <tlsfn>:
+ 800a4: 6fae 5021 0800 move.d 82150 <_GLOBAL_OFFSET_TABLE_\+0xc>,\$r10
+#...
+
+000800ac <tlsfn16>:
+ 800ac: 6fae 5821 0800 move.d 82158 <_GLOBAL_OFFSET_TABLE_\+0x14>,\$r10
+#...
diff --git a/ld/testsuite/ld-cris/tls-legd-16.s b/ld/testsuite/ld-cris/tls-legd-16.s
new file mode 100644
index 0000000000..37160823f3
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-legd-16.s
@@ -0,0 +1,8 @@
+ .text
+ .global tlsfn16
+ .type tlsfn15,@function
+ .p2align 1
+tlsfn16:
+ move.d z:GD,$r10
+.Lfe16:
+ .size tlsfn16,.Lfe16-tlsfn16
diff --git a/ld/testsuite/ld-cris/tls-legd-17.d b/ld/testsuite/ld-cris/tls-legd-17.d
new file mode 100644
index 0000000000..328d1fd523
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-legd-17.d
@@ -0,0 +1,58 @@
+#source: start1.s
+#source: tls128.s
+#source: tls-le-13s.s
+#source: tls-gd-2.s --pic
+#source: tls-ldgd-14.s --pic
+#source: tls-x.s
+#source: tls-z.s
+#source: tls-x1x2.s
+#as: --no-underscore --em=criself
+#ld: -m crislinux
+#objdump: -d -s -h -t -r -p
+
+# Check that we have proper NPTL/TLS markings and GOT for an
+# executable with two R_CRIS_16_TPREL a R_CRIS_32_GOT_GD and a
+# R_CRIS_16_GOT_GD, different symbols.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off 0x0+ac vaddr 0x0+820ac paddr 0x0+820ac align 2\*\*2
+ filesz 0x0+90 memsz 0x0+90 flags r--
+private flags = 0:
+
+#...
+ 2 .got .*
+ CONTENTS.*
+SYMBOL TABLE:
+#...
+0+80 g \.tdata 0+4 x
+#...
+0+8c g \.tdata 0+4 x2
+#...
+0+84 g \.tdata 0+4 z
+#...
+0+88 g \.tdata 0+4 x1
+#...
+Contents of section \.text:
+#...
+Contents of section \.got:
+ 8213c 0+ 0+ 0+ 010+ .*
+ 8214c 80+ 010+ 840+ .*
+
+Disassembly of section \.text:
+
+00080094 <_start>:
+ 80094: 41b2 moveq 1,\$r11
+#...
+00080098 <tlsfn13>:
+ 80098: 5fae 8800 move.w 0x88,\$r10
+ 8009c: 5fae 8c00 move.w 0x8c,\$r10
+
+000800a0 <tlsdsofn2>:
+ 800a0: 6fae 0c00 0000 move.d c <tls128\+0xc>,\$r10
+#...
+
+000800a8 <tlsdsofn14>:
+ 800a8: 5fae 1400 move.w 0x14,\$r10
diff --git a/ld/testsuite/ld-cris/tls-legdx-16.d b/ld/testsuite/ld-cris/tls-legdx-16.d
new file mode 100644
index 0000000000..8ce4280cef
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-legdx-16.d
@@ -0,0 +1,52 @@
+#source: start1.s
+#source: tls128.s
+#source: tls-le-13.s
+#source: tls-gd-3.s
+#source: tls-legd-16.s
+#source: tls-x1x2.s
+#as: --no-underscore --em=criself
+#ld: -m crislinux tmpdir/tls-dso-xz-1.so
+#objdump: -s -h -t -T -R -r -p
+
+# Check that we have proper NPTL/TLS markings and GOT for an
+# executable with two R_CRIS_32_TPREL and two R_CRIS_32_GD, different
+# symbols, GD symbols defined elsewhere.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off .*
+ filesz 0x0+88 memsz 0x0+88 flags r--
+Dynamic Section:
+ NEEDED tmpdir/tls-dso-xz-1.so
+#...
+private flags = 0:
+
+#...
+ 8 .got .*
+ CONTENTS.*
+SYMBOL TABLE:
+#...
+0+ \*UND\* 0+ x
+#...
+0+ \*UND\* 0+ z
+#...
+DYNAMIC SYMBOL TABLE:
+0+ D \*UND\* 0+ x
+0+ D \*UND\* 0+ z
+#...
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+00082310 R_CRIS_DTP x
+00082318 R_CRIS_DTP z
+
+Contents of section .interp:
+#...
+Contents of section \.text:
+ 801dc 41b20000 6fae8000 00006fae 84000000 .*
+ 801ec 6fae1023 08000000 6fae1823 08000000 .*
+#...
+Contents of section \.got:
+ 82304 84220800 0+ 0+ 0+ .*
+ 82314 0+ 0+ 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-legdx-17.d b/ld/testsuite/ld-cris/tls-legdx-17.d
new file mode 100644
index 0000000000..5a76604f7b
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-legdx-17.d
@@ -0,0 +1,54 @@
+#source: start1.s
+#source: tls128.s
+#source: tls-le-13s.s
+#source: tls-gd-2.s --pic
+#source: tls-ldgd-14.s --pic
+#source: tls-x1x2.s
+#as: --no-underscore --em=criself
+#ld: -m crislinux tmpdir/tls-dso-xz-1.so
+#objdump: -s -h -t -T -R -r -p
+
+# Check that we have proper NPTL/TLS markings and GOT for an
+# executable with two R_CRIS_16_TPREL a R_CRIS_32_GOT_GD and a
+# R_CRIS_16_GOT_GD, different symbols, GD symbols defined elsewhere.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off .*
+ filesz 0x0+88 memsz 0x0+88 flags r--
+Dynamic Section:
+ NEEDED tmpdir/tls-dso-xz-1.so
+#...
+private flags = 0:
+
+#...
+ 8 .got .*
+ CONTENTS.*
+SYMBOL TABLE:
+#...
+0+ \*UND\* 0+ x
+#...
+0+ \*UND\* 0+ z
+#...
+DYNAMIC SYMBOL TABLE:
+#...
+0+ D \*UND\* 0+ x
+#...
+0+ D \*UND\* 0+ z
+#...
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+00082308 R_CRIS_DTP x
+00082310 R_CRIS_DTP z
+
+Contents of section .interp:
+#...
+Contents of section \.text:
+ 801dc 41b20000 5fae8000 5fae8400 6fae0c00 .*
+ 801ec 00000000 5fae1400 .*
+#...
+Contents of section \.got:
+ 822fc 7c220800 0+ 0+ 0+ .*
+ 8230c 0+ 0+ 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-leie-18.d b/ld/testsuite/ld-cris/tls-leie-18.d
new file mode 100644
index 0000000000..e4d1601d1a
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-leie-18.d
@@ -0,0 +1,47 @@
+#source: start1.s
+#source: tls128.s
+#source: tls-le-13s.s
+#source: tls-ie-9.s --pic
+#source: tls-x1x2.s
+#as: --no-underscore --em=criself
+#ld: -m crislinux
+#objdump: -d -s -h -t -r -p
+
+# Check that we have proper NPTL/TLS markings and GOT for an
+# executable with two R_CRIS_16_TPREL and two R_CRIS_16_GOT_TPREL, no
+# same reloc to same symbol; two different symbols.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off 0x0+a8 vaddr 0x0+820a8 paddr 0x0+820a8 align 2\*\*2
+ filesz 0x0+88 memsz 0x0+88 flags r--
+private flags = 0:
+#...
+ 2 .got .*
+ CONTENTS.*
+SYMBOL TABLE:
+#...
+0+84 g \.tdata 0+4 x2
+#...
+0+80 g \.tdata 0+4 x1
+#...
+Contents of section \.text:
+#...
+Contents of section \.got:
+ 82130 0+ 0+ 0+ 840+ .*
+ 82140 80+ ....
+
+Disassembly of section \.text:
+
+00080094 <_start>:
+ 80094: 41b2 moveq 1,\$r11
+#...
+00080098 <tlsfn13>:
+ 80098: 5fae 8000 move.w 0x80,\$r10
+ 8009c: 5fae 8400 move.w 0x84,\$r10
+
+000800a0 <tlsdsofn9>:
+ 800a0: 5fae 1000 move.w 0x10,\$r10
+ 800a4: 5fbe 0c00 move.w 0xc,\$r11
diff --git a/ld/testsuite/ld-cris/tls-leie-19.d b/ld/testsuite/ld-cris/tls-leie-19.d
new file mode 100644
index 0000000000..f294b77b9b
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-leie-19.d
@@ -0,0 +1,58 @@
+#source: start1.s
+#source: tls128.s
+#source: tls-leie-19.s
+#source: tls-le-12.s
+#source: tls-ie-11.s --pic
+#source: tls-hx1x2.s
+#source: tls-x.s
+#source: tls-z.s
+#as: --no-underscore --em=criself
+#ld: -m crislinux
+#objdump: -d -s -h -t -r -p
+
+# Check that we have proper NPTL/TLS markings and GOT for an
+# executable with two R_CRIS_32_TPREL and two R_CRIS_32_GOT_TPREL,
+# four different symbols.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off 0x0+b4 vaddr 0x0+820b4 paddr 0x0+820b4 align 2\*\*2
+ filesz 0x0+90 memsz 0x0+90 flags r--
+private flags = 0:
+#...
+ 2 .got .*
+ CONTENTS.*
+SYMBOL TABLE:
+#...
+0+88 g .tdata 0+4 x
+#...
+0+84 g \.tdata 0+4 \.hidden x2
+#...
+0+8c g .tdata 0+4 z
+#...
+0+80 g \.tdata 0+4 \.hidden x1
+#...
+Contents of section \.text:
+#...
+Contents of section \.got:
+ 82144 0+ 0+ 0+ 840+ .*
+ 82154 80+ .*
+
+Disassembly of section \.text:
+
+00080094 <_start>:
+ 80094: 41b2 moveq 1,\$r11
+#...
+00080098 <tlsfn19>:
+ 80098: 6fae 8800 0000 move.d 88 <x>,\$r10
+#...
+
+000800a0 <tlsfn12>:
+ 800a0: 6fae 8c00 0000 move.d 8c <z>,\$r10
+#...
+
+000800a8 <tlsdsofn>:
+ 800a8: 6fae 1000 0000 move.d 10 <tls128\+0x10>,\$r10
+ 800ae: 6fbe 0c00 0000 move.d c <tls128\+0xc>,\$r11
diff --git a/ld/testsuite/ld-cris/tls-leie-19.s b/ld/testsuite/ld-cris/tls-leie-19.s
new file mode 100644
index 0000000000..a3a65ce1c4
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-leie-19.s
@@ -0,0 +1,8 @@
+ .text
+ .global tlsfn19
+ .type tlsfn19,@function
+ .p2align 1
+tlsfn19:
+ move.d x:TPOFF,$r10
+.Lfe19:
+ .size tlsfn19,.Lfe19-tlsfn19
diff --git a/ld/testsuite/ld-cris/tls-local-54.d b/ld/testsuite/ld-cris/tls-local-54.d
new file mode 100644
index 0000000000..7c0deb6ac2
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-local-54.d
@@ -0,0 +1,27 @@
+#source: tls-local-54.s
+#as: --pic --no-underscore --em=criself -I$srcdir/$subdir
+#ld: --shared -m crislinux
+#objdump: -s -t -R -p -T
+
+# A DSO with a R_CRIS_32_GOT_GD against a local symbol.
+# Check that we have proper NPTL/TLS markings and GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off .*
+ filesz 0x00000080 memsz 0x00000080 flags r--
+#...
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+00002288 R_CRIS_DTP \*ABS\*\+0x0000002a
+
+Contents of section .hash:
+#...
+Contents of section \.text:
+ 0184 6fae0c00 00000000 .*
+#...
+Contents of section \.got:
+ 227c 0c220000 0+ 0+ 0+ .*
+ 228c 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-local-54.s b/ld/testsuite/ld-cris/tls-local-54.s
new file mode 100644
index 0000000000..2bbe756204
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-local-54.s
@@ -0,0 +1,3 @@
+ .include "tls-gd-2.s"
+ .include "tls128.s"
+ .set x, tls128+42
diff --git a/ld/testsuite/ld-cris/tls-local-57.d b/ld/testsuite/ld-cris/tls-local-57.d
new file mode 100644
index 0000000000..03899a7ec0
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-local-57.d
@@ -0,0 +1,23 @@
+#source: start1.s
+#source: tls-x.s
+#source: tls-local-57.s
+#as: --pic --no-underscore --em=criself -I$srcdir/$subdir
+#ld: -m crislinux
+#objdump: -s -t -r -p
+
+# An executable with a R_CRIS_32_GOT_GD against a local symbol.
+# Check that we have proper NPTL/TLS markings and GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off .*
+ filesz 0x00000084 memsz 0x00000084 flags r--
+#...
+Contents of section .text:
+ 80094 41b20000 6fae0c00 0+ .*
+#...
+Contents of section \.got:
+ 82124 0+ 0+ 0+ 010+ .*
+ 82134 040+ .*
diff --git a/ld/testsuite/ld-cris/tls-local-57.s b/ld/testsuite/ld-cris/tls-local-57.s
new file mode 100644
index 0000000000..7c524fc144
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-local-57.s
@@ -0,0 +1,3 @@
+ .include "tls128.s"
+ .set x,tls128
+ .include "tls-gd-2.s"
diff --git a/ld/testsuite/ld-cris/tls-local-58.d b/ld/testsuite/ld-cris/tls-local-58.d
new file mode 100644
index 0000000000..2f68a88f31
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-local-58.d
@@ -0,0 +1,24 @@
+#source: start1.s
+#source: tls-x.s
+#source: tls-local-58.s
+#as: --pic --no-underscore --em=criself -I$srcdir/$subdir
+#ld: -m crislinux
+#objdump: -s -t -r -p
+
+# An executable with a R_CRIS_32_GOT_GD and a R_CRIS_16_GOT_GD against
+# the same local symbol. Check that we have proper NPTL/TLS markings
+# and GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off .*
+ filesz 0x00000084 memsz 0x00000084 flags r--
+#...
+Contents of section .text:
+ 80094 41b20000 6fae0c00 00005fae 0c000000 .*
+#...
+Contents of section \.got:
+ 82128 0+ 0+ 0+ 010+ .*
+ 82138 040+ .*
diff --git a/ld/testsuite/ld-cris/tls-local-58.s b/ld/testsuite/ld-cris/tls-local-58.s
new file mode 100644
index 0000000000..ceb2f693f6
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-local-58.s
@@ -0,0 +1,4 @@
+ .include "tls128.s"
+ .set x,tls128
+ .include "tls-gd-2.s"
+ .include "tls-gd-1.s"
diff --git a/ld/testsuite/ld-cris/tls-local-59.d b/ld/testsuite/ld-cris/tls-local-59.d
new file mode 100644
index 0000000000..fd033e4520
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-local-59.d
@@ -0,0 +1,25 @@
+#source: start1.s
+#source: tls-x.s
+#source: tls-local-59.s
+#as: --pic --no-underscore --em=criself -I$srcdir/$subdir
+#ld: -m crislinux
+#objdump: -s -t -r -p
+
+# An executable with a R_CRIS_32_GOT_GD, a R_CRIS_16_GOT_GD, a
+# R_CRIS_32_GOT_TPREL and a R_CRIS_16_GOT_TPREL against the same local
+# symbol. Check that we have proper NPTL/TLS markings and GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off .*
+ filesz 0x00000084 memsz 0x00000084 flags r--
+#...
+Contents of section .text:
+ 80094 41b20000 6fae1000 00006fae 0c000000 .*
+ 800a4 5fae1000 5fae0c00 .*
+#...
+Contents of section \.got:
+ 82130 0+ 0+ 0+ 040+ .*
+ 82140 010+ 040+ .*
diff --git a/ld/testsuite/ld-cris/tls-local-59.s b/ld/testsuite/ld-cris/tls-local-59.s
new file mode 100644
index 0000000000..9a0d4e456f
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-local-59.s
@@ -0,0 +1,6 @@
+ .include "tls128.s"
+ .set x,tls128
+ .include "tls-gd-2.s"
+ .include "tls-ie-10.s"
+ .include "tls-gd-1.s"
+ .include "tls-ie-8.s"
diff --git a/ld/testsuite/ld-cris/tls-local-60.d b/ld/testsuite/ld-cris/tls-local-60.d
new file mode 100644
index 0000000000..958a29655f
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-local-60.d
@@ -0,0 +1,33 @@
+#source: tls-x.s
+#source: tls-local-59.s
+#as: --pic --no-underscore --em=criself -I$srcdir/$subdir
+#ld: -m crislinux --shared
+#objdump: -s -t -r -p -R -T
+
+# A DSO with a R_CRIS_32_GOT_GD, a R_CRIS_16_GOT_GD, a
+# R_CRIS_32_GOT_TPREL and a R_CRIS_16_GOT_TPREL against the same local
+# symbol. Check that we have proper NPTL/TLS markings and GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off .*
+ filesz 0x00000084 memsz 0x00000084 flags r--
+#...
+ FLAGS 0x00000010
+#...
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0000231c R_CRIS_32_TPREL \*ABS\*\+0x0+4
+00002320 R_CRIS_DTP \*ABS\*\+0x0+4
+
+Contents of section \.hash:
+#...
+Contents of section \.text:
+ 0200 6fae1000 00006fae 0c000000 5fae1000 .*
+ 0210 5fae0c00 .*
+#...
+Contents of section \.got:
+ 2310 98220+ 0+ 0+ 040+ .*
+ 2320 0+ 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-local-61.d b/ld/testsuite/ld-cris/tls-local-61.d
new file mode 100644
index 0000000000..bfa4a25c1e
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-local-61.d
@@ -0,0 +1,32 @@
+#source: tls-local-59.s
+#as: --pic --no-underscore --em=criself -I$srcdir/$subdir
+#ld: -m crislinux --shared
+#objdump: -s -t -r -p -R -T
+
+# A DSO with a R_CRIS_32_GOT_GD, a R_CRIS_16_GOT_GD, a
+# R_CRIS_32_GOT_TPREL and a R_CRIS_16_GOT_TPREL against the same local
+# symbol. Check that we have proper NPTL/TLS markings and GOT.
+
+.*: file format elf32-cris
+
+Program Header:
+#...
+ TLS off .*
+ filesz 0x00000080 memsz 0x00000080 flags r--
+#...
+ FLAGS 0x00000010
+#...
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+00002304 R_CRIS_32_TPREL \*ABS\*
+00002308 R_CRIS_DTP \*ABS\*
+
+Contents of section \.hash:
+#...
+Contents of section \.text:
+ 01ec 6fae1000 00006fae 0c000000 5fae1000 .*
+ 01fc 5fae0c00 .*
+#...
+Contents of section \.got:
+ 22f8 80220+ 0+ 0+ 0+ .*
+ 2308 0+ 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-local-63.d b/ld/testsuite/ld-cris/tls-local-63.d
new file mode 100644
index 0000000000..f6f0bdb933
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-local-63.d
@@ -0,0 +1,31 @@
+#source: tls-ie-8.s --pic
+#source: tls-hx.s
+#as: --no-underscore --em=criself
+#ld: -m crislinux --shared
+#readelf: -a -x 6 -x 8 -x 5
+
+# A R_CRIS_16_GOT_TPREL in a DSO against a hidden symbol. Make sure
+# the relocation, GOT, .text and .tdata have the right contents.
+
+#...
+Relocation section '.rela.dyn' at offset 0x.* contains 1 entries:
+ Offset Info Type Sym.Value Sym. Name \+ Addend
+00002210 0000001c R_CRIS_32_TPREL[ ]+00+
+
+There are no unwind sections in this file.
+
+Symbol table '.dynsym' contains 7 entries:
+ Num: Value Size Type Bind Vis Ndx Name
+#...
+Symbol table '.symtab' contains 16 entries:
+#...
+ .: 00000000 4 TLS LOCAL HIDDEN 6 x
+#...
+Hex dump of section '.text':
+ 0x00000184 5fae0c00 .*
+#...
+Hex dump of section '.tdata':
+ 0x00002188 280+ .*
+#...
+Hex dump of section '.got':
+ 0x0+2204 8c210000 0+ 0+ 0+ .*
diff --git a/ld/testsuite/ld-cris/tls-local-64.d b/ld/testsuite/ld-cris/tls-local-64.d
new file mode 100644
index 0000000000..9fb3019ad5
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-local-64.d
@@ -0,0 +1,37 @@
+#source: tls-ie-8.s --pic
+#source: tls128.s
+#source: tls-hx.s
+#as: --no-underscore --em=criself
+#ld: -m crislinux --shared
+#readelf: -a -x 6 -x 8 -x 5
+
+# A R_CRIS_16_GOT_TPREL in a DSO against a hidden symbol, at an offset
+# into .data. Make sure the relocation, GOT, .text and .tdata have
+# the right contents.
+
+#...
+Relocation section '.rela.dyn' at offset 0x.* contains 1 entries:
+ Offset Info Type Sym.Value Sym. Name \+ Addend
+00002290 0000001c R_CRIS_32_TPREL[ ]+0+80
+
+There are no unwind sections in this file.
+
+Symbol table '.dynsym' contains 7 entries:
+ Num: Value Size Type Bind Vis Ndx Name
+#...
+Symbol table '.symtab' contains 17 entries:
+#...
+ ..: 00000080 4 TLS LOCAL HIDDEN 6 x
+#...
+Hex dump of section '.text':
+ 0x00000184 5fae0c00 .*
+#...
+Hex dump of section '.tdata':
+ 0x00002188 2f0+ 0+ 0+ 0+ .*
+ 0x00002198 0+ 0+ 0+ 0+ .*
+#...
+ 0x000021f8 0+ 0+ 0+ 0+ .*
+ 0x00002208 280+ .*
+#...
+Hex dump of section '.got':
+ 0x0+2284 0c220000 0+ 0+ 80+ .*
diff --git a/ld/testsuite/ld-cris/tls-ok-30.d b/ld/testsuite/ld-cris/tls-ok-30.d
new file mode 100644
index 0000000000..94ed19441a
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ok-30.d
@@ -0,0 +1,29 @@
+#source: tls-gdgotrelm.s --defsym r=8191
+#as: --no-underscore --em=criself --pic
+#ld: --shared -m crislinux
+#objdump: -s -j .got -R
+
+# Verify that the first and last R_CRIS_16_GOT_GD entries are ok just
+# below the limit, in a DSO. Beware, the order here is quite random,
+# supposedly depending on symbol hashes.
+
+.*: file format elf32-cris
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+000b3910 R_CRIS_DTP x2814
+#...
+000b8350 R_CRIS_DTP x8190
+#...
+000c1308 R_CRIS_DTP x0
+#...
+000c3900 R_CRIS_DTP x1345
+
+Contents of section .got:
+ b3904 94380b00 00000000 00000000 00000000 .*
+ b3914 00000000 00000000 00000000 00000000 .*
+#...
+ c38e4 00000000 00000000 00000000 00000000 .*
+ c38f4 00000000 00000000 00000000 00000000 .*
+ c3904 00000000 .*
+#PASS
diff --git a/ld/testsuite/ld-cris/tls-ok-32.d b/ld/testsuite/ld-cris/tls-ok-32.d
new file mode 100644
index 0000000000..8042e2887e
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ok-32.d
@@ -0,0 +1,23 @@
+#source: tls-dtprelm.s --defsym r=32767
+#as: --no-underscore --em=criself --pic
+#ld: --shared -m crislinux
+#objdump: -s -j .got -j .text -j .tdata -R
+
+# Check that a R_CRIS_16_DTPREL just below the theoretical limit
+# works, in a DSO.
+
+.*: file format elf32-cris
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+0000a220 R_CRIS_DTPMOD \*ABS\*
+
+Contents of section \.text:
+ 01a0 5faeff7f .*
+Contents of section \.tdata:
+ 21a4 2a2a2a2a 2a2a2a2a 2a2a2a2a 2a2a2a2a .*
+#...
+ a194 2a2a2a2a 2a2a2a2a 2a2a2a2a 2a2a2a2a .*
+Contents of section \.got:
+ a214 a4a10000 00000000 00000000 00000000 .*
+ a224 00000000 .*
diff --git a/ld/testsuite/ld-cris/tls-ok-34.d b/ld/testsuite/ld-cris/tls-ok-34.d
new file mode 100644
index 0000000000..f534c993d2
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ok-34.d
@@ -0,0 +1,28 @@
+#source: tls-gottprelm.s --defsym r=8189
+#as: --no-underscore --em=criself --pic
+#ld: --shared -m crislinux
+#objdump: -s -j .got -R
+
+# Check that a R_CRIS_16_DTPREL just below the theoretical limit
+# works. Verify that the first and last R_CRIS_16_GOT_TPREL entries
+# are ok, in a DSO. Beware, the order here is quite random,
+# supposedly depending on symbol hashes.
+
+.*: file format elf32-cris
+
+DYNAMIC RELOCATION RECORDS
+OFFSET TYPE VALUE
+000b3870 R_CRIS_32_TPREL x2814
+#...
+000b485c R_CRIS_32_TPREL x8188
+#...
+000ba564 R_CRIS_32_TPREL x0
+#...
+000bb860 R_CRIS_32_TPREL x1345
+
+Contents of section .got:
+ b3864 ec370b00 00000000 00000000 00000000 .*
+ b3874 00000000 00000000 00000000 00000000 .*
+#...
+ bb844 00000000 00000000 00000000 00000000 .*
+ bb854 00000000 00000000 00000000 00000000 .*
diff --git a/ld/testsuite/ld-cris/tls-ok-36.d b/ld/testsuite/ld-cris/tls-ok-36.d
new file mode 100644
index 0000000000..506f7c900f
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-ok-36.d
@@ -0,0 +1,16 @@
+#source: start1.s
+#source: tls-tprelm.s --defsym r=32767
+#as: --no-underscore --em=criself
+#ld: -m crislinux
+#objdump: -s -j .got -j .text -j .tdata
+
+# Check that a R_CRIS_16_TPREL just below the theoretical limit works.
+
+.*: file format elf32-cris
+
+Contents of section \.text:
+ 80094 41b20000 5faeff7f .*
+Contents of section \.tdata:
+ 8209c 2a2a2a2a 2a2a2a2a 2a2a2a2a 2a2a2a2a .*
+#...
+ 8a08c 2a2a2a2a 2a2a2a2a 2a2a2a2a 2a2a2a2a .*
diff --git a/ld/testsuite/ld-cris/tls-tprelm.s b/ld/testsuite/ld-cris/tls-tprelm.s
new file mode 100644
index 0000000000..7d03ddd026
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-tprelm.s
@@ -0,0 +1,26 @@
+ .text
+
+ .ifndef r
+ .set r,1
+ .endif
+
+ .global tlsfntprelm
+ .type tlsfntprelm,@function
+ .p2align 1
+tlsfntprelm:
+ move.w x:TPOFF16,$r10
+.Lfe:
+ .size tlsfntprelm,.Lfe-tlsfntprelm
+
+ .globl z
+ .section .tdata,"awT",@progbits
+ .p2align 2
+ .type z,@object
+ .size z,r
+z:
+ .fill r,1,42
+
+ .type x,@object
+ .size x,1
+x:
+ .byte 42
diff --git a/ld/testsuite/ld-cris/tls-und-38.d b/ld/testsuite/ld-cris/tls-und-38.d
new file mode 100644
index 0000000000..e4df56fe37
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-und-38.d
@@ -0,0 +1,27 @@
+#source: tls-gd-2.s --pic
+#as: --no-underscore --em=criself
+#ld: -m crislinux --shared
+#readelf: -a -x 7
+
+# Undefined reference for a R_CRIS_32_GOT_GD in a DSO. Not an error;
+# it's ok for a DSO to have undefined references upon creation for
+# global symbols that can be overridden. Just make sure GOT, dynsyms
+# and dynrelocs look right.
+
+#...
+Relocation section '.rela.dyn' at offset 0x.* contains 1 entries:
+ Offset Info Type Sym.Value Sym. Name \+ Addend
+000021ec 00000217 R_CRIS_DTP 00000000 x \+ 0
+
+There are no unwind sections in this file.
+
+Symbol table '.dynsym' contains . entries:
+ Num: Value Size Type Bind Vis Ndx Name
+#...
+ [0-9]: 00000000 0 TLS GLOBAL DEFAULT UND x
+#...
+Symbol table '.symtab' contains .. entries:
+#...
+Hex dump of section '.got':
+ 0x0+21e0 70210000 00000000 00000000 00000000 .*
+ 0x0+21f0 00000000 .*
diff --git a/ld/testsuite/ld-cris/tls-und-42.d b/ld/testsuite/ld-cris/tls-und-42.d
new file mode 100644
index 0000000000..b2fba409b2
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-und-42.d
@@ -0,0 +1,26 @@
+#source: tls-ie-10.s --pic
+#as: --no-underscore --em=criself
+#ld: -m crislinux --shared
+#readelf: -a -x 7
+
+# Undefined reference for a R_CRIS_32_GOT_TPREL in a DSO. Not an
+# error; it's ok for a DSO to have undefined references upon creation
+# for global symbols that can be overridden. Just make sure GOT,
+# dynsyms and dynrelocs look right.
+
+#...
+Relocation section '.rela.dyn' at offset 0x.* contains 1 entries:
+ Offset Info Type Sym.Value Sym. Name \+ Addend
+000021f4 0000021c R_CRIS_32_TPREL 0+ x \+ 0
+
+There are no unwind sections in this file.
+
+Symbol table '.dynsym' contains . entries:
+ Num: Value Size Type Bind Vis Ndx Name
+#...
+ [0-9]: 00000000 0 TLS GLOBAL DEFAULT UND x
+#...
+Symbol table '.symtab' contains .. entries:
+#...
+Hex dump of section '.got':
+ 0x0+21e8 70210000 00000000 00000000 00000000 .*
diff --git a/ld/testsuite/ld-cris/tls-und-46.d b/ld/testsuite/ld-cris/tls-und-46.d
new file mode 100644
index 0000000000..8da45b3f23
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-und-46.d
@@ -0,0 +1,27 @@
+#source: tls-gd-1.s --pic
+#as: --no-underscore --em=criself
+#ld: -m crislinux --shared
+#readelf: -a -x 7
+
+# Undefined reference for a R_CRIS_16_GOT_GD in a DSO. Not an error;
+# it's ok for a DSO to have undefined references upon creation for
+# global symbols that can be overridden. Just make sure GOT, dynsyms
+# and dynrelocs look right.
+
+#...
+Relocation section '.rela.dyn' at offset 0x.* contains 1 entries:
+ Offset Info Type Sym.Value Sym. Name \+ Addend
+000021e8 00000217 R_CRIS_DTP 00000000 x \+ 0
+
+There are no unwind sections in this file.
+
+Symbol table '.dynsym' contains . entries:
+ Num: Value Size Type Bind Vis Ndx Name
+#...
+ [0-9]: 00000000 0 TLS GLOBAL DEFAULT UND x
+#...
+Symbol table '.symtab' contains .. entries:
+#...
+Hex dump of section '.got':
+ 0x0+21dc 6c210000 00000000 00000000 00000000 .*
+ 0x0+21ec 00000000 .*
diff --git a/ld/testsuite/ld-cris/tls-und-50.d b/ld/testsuite/ld-cris/tls-und-50.d
new file mode 100644
index 0000000000..417e7a980b
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-und-50.d
@@ -0,0 +1,26 @@
+#source: tls-ie-8.s --pic
+#as: --no-underscore --em=criself
+#ld: -m crislinux --shared
+#readelf: -a -x 7
+
+# Undefined reference for a R_CRIS_16_GOT_TPREL in a DSO. Not an
+# error; it's ok for a DSO to have undefined references upon creation
+# for global symbols that can be overridden. Just make sure GOT,
+# dynsyms and dynrelocs look right.
+
+#...
+Relocation section '.rela.dyn' at offset 0x.* contains 1 entries:
+ Offset Info Type Sym.Value Sym. Name \+ Addend
+000021ec 0000021c R_CRIS_32_TPREL 0+ x \+ 0
+
+There are no unwind sections in this file.
+
+Symbol table '.dynsym' contains . entries:
+ Num: Value Size Type Bind Vis Ndx Name
+#...
+ [0-9]: 00000000 0 TLS GLOBAL DEFAULT UND x
+#...
+Symbol table '.symtab' contains .. entries:
+#...
+Hex dump of section '.got':
+ 0x0+21e0 68210000 00000000 00000000 00000000 .*
diff --git a/ld/testsuite/ld-cris/tls-x.s b/ld/testsuite/ld-cris/tls-x.s
new file mode 100644
index 0000000000..504377ad26
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-x.s
@@ -0,0 +1,7 @@
+ .globl x
+ .section .tdata,"awT",@progbits
+ .p2align 2
+ .type x, @object
+ .size x, 4
+x:
+ .long 40
diff --git a/ld/testsuite/ld-cris/tls-x1x2.s b/ld/testsuite/ld-cris/tls-x1x2.s
new file mode 100644
index 0000000000..fd5d349fb8
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-x1x2.s
@@ -0,0 +1,13 @@
+ .globl x1
+ .section .tdata,"awT",@progbits
+ .p2align 2
+ .type x1, @object
+ .size x1, 4
+x1:
+ .long 41
+ .globl x2
+ .p2align 2
+ .type x2, @object
+ .size x2, 4
+x2:
+ .long 42
diff --git a/ld/testsuite/ld-cris/tls-z.s b/ld/testsuite/ld-cris/tls-z.s
new file mode 100644
index 0000000000..25d97cd075
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls-z.s
@@ -0,0 +1,7 @@
+ .globl z
+ .section .tdata,"awT",@progbits
+ .p2align 2
+ .type z, @object
+ .size z, 4
+z:
+ .long 42
diff --git a/ld/testsuite/ld-cris/tls128.s b/ld/testsuite/ld-cris/tls128.s
new file mode 100644
index 0000000000..71d6b84410
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls128.s
@@ -0,0 +1,8 @@
+; Just something allocating 128 bytes TLS data.
+ .section .tdata,"awT",@progbits
+ .p2align 2
+ .type tls128, @object
+tls128:
+ .long 47
+ .fill 124,1,0
+ .size tls128, 128
diff --git a/ld/testsuite/ld-cris/tls128g.s b/ld/testsuite/ld-cris/tls128g.s
new file mode 100644
index 0000000000..766b7d9624
--- /dev/null
+++ b/ld/testsuite/ld-cris/tls128g.s
@@ -0,0 +1,9 @@
+; Just something allocating 128 bytes TLS data, with the symbol being global.
+ .section .tdata,"awT",@progbits
+ .p2align 2
+ .global tls128
+ .type tls128, @object
+tls128:
+ .long 47
+ .fill 124,1,0
+ .size tls128, 128