aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorXi Ruoyao <xry111@xry111.site>2024-06-19 14:04:18 +0800
committerliuzhensong <liuzhensong@loongson.cn>2024-06-20 16:55:24 +0800
commitb5b05a6e6524778e20fccd6b019e781727659f42 (patch)
tree341ee99d646d3efef302612b3ef3210be785aca0 /ld
parentb5929e7aa0195a0656a63da95d5eccbb73b5b173 (diff)
downloadbinutils-b5b05a6e6524778e20fccd6b019e781727659f42.zip
binutils-b5b05a6e6524778e20fccd6b019e781727659f42.tar.gz
binutils-b5b05a6e6524778e20fccd6b019e781727659f42.tar.bz2
LoongArch: TLS IE needs only one dynamic reloc
As the comment in the code says, TLS_IE needs only one dynamic reloc. But commit b67a17aa7c0c ("LoongArch: Fix the issue of excessive relocation generated by GD and IE") has incorrectly allocated the space for two dynamic relocs, causing libc.so to contain 8 R_LARCH_NONE. Adjust tlsdesc-dso.d for the offset changes and add two tests to ensure there are no R_LARCH_NONE with TLS. Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Diffstat (limited to 'ld')
-rw-r--r--ld/testsuite/ld-loongarch-elf/desc-ie-reloc.d9
-rw-r--r--ld/testsuite/ld-loongarch-elf/desc-ie.d8
-rw-r--r--ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp2
-rw-r--r--ld/testsuite/ld-loongarch-elf/tlsdesc-dso-reloc.d9
-rw-r--r--ld/testsuite/ld-loongarch-elf/tlsdesc-dso.d86
5 files changed, 67 insertions, 47 deletions
diff --git a/ld/testsuite/ld-loongarch-elf/desc-ie-reloc.d b/ld/testsuite/ld-loongarch-elf/desc-ie-reloc.d
new file mode 100644
index 0000000..c7a2f8e
--- /dev/null
+++ b/ld/testsuite/ld-loongarch-elf/desc-ie-reloc.d
@@ -0,0 +1,9 @@
+#source: desc-ie.s
+#as:
+#ld: -shared -z norelro --hash-style=both
+#readelf: -Wr
+
+#failif
+#...
+.* +R_LARCH_NONE +.*
+#...
diff --git a/ld/testsuite/ld-loongarch-elf/desc-ie.d b/ld/testsuite/ld-loongarch-elf/desc-ie.d
index c833b23..0759404 100644
--- a/ld/testsuite/ld-loongarch-elf/desc-ie.d
+++ b/ld/testsuite/ld-loongarch-elf/desc-ie.d
@@ -8,7 +8,7 @@
Disassembly of section .text:
[0-9a-f]+ <fn1>:
- +[0-9a-f]+: 1a000084 pcalau12i \$a0, .*
- +[0-9a-f]+: 28cd0084 ld.d \$a0, \$a0, .*
- +[0-9a-f]+: 1a000084 pcalau12i \$a0, .*
- +[0-9a-f]+: 28cd0084 ld.d \$a0, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcalau12i \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$a0, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcalau12i \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$a0, \$a0, .*
diff --git a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
index 40f5657..d833a89 100644
--- a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
+++ b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
@@ -130,7 +130,9 @@ if [istarget "loongarch64-*-*"] {
if [istarget "loongarch64-*-*"] {
if [check_shared_lib_support] {
run_dump_test "desc-ie"
+ run_dump_test "desc-ie-reloc"
run_dump_test "tlsdesc-dso"
+ run_dump_test "tlsdesc-dso-reloc"
run_dump_test "desc-norelax"
run_dump_test "desc-relax"
run_dump_test "data-got"
diff --git a/ld/testsuite/ld-loongarch-elf/tlsdesc-dso-reloc.d b/ld/testsuite/ld-loongarch-elf/tlsdesc-dso-reloc.d
new file mode 100644
index 0000000..d5afa7c
--- /dev/null
+++ b/ld/testsuite/ld-loongarch-elf/tlsdesc-dso-reloc.d
@@ -0,0 +1,9 @@
+#source: tlsdesc-dso.s
+#as:
+#ld: -shared -z norelro --hash-style=both
+#readelf: -Wr
+
+#failif
+#...
+.* +R_LARCH_NONE +.*
+#...
diff --git a/ld/testsuite/ld-loongarch-elf/tlsdesc-dso.d b/ld/testsuite/ld-loongarch-elf/tlsdesc-dso.d
index 8f66302..d6997ec 100644
--- a/ld/testsuite/ld-loongarch-elf/tlsdesc-dso.d
+++ b/ld/testsuite/ld-loongarch-elf/tlsdesc-dso.d
@@ -9,52 +9,52 @@
Disassembly of section .text:
[0-9a-f]+ <fun_gl1>:
- +[0-9a-f]+: 18021584 pcaddi \$a0, 4268
- +[0-9a-f]+: 1a000084 pcalau12i \$a0, 4
- +[0-9a-f]+: 28dd4084 ld.d \$a0, \$a0, 1872
- +[0-9a-f]+: 18021364 pcaddi \$a0, 4251
- +[0-9a-f]+: 180213c4 pcaddi \$a0, 4254
- +[0-9a-f]+: 28c00081 ld.d \$ra, \$a0, 0
- +[0-9a-f]+: 4c000021 jirl \$ra, \$ra, 0
- +[0-9a-f]+: 1a000084 pcalau12i \$a0, 4
- +[0-9a-f]+: 28dc0084 ld.d \$a0, \$a0, 1792
- +[0-9a-f]+: 1a000084 pcalau12i \$a0, 4
- +[0-9a-f]+: 28dc0084 ld.d \$a0, \$a0, 1792
- +[0-9a-f]+: 18021364 pcaddi \$a0, 4251
- +[0-9a-f]+: 180213c4 pcaddi \$a0, 4254
- +[0-9a-f]+: 28c00081 ld.d \$ra, \$a0, 0
- +[0-9a-f]+: 4c000021 jirl \$ra, \$ra, 0
- +[0-9a-f]+: 1a000084 pcalau12i \$a0, 4
- +[0-9a-f]+: 28dce084 ld.d \$a0, \$a0, 1848
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcalau12i \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$a0, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$ra, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ jirl \$ra, \$ra, .*
+ +[0-9a-f]+: [0-9a-f]+ pcalau12i \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$a0, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcalau12i \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$a0, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$ra, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ jirl \$ra, \$ra, .*
+ +[0-9a-f]+: [0-9a-f]+ pcalau12i \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$a0, \$a0, .*
[0-9a-f]+ <fun_lo>:
- +[0-9a-f]+: 1a000084 pcalau12i \$a0, 4
- +[0-9a-f]+: 28daa084 ld.d \$a0, \$a0, 1704
- +[0-9a-f]+: 18020de4 pcaddi \$a0, 4207
- +[0-9a-f]+: 18020f04 pcaddi \$a0, 4216
- +[0-9a-f]+: 28c00081 ld.d \$ra, \$a0, 0
- +[0-9a-f]+: 4c000021 jirl \$ra, \$ra, 0
- +[0-9a-f]+: 18020e24 pcaddi \$a0, 4209
- +[0-9a-f]+: 1a000084 pcalau12i \$a0, 4
- +[0-9a-f]+: 28db4084 ld.d \$a0, \$a0, 1744
- +[0-9a-f]+: 1a000084 pcalau12i \$a0, 4
- +[0-9a-f]+: 28db4084 ld.d \$a0, \$a0, 1744
- +[0-9a-f]+: 18020f44 pcaddi \$a0, 4218
- +[0-9a-f]+: 28c00081 ld.d \$ra, \$a0, 0
- +[0-9a-f]+: 4c000021 jirl \$ra, \$ra, 0
- +[0-9a-f]+: 18020e64 pcaddi \$a0, 4211
- +[0-9a-f]+: 1a000084 pcalau12i \$a0, 4
- +[0-9a-f]+: 28dba084 ld.d \$a0, \$a0, 1768
+ +[0-9a-f]+: [0-9a-f]+ pcalau12i \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$a0, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$ra, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ jirl \$ra, \$ra, .*
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcalau12i \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$a0, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcalau12i \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$a0, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$ra, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ jirl \$ra, \$ra, .*
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ pcalau12i \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$a0, \$a0, .*
[0-9a-f]+ <fun_external>:
- +[0-9a-f]+: 18020ec4 pcaddi \$a0, 4214
- +[0-9a-f]+: 28c00081 ld.d \$ra, \$a0, 0
- +[0-9a-f]+: 4c000021 jirl \$ra, \$ra, 0
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$ra, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ jirl \$ra, \$ra, .*
[0-9a-f]+ <fun_hidden>:
- +[0-9a-f]+: 18021224 pcaddi \$a0, 4241
- +[0-9a-f]+: 28c00081 ld.d \$ra, \$a0, 0
- +[0-9a-f]+: 4c000021 jirl \$ra, \$ra, 0
- +[0-9a-f]+: 18021144 pcaddi \$a0, 4234
- +[0-9a-f]+: 28c00081 ld.d \$ra, \$a0, 0
- +[0-9a-f]+: 4c000021 jirl \$ra, \$ra, 0
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$ra, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ jirl \$ra, \$ra, .*
+ +[0-9a-f]+: [0-9a-f]+ pcaddi \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ ld.d \$ra, \$a0, .*
+ +[0-9a-f]+: [0-9a-f]+ jirl \$ra, \$ra, .*