binutils Newspaper
OCTOBER 6, 2026
loongarch — Proposed

LoongArch: fix .got.plt dislocation in static PDE

Fixes an issue where static Position-Dependent Executables (PDEs) on LoongArch incorrectly offset .got.plt entries due to miscalculation of reserved slots.

This patch addresses a bug in LoongArch’s handling of relocations for static Position-Dependent Executables (PDEs). The code incorrectly accounted for two reserved .got.plt entries, which do not exist in static PDEs (as the PLT is only for ifuncs). This resulted in a two-slot dislocation for all .got.plt entries. The fix unifies several relocation handling paths, including those for ifuncs, into a common subroutine that correctly references .got.iplt instead of .got.plt for static builds, resolving latent issues that became exploitable in recent releases.

In the Thread 1 participant
  1. Xi Ruoyao <xry111@xry111.site> proposer

    Submits a patch to correct .got.plt dislocation in LoongArch static PDEs.

    “The code path handling R_LARCH_GOT{64*,{,_PC}_LO12} miscalculated the address of the .got.plt entry: it always counted the two .got.plt entries reserved for ld.so, but in static PDE those two entries do not exist (as in static PDE the PLT is solely for ifunc). Thus all .got.plt entries dislocated for two slots.”

In Details

This patch targets the LoongArch ELF backend in binutils. Specifically, it fixes an issue in static Position-Dependent Executables (PDEs) where relocations like R_LARCH_GOT{64*,{,_PC}_LO12} and R_LARCH_GOT_{PC_,}HI20, as well as R_LARCH_SOP_PUSH_GPREL used for ifuncs, miscalculate the address of .got.plt entries. In static PDEs, the two entries typically reserved for ld.so are absent, leading to a two-slot offset. The fix introduces a unified subroutine that correctly handles these cases, using .got.iplt for static builds and addressing latent issues that became apparent in binutils 2.4…

For Context
LoongArch
A RISC-based instruction set architecture developed in China, with specific ELF object file format conventions.
.got.plt
The 'Global Offset Table for the Procedure Linkage Table'. It stores addresses of dynamically resolved external functions and variables used in Position-Independent Code (PIC).
static PDE
A statically linked Position-Dependent Executable. In this context, it means the executable is linked without shared libraries, and its code relies on fixed memory addresses.
PLT
Procedure Linkage Table. A table used in dynamically linked executables to provide an indirect jump to shared library functions, allowing lazy binding.
ifunc
An indirect function. It's a mechanism used for function selection at runtime, often based on CPU features detected via hardware probing.
relocation
Information in an object file that specifies how addresses and references need to be adjusted by the linker to create the final executable or shared library.
ld.so
The dynamic linker/loader, responsible for loading shared libraries and resolving symbols at runtime.
.got.iplt
Likely refers to a GOT entry specifically used for indirect function (ifunc) resolution, distinct from the standard .got.plt.
Filed Under: loongarchlinkerelfrelocationstatic-linking