aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorXin Wang <wangxin03@loongson.cn>2024-11-01 19:41:49 +0800
committerliuzhensong <liuzhensong@loongson.cn>2024-11-11 12:02:35 +0800
commit599df6e2db17d1c4be94522fbd4da3d56d5c5515 (patch)
treea204166d6d8134dba0b9ebdf943b09bd5961e367 /ld
parent9f4d8151eef2276989cf3aa83866103b05efa137 (diff)
downloadbinutils-599df6e2db17d1c4be94522fbd4da3d56d5c5515.zip
binutils-599df6e2db17d1c4be94522fbd4da3d56d5c5515.tar.gz
binutils-599df6e2db17d1c4be94522fbd4da3d56d5c5515.tar.bz2
ld, LoongArch: print error about linking without -fPIC or -fPIE flag in more detail
Diffstat (limited to 'ld')
-rw-r--r--ld/testsuite/ld-loongarch-elf/bad_pcala_hi20_global_pie.d4
-rw-r--r--ld/testsuite/ld-loongarch-elf/bad_pcala_hi20_global_pie.s3
-rw-r--r--ld/testsuite/ld-loongarch-elf/bad_pcala_hi20_weak_pie.d4
-rw-r--r--ld/testsuite/ld-loongarch-elf/bad_pcala_hi20_weak_pie.s3
-rw-r--r--ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp2
5 files changed, 16 insertions, 0 deletions
diff --git a/ld/testsuite/ld-loongarch-elf/bad_pcala_hi20_global_pie.d b/ld/testsuite/ld-loongarch-elf/bad_pcala_hi20_global_pie.d
new file mode 100644
index 0000000..5dc2f7c
--- /dev/null
+++ b/ld/testsuite/ld-loongarch-elf/bad_pcala_hi20_global_pie.d
@@ -0,0 +1,4 @@
+#name: PC-relative relocation making executable
+#source: bad_pcala_hi20_global_pie.s
+#ld: -pie -z undefs --defsym _start=0
+#error: .*: relocation R_LARCH_PCALA_HI20 against `sym` can not be used when making a PIE object; recompile with -fPIE
diff --git a/ld/testsuite/ld-loongarch-elf/bad_pcala_hi20_global_pie.s b/ld/testsuite/ld-loongarch-elf/bad_pcala_hi20_global_pie.s
new file mode 100644
index 0000000..f07bff9
--- /dev/null
+++ b/ld/testsuite/ld-loongarch-elf/bad_pcala_hi20_global_pie.s
@@ -0,0 +1,3 @@
+ .global sym
+main:
+ la.pcrel $a0, sym
diff --git a/ld/testsuite/ld-loongarch-elf/bad_pcala_hi20_weak_pie.d b/ld/testsuite/ld-loongarch-elf/bad_pcala_hi20_weak_pie.d
new file mode 100644
index 0000000..5515f25
--- /dev/null
+++ b/ld/testsuite/ld-loongarch-elf/bad_pcala_hi20_weak_pie.d
@@ -0,0 +1,4 @@
+#name: PC-relative relocation making executable
+#source: bad_pcala_hi20_weak_pie.s
+#ld: -pie --defsym _start=0
+#error: .*: relocation R_LARCH_PCALA_HI20 against `sym` can not be used when making a PIE object; recompile with -fPIE
diff --git a/ld/testsuite/ld-loongarch-elf/bad_pcala_hi20_weak_pie.s b/ld/testsuite/ld-loongarch-elf/bad_pcala_hi20_weak_pie.s
new file mode 100644
index 0000000..43abe59
--- /dev/null
+++ b/ld/testsuite/ld-loongarch-elf/bad_pcala_hi20_weak_pie.s
@@ -0,0 +1,3 @@
+ .weak sym
+main:
+ la.pcrel $a0, sym
diff --git a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
index 4e0068d..3313f72 100644
--- a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
+++ b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
@@ -168,6 +168,8 @@ if [istarget "loongarch64-*-*"] {
run_dump_test "abssym_shared"
run_dump_test "bad_pcala_hi20_global"
run_dump_test "bad_pcala_hi20_weak"
+ run_dump_test "bad_pcala_hi20_global_pie"
+ run_dump_test "bad_pcala_hi20_weak_pie"
run_dump_test "bad_pcrel20_s2_global"
run_dump_test "bad_pcrel20_s2_weak"
}