LoongArch: only insert align section for ld -r if an input has R_LARCH_ALIGN or R_LARCH_RELAX

Project / Subsystem

binutils / loongarch

Date

2026-07-14

Proposer

Xi Ruoyao <xry111@xry111.site>

Source type

public_inbox

Consensus

Proposed

Sentiment

/10

Technical tradeoffs

  • Conditionally inserting align sections reduces output bloat and resolves compatibility issues with environments expecting specific relocation behaviors.
  • Balancing linker flexibility with strict requirements from environments like the Linux kernel module loader.

All attributes

project
binutils
subsystem
loongarch
patch_id
discussion_id
20260714155352.83544-1-xry111@xry111.site
source_type
public_inbox
title
LoongArch: only insert align section for ld -r if an input has R_LARCH_ALIGN or R_LARCH_RELAX
headline
LoongArch: only insert align section for ld -r if an input has R_LARCH_ALIGN or R_LARCH_RELAX
tldr
Fixes LoongArch linker behavior when using `ld -r` to avoid inserting align sections unnecessarily, preventing kernel module loading issues.
proposer
Xi Ruoyao <xry111@xry111.site>
consensus
Proposed
outcome
proposed
sentiment_score
technical_tradeoffs
  • Conditionally inserting align sections reduces output bloat and resolves compatibility issues with environments expecting specific relocation behaviors.
  • Balancing linker flexibility with strict requirements from environments like the Linux kernel module loader.
series_id
series_role
cover
series_parts
[]
tags
  • linker
  • loongarch
  • relocation
  • kernel
  • binutils
bugzilla_url
date
2026-07-14T00:00:00.000Z

LoongArch: only insert align section for ld -r if an input has R_LARCH_ALIGN or R_LARCH_RELAX

Xi Ruoyao proposes a fix to the LoongArch linker’s behavior with ld -r. A previous change inadvertently caused issues with Debian kernel modules because the linker was inserting align sections even when not explicitly required by R_LARCH_ALIGN or R_LARCH_RELAX relocations. This patch ensures the align section is only inserted when such relocations are present, resolving the kernel module loading problem and preventing unnecessary bloat from NOPs and align sections.