[PATCH v2] LoongArch: fix .got.plt dislocation in static PDE

Project / Subsystem

binutils / loongarch

Date

2026-08-30

Proposer

Xi Ruoyao <xry111@xry111.site>

Source type

public_inbox

Consensus

Proposed

Sentiment

—/10

Technical tradeoffs

  • • The previous behavior relied on a coincidence where `.got.plt` and `.got.iplt` addresses were the same in static builds with default linker scripts, which could break with custom scripts.
  • • The fix unifies multiple code paths, which could increase complexity but improves correctness and maintainability.
  • • Avoiding C23 attributes in the test suite ensures compatibility with older GCC versions.

All attributes

project
binutils
subsystem
loongarch
patch_id
—
discussion_id
20260830105225.796966-1-xry111@xry111.site
source_type
public_inbox
title
[PATCH v2] LoongArch: fix .got.plt dislocation in static PDE
headline
LoongArch: fix .got.plt dislocation in static PDE
tldr
Fixes an issue where static Position-Dependent Executables (PDEs) on LoongArch incorrectly offset .got.plt entries due to miscalculation of reserved slots.
proposer
Xi Ruoyao <xry111@xry111.site>
consensus
Proposed
outcome
proposed
sentiment_score
—
technical_tradeoffs
  • • The previous behavior relied on a coincidence where `.got.plt` and `.got.iplt` addresses were the same in static builds with default linker scripts, which could break with custom scripts.
  • • The fix unifies multiple code paths, which could increase complexity but improves correctness and maintainability.
  • • Avoiding C23 attributes in the test suite ensures compatibility with older GCC versions.
series_id
—
series_role
standalone
series_parts
[]
tags
  • • loongarch
  • • linker
  • • elf
  • • relocation
  • • static-linking
bugzilla_url
—
date
2026-08-30T00:00:00.000Z

[PATCH v2] LoongArch: fix .got.plt dislocation in static PDE

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.