diff options
author | Lulu Cai <cailulu@loongson.cn> | 2024-08-09 17:40:59 +0800 |
---|---|---|
committer | liuzhensong <liuzhensong@loongson.cn> | 2024-08-26 17:25:45 +0800 |
commit | 05b3e96495386ee41358c68b8787274ce77ae049 (patch) | |
tree | 4ae4d35b7fb12ea1083533cd6f017e1fd894d4dc /ld | |
parent | 387f97a1b24e968e06dd62f91a26eb0a883fff58 (diff) | |
download | gdb-05b3e96495386ee41358c68b8787274ce77ae049.zip gdb-05b3e96495386ee41358c68b8787274ce77ae049.tar.gz gdb-05b3e96495386ee41358c68b8787274ce77ae049.tar.bz2 |
LoongArch: Fix wrong relocation handling of symbols defined by PROVIDE
If the symbol defined by PROVIDE in the link script is not in SECTION,
the symbol is placed in the ABS section. The linker considers that
symbols in the ABS section do not need to calculate PC relative offsets.
Symbols in ABS sections should calculate PC relative offsets normally
based on relocations.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp | 3 | ||||
-rw-r--r-- | ld/testsuite/ld-loongarch-elf/provide_abs.d | 12 | ||||
-rw-r--r-- | ld/testsuite/ld-loongarch-elf/provide_abs.ld | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-loongarch-elf/provide_noabs.d | 13 | ||||
-rw-r--r-- | ld/testsuite/ld-loongarch-elf/provide_noabs.ld | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-loongarch-elf/provide_sym.s | 7 |
6 files changed, 43 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 d80014d..4328f6e 100644 --- a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp +++ b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp @@ -184,5 +184,8 @@ if [istarget "loongarch64-*-*"] { run_dump_test "ie-le-relax" run_dump_test "tlsdesc_abs" run_dump_test "tlsdesc_extreme" + run_dump_test "provide_abs" + run_dump_test "provide_noabs" + } diff --git a/ld/testsuite/ld-loongarch-elf/provide_abs.d b/ld/testsuite/ld-loongarch-elf/provide_abs.d new file mode 100644 index 0000000..1514fb1 --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/provide_abs.d @@ -0,0 +1,12 @@ +#source: provide_sym.s +#as: +#ld: -T provide_abs.ld +#objdump: -d + +.*: +file format .* + +#... + 0: 58001085 beq \$a0, \$a1, 16 # 10 <fun1> + 4: 40000c80 beqz \$a0, 12 # 10 <fun1> + 8: 54000800 bl 8 # 10 <fun1> +#pass diff --git a/ld/testsuite/ld-loongarch-elf/provide_abs.ld b/ld/testsuite/ld-loongarch-elf/provide_abs.ld new file mode 100644 index 0000000..473476c --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/provide_abs.ld @@ -0,0 +1 @@ +PROVIDE(fun1 = 0x10); diff --git a/ld/testsuite/ld-loongarch-elf/provide_noabs.d b/ld/testsuite/ld-loongarch-elf/provide_noabs.d new file mode 100644 index 0000000..7d6bc4d --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/provide_noabs.d @@ -0,0 +1,13 @@ +#source: provide_sym.s +#as: +#ld: -T provide_noabs.ld +#objdump: -d + +.*: +file format .* + + +#... + 0: 58001085 beq \$a0, \$a1, 16 # 10 <fun1> + 4: 40000c80 beqz \$a0, 12 # 10 <fun1> + 8: 54000800 bl 8 # 10 <fun1> +#pass diff --git a/ld/testsuite/ld-loongarch-elf/provide_noabs.ld b/ld/testsuite/ld-loongarch-elf/provide_noabs.ld new file mode 100644 index 0000000..0154c6f --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/provide_noabs.ld @@ -0,0 +1,7 @@ +SECTIONS +{ + .text : + { + PROVIDE(fun1 = 0x10); + } +} diff --git a/ld/testsuite/ld-loongarch-elf/provide_sym.s b/ld/testsuite/ld-loongarch-elf/provide_sym.s new file mode 100644 index 0000000..6610894 --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/provide_sym.s @@ -0,0 +1,7 @@ + .text + .globl main + .type main, @function +main: + beq $a0,$a1,%b16(fun1) + beqz $a0,%b21(fun1) + bl %b26(fun1) |