diff options
author | Nelson Chu <nelson@rivosinc.com> | 2024-06-11 16:35:58 +0800 |
---|---|---|
committer | Nelson Chu <nelson@rivosinc.com> | 2024-06-28 13:36:49 +0800 |
commit | 81c353cb9cbba572b73ea4a3949571c44282b0df (patch) | |
tree | e633811341e370162a98f07d32b3137938187aec /gdb | |
parent | 805df5e4a8de619aec6d6a808158c302307478e7 (diff) | |
download | gdb-81c353cb9cbba572b73ea4a3949571c44282b0df.zip gdb-81c353cb9cbba572b73ea4a3949571c44282b0df.tar.gz gdb-81c353cb9cbba572b73ea4a3949571c44282b0df.tar.bz2 |
RISC-V: PR27180, Update relocation for riscv_zero_pcrel_hi_reloc.
When pcrel access overflow, the riscv_zero_pcrel_hi_reloc may convert pcrel
relocation to absolutly access if possible at the relocate stage. We used to
encode the target address into r_sym of R_RISCV_HI20 if it is converted from
R_RISCV_PCREL_HI20. But that may cause segfault if --emit-relocs is set,
since r_sym becomes an address rather than a symbol index. Although the
relocate result is correct, it does not meet the definition, so may cause
unexpected behaviors.
This patch encodes the target address into r_addend, rather than r_sym, if
riscv_zero_pcrel_hi_reloc converts the relocation. Besdies, since the
corresponding pcrel_lo relocation are also changed to absolutly access,
we should also update them to R_RISCV_LO12_I/S.
bfd/
PR 27180
* elfnn-riscv.c (riscv_pcrel_hi_reloc): New boolean `absolute', to
inform corresponding pcrel_lo that the pcrel_hi relocation was already
converted to hi20 relocation.
(riscv_record_pcrel_hi_reloc): Likewise, record `absolute'.
(riscv_pcrel_lo_reloc): Removed `const' for Elf_Internal_Rela *reloc,
since we may need to convert it from pcrel_lo to lo relocation.
(riscv_record_pcrel_lo_reloc): Likewise. Convert pcrel_lo to lo
relocation if corresponding pcrel_hi was converted to hi relocation.
(riscv_zero_pcrel_hi_reloc): Encode target absolute address into
r_addend rather than r_sym. Clear the `addr' to avoid duplicate
relocate in the perform_relocation.
(riscv_elf_relocate_section): Updated.
ld/
PR 27180
* testsuite/ld-riscv-elf/pcrel-lo-addend-3a-emit-relocs.d: New testcase.
Segfault without applying this patch.
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
Diffstat (limited to 'gdb')
0 files changed, 0 insertions, 0 deletions