aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorLulu Cai <cailulu@loongson.cn>2024-03-19 17:51:19 +0800
committerliuzhensong <liuzhensong@loongson.cn>2024-04-25 09:21:26 +0800
commit66156bae7a0581879763514382d112716464db8a (patch)
tree41141ce7665dab0e3478cd7b4467156d1ab739a9 /ld
parentb221bff7c7ca20d961a7e6b663a545384054a5be (diff)
downloadgdb-66156bae7a0581879763514382d112716464db8a.zip
gdb-66156bae7a0581879763514382d112716464db8a.tar.gz
gdb-66156bae7a0581879763514382d112716464db8a.tar.bz2
LoongArch: Add bad static relocation check and output more information to user
Absolute address symbols cannot be used with -shared. We output more information to the user than just BFD_ASSETR.
Diffstat (limited to 'ld')
-rw-r--r--ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp3
-rw-r--r--ld/testsuite/ld-loongarch-elf/reloc_abs_with_shared.d6
-rw-r--r--ld/testsuite/ld-loongarch-elf/reloc_abs_with_shared.s9
-rw-r--r--ld/testsuite/ld-loongarch-elf/reloc_le_with_shared.d6
-rw-r--r--ld/testsuite/ld-loongarch-elf/reloc_le_with_shared.s8
-rw-r--r--ld/testsuite/ld-loongarch-elf/reloc_ler_with_shared.d4
-rw-r--r--ld/testsuite/ld-loongarch-elf/reloc_ler_with_shared.s9
7 files changed, 45 insertions, 0 deletions
diff --git a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
index c2d616b..40f5657 100644
--- a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
+++ b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
@@ -134,6 +134,9 @@ if [istarget "loongarch64-*-*"] {
run_dump_test "desc-norelax"
run_dump_test "desc-relax"
run_dump_test "data-got"
+ run_dump_test "reloc_le_with_shared"
+ run_dump_test "reloc_ler_with_shared"
+ run_dump_test "reloc_abs_with_shared"
}
if [check_pie_support] {
diff --git a/ld/testsuite/ld-loongarch-elf/reloc_abs_with_shared.d b/ld/testsuite/ld-loongarch-elf/reloc_abs_with_shared.d
new file mode 100644
index 0000000..532e84f
--- /dev/null
+++ b/ld/testsuite/ld-loongarch-elf/reloc_abs_with_shared.d
@@ -0,0 +1,6 @@
+#source: reloc_abs_with_shared.s
+#as:
+#ld: -shared
+#error: .*relocation R_LARCH_ABS_HI20 against `s` can not be used when making a shared object; recompile with -fPIC
+#...
+#pass
diff --git a/ld/testsuite/ld-loongarch-elf/reloc_abs_with_shared.s b/ld/testsuite/ld-loongarch-elf/reloc_abs_with_shared.s
new file mode 100644
index 0000000..13341af
--- /dev/null
+++ b/ld/testsuite/ld-loongarch-elf/reloc_abs_with_shared.s
@@ -0,0 +1,9 @@
+ .text
+ .globl s
+ .data
+ .type s, @object
+ s:
+ .word 123
+ .text
+ lu12i.w $r4,%abs_hi20(s)
+ addi.d $r4,$r4,%abs_lo12(s)
diff --git a/ld/testsuite/ld-loongarch-elf/reloc_le_with_shared.d b/ld/testsuite/ld-loongarch-elf/reloc_le_with_shared.d
new file mode 100644
index 0000000..562b079
--- /dev/null
+++ b/ld/testsuite/ld-loongarch-elf/reloc_le_with_shared.d
@@ -0,0 +1,6 @@
+#source: reloc_le_with_shared.s
+#as:
+#ld: -shared
+#error: .*relocation R_LARCH_TLS_LE_HI20 against `s` can not be used when making a shared object; recompile with -fPIC
+#...
+#pass
diff --git a/ld/testsuite/ld-loongarch-elf/reloc_le_with_shared.s b/ld/testsuite/ld-loongarch-elf/reloc_le_with_shared.s
new file mode 100644
index 0000000..c720665
--- /dev/null
+++ b/ld/testsuite/ld-loongarch-elf/reloc_le_with_shared.s
@@ -0,0 +1,8 @@
+ .text
+ .globl s
+ .section .tdata,"awT",@progbits
+ .type s, @object
+ s:
+ .word 123
+ .text
+ la.tls.le $r4, s
diff --git a/ld/testsuite/ld-loongarch-elf/reloc_ler_with_shared.d b/ld/testsuite/ld-loongarch-elf/reloc_ler_with_shared.d
new file mode 100644
index 0000000..7382d5b
--- /dev/null
+++ b/ld/testsuite/ld-loongarch-elf/reloc_ler_with_shared.d
@@ -0,0 +1,4 @@
+#source: reloc_ler_with_shared.s
+#as:
+#ld: -shared
+#error: .*relocation R_LARCH_TLS_LE_HI20_R against `s` can not be used when making a shared object; recompile with -fPIC
diff --git a/ld/testsuite/ld-loongarch-elf/reloc_ler_with_shared.s b/ld/testsuite/ld-loongarch-elf/reloc_ler_with_shared.s
new file mode 100644
index 0000000..a9e5696
--- /dev/null
+++ b/ld/testsuite/ld-loongarch-elf/reloc_ler_with_shared.s
@@ -0,0 +1,9 @@
+ .text
+ .globl s
+ .section .tdata,"awT",@progbits
+ .type s, @object
+ s:
+ .word 123
+ .text
+ lu12i.w $r4,%le_hi20_r(s)
+ add.d $r4,$r4,$r2,%le_add_r(s)