diff options
author | Xin Wang <yw987194828@gmail.com> | 2024-08-16 11:28:10 +0800 |
---|---|---|
committer | liuzhensong <liuzhensong@loongson.cn> | 2024-09-07 10:07:13 +0800 |
commit | 9a33a0b9c65e587c3142600571f59efb25c973f9 (patch) | |
tree | 4526bf8082f619700648f0fb377a86609527ccee /ld | |
parent | 2bbe1079021228795905938a4c4ce5f71575a20b (diff) | |
download | binutils-9a33a0b9c65e587c3142600571f59efb25c973f9.zip binutils-9a33a0b9c65e587c3142600571f59efb25c973f9.tar.gz binutils-9a33a0b9c65e587c3142600571f59efb25c973f9.tar.bz2 |
Not append rela for absolute symbol
LoongArch: Not append rela for absolute symbol
Use la.global to get absolute symbol like la.abs.
la.global put address of a global symbol into a got
entry and append a rela for it, which will be used
to relocate by dynamic linker. Dynamic linker should
not relocate for got entry of absolute symbol as it
stores symval not symbol's address.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/testsuite/ld-loongarch-elf/abs-global.out | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-loongarch-elf/abs-global.s | 5 | ||||
-rw-r--r-- | ld/testsuite/ld-loongarch-elf/get_abs_global_sym.c | 7 | ||||
-rw-r--r-- | ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp | 12 |
4 files changed, 25 insertions, 0 deletions
diff --git a/ld/testsuite/ld-loongarch-elf/abs-global.out b/ld/testsuite/ld-loongarch-elf/abs-global.out new file mode 100644 index 0000000..3656652 --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/abs-global.out @@ -0,0 +1 @@ +abba diff --git a/ld/testsuite/ld-loongarch-elf/abs-global.s b/ld/testsuite/ld-loongarch-elf/abs-global.s new file mode 100644 index 0000000..93a5da6 --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/abs-global.s @@ -0,0 +1,5 @@ +.text +.globl get_sym +get_sym: + la.global $a0, sym + ret diff --git a/ld/testsuite/ld-loongarch-elf/get_abs_global_sym.c b/ld/testsuite/ld-loongarch-elf/get_abs_global_sym.c new file mode 100644 index 0000000..29781ad --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/get_abs_global_sym.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +extern int get_sym(); +int main() { + printf("%x\n", get_sym()); + return 0; +} diff --git a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp index 4328f6e..6bef97c2 100644 --- a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp +++ b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp @@ -130,6 +130,18 @@ if [istarget "loongarch64-*-*"] { "a.binary" \ ] \ ] + + + run_ld_link_exec_tests [list \ + [list \ + "get global abs symbol test" \ + "-Wl,-z norelro -Wl,--defsym sym=0xabba" \ + "" \ + { abs-global.s get_abs_global_sym.c} \ + "abs-global" \ + "abs-global.out" \ + ] \ + ] } if [istarget "loongarch64-*-*"] { |