binutils Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
bfd

LoongArch: Fix GOT entry confusion for DT_RELR.

Corrects handling of GOT entries for DT_RELR relocations on LoongArch.

This commit addresses a “union phase confusion” in the handling of GOT entries for DT_RELR relocations on LoongArch targets. It updates the condition that determines if a GOT entry has been allocated, ensuring it aligns with the offset semantics used after allocate_dynrelocs.

In Details

Corrects an issue in bfd/elfnn-loongarch.c where the record_relr_dyn_got_relocs function misinterprets the h->got union. The fix modifies the check for unallocated GOT entries from h->got.refcount <= 0 to h->got.offset == (bfd_vma) -1, accurately reflecting the new offset-based semantics after allocate_dynrelocs completes.

For Context
LoongArch
A family of RISC-based instruction set architectures developed in China.
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. RELR implies 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.
Filed Under: loongarchlinkerelfrelocation