diff options
author | 2024-08-16 11:28:10 +0800 | |
---|---|---|
committer | 2024-09-07 10:07:13 +0800 | |
commit | 9a33a0b9c65e587c3142600571f59efb25c973f9 (patch) | |
tree | 4526bf8082f619700648f0fb377a86609527ccee /ld | |
parent | Add macros to get opcode of instructions approriately (diff) | |
download | binutils-gdb-9a33a0b9c65e587c3142600571f59efb25c973f9.tar.gz binutils-gdb-9a33a0b9c65e587c3142600571f59efb25c973f9.tar.bz2 binutils-gdb-9a33a0b9c65e587c3142600571f59efb25c973f9.zip |
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 00000000000..3656652b938 --- /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 00000000000..93a5da6dd22 --- /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 00000000000..29781ad7703 --- /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 4328f6e941e..6bef97c260f 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-*-*"] { |