FRIDAY, OCTOBER 2, 2026
bfd
RISC-V: Fix GOT entry confusion for DT_RELR.
Corrects handling of GOT entries for DT_RELR relocations on RISC-V.
This commit fixes a “union phase confusion” in how GOT entries are handled for DT_RELR relocations on RISC-V targets. It adjusts the condition that checks for no allocated GOT entry, aligning it with changes in how the offset semantics are repurposed after allocate_dynrelocs.
In Details
Resolves an issue in bfd/elfnn-riscv.c where record_relr_dyn_got_relocs incorrectly interpreted the repurposed h->got union. The fix changes the check for an unallocated GOT entry from h->got.refcount <= 0 to h->got.offset == (bfd_vma) -1, reflecting the new offset semantics after allocate_dynrelocs has run.
For Context
- RISC-V
- An open-standard Instruction Set Architecture (ISA) based on Reduced Instruction Set Computing principles.
- GOT
- Global Offset Table. A table used in position-independent executable code to store addresses of global variables and functions, allowing them to be resolved at runtime.
- DT_RELR
- A dynamic tag in an ELF file that indicates a table of relocation entries.
RELRimplies a compact relocation format. - relocation
- The process of updating symbolic addresses in relocatable object files to absolute addresses in an executable or shared library. This is typically done by the linker or dynamic loader.
- union phase confusion
- An issue where a data structure (a union) is used to store different types of information at different times, and the code incorrectly assumes one type is present when another is actually stored, leading to misinterpretation of the data.