diff options
author | Nelson Chu <nelson@rivosinc.com> | 2023-03-25 08:41:12 +0800 |
---|---|---|
committer | Nelson Chu <nelson@rivosinc.com> | 2023-03-30 07:40:14 +0800 |
commit | b679fb488a8c35e573d50f118a09f72c1f6289de (patch) | |
tree | 523872417472d0d54487e0ca668b3260c2b391ca /ld/testsuite/ld-riscv-elf/data-reloc-rv64-symbolic.d | |
parent | 23068b02d3a6743658110c7662178fdebbe2ac6a (diff) | |
download | binutils-gdb-b679fb488a8c35e573d50f118a09f72c1f6289de.tar.gz |
RISC-V: Clarify link behaviors of R_RISCV_32/64 relocations with ABS symbol.
There are two improvements, which are all referenced to aarch64,
* R_RISCV_32 with non ABS symbol cannot be used under RV64 when making
shard objects.
* Don't need dynamic relocation for R_RISCV_32/64 under RV32/RV64 when
making shared objects, if the referenced symbol is local ABS symbol.
However, considering this link,
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/341
Seems like we should makes all R_RISCV_32/64 relocs with ABS symbol
that don't need any dynamic relocations when making the shared objects.
But anyway, I just sync the current behavior as aarch64 ld, in case
there are any unexpected behaviors happen.
Passed the gcc/binutils regressions in riscv-gnu-toolchain.
bfd/
* elfnn-riscv.c (riscv_elf_check_relocs): Only allow R_RISCV_32 with ABS
symbol under RV64.
(riscv_elf_relocate_section): R_RISCV_32/64 with local ABS symbol under
RV32/RV64 doesn't need any dynamic relocation when making shared objects.
I just make the implementations similar to other targets, so that will be
more easy to mainatain.
ld/
* testsuite/ld-riscv-elf/data-reloc*: New testcases.
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Added new data-reloc* testcases,
and need to make ifunc-seperate* testcases work for rv32.
* testsuite/ld-riscv-elf/ifunc-seperate-caller-nonplt.s: Likewise.
* testsuite/ld-riscv-elf/ifunc-seperate-caller-plt.s: Likewise.
Diffstat (limited to 'ld/testsuite/ld-riscv-elf/data-reloc-rv64-symbolic.d')
-rw-r--r-- | ld/testsuite/ld-riscv-elf/data-reloc-rv64-symbolic.d | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/ld/testsuite/ld-riscv-elf/data-reloc-rv64-symbolic.d b/ld/testsuite/ld-riscv-elf/data-reloc-rv64-symbolic.d new file mode 100644 index 00000000000..5d41f869b72 --- /dev/null +++ b/ld/testsuite/ld-riscv-elf/data-reloc-rv64-symbolic.d @@ -0,0 +1,21 @@ +#source: data-reloc.s +#as: -march=rv64i -mabi=lp64 -defsym __64_bit__=1 -defsym __abs__=1 -defsym __addr__=1 -defsym __undef__=1 +#ld: -m[riscv_choose_lp64_emul] -Ttext 0x8000 --defsym _start=0x0 --defsym abs=0x100 --defsym abs_local=0x200 -shared -Bsymbolic +#objdump: -dR + +.*:[ ]+file format .* + + +Disassembly of section .text: + +0+8000 <addr_globl>: + ... + 8000: R_RISCV_RELATIVE \*ABS\*\+0x8000 + +0+8008 <addr_local>: + ... + 8008: R_RISCV_RELATIVE \*ABS\*\+0x8008 + 8010: R_RISCV_RELATIVE \*ABS\*\+0x100 + 8018: 00000200 .word 0x00000200 + ... + 8020: R_RISCV_64 undef |