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

Project / Subsystem

binutils / loongarch

Date

2026-07-14

Proposer

Xi Ruoyao <xry111@xry111.site>

Source type

public_inbox

Consensus

Proposed

Sentiment

7/10

Technical tradeoffs

  • Making the insertion of align sections conditional improves linker behavior for specific use cases like kernel modules.
  • Ensuring compatibility with environments that have strict requirements on the presence or absence of certain relocations.

All attributes

project
binutils
subsystem
loongarch
patch_id
discussion_id
20260714114920.585718-1-xry111@xry111.site
source_type
public_inbox
title
LoongArch: only insert align section for ld -r if an input has R_LARCH_ALIGN
headline
LoongArch: only insert align section for ld -r if an input has R_LARCH_ALIGN
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
7
technical_tradeoffs
  • Making the insertion of align sections conditional improves linker behavior for specific use cases like kernel modules.
  • Ensuring compatibility with environments that have strict requirements on the presence or absence of certain relocations.
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

Xi Ruoyao proposes a fix for the LoongArch linker when using ld -r, addressing a regression that broke kernel modules. The issue arose because a previous commit unconditionally inserted an align section, which is not expected by modules compiled with -mno-relax. This patch ensures the align section is only created if an input object contains the R_LARCH_ALIGN relocation, thus restoring correct behavior for kernel modules and preventing unnecessary output bloat.