[PATCH 3/3] LoongArch: Resolve alignment before first linker-relaxable frag

Project / Subsystem

binutils / loongarch

Date

2026-09-10

Proposer

mengqinggang <mengqinggang@loongson.cn>

Source type

public_inbox

Consensus

Proposed

Sentiment

—/10

Technical tradeoffs

  • • Reduces the number of R_LARCH_ALIGN relocations, potentially improving link times and code density.
  • • Adds complexity to the alignment handling logic, with a fallback for R_LARCH_RELAX.
  • • May affect custom linker scripts if they rely on the exact placement of R_LARCH_ALIGN.

All attributes

project
binutils
subsystem
loongarch
patch_id
—
discussion_id
20260910092253.526336-4-mengqinggang@loongson.cn
source_type
public_inbox
title
[PATCH 3/3] LoongArch: Resolve alignment before first linker-relaxable frag
headline
LoongArch: Optimize alignment before first relaxable frag
tldr
Optimizes alignment handling in LoongArch by converting early alignment frags to non-relaxable ones.
proposer
mengqinggang <mengqinggang@loongson.cn>
consensus
Proposed
outcome
proposed
sentiment_score
—
technical_tradeoffs
  • • Reduces the number of R_LARCH_ALIGN relocations, potentially improving link times and code density.
  • • Adds complexity to the alignment handling logic, with a fallback for R_LARCH_RELAX.
  • • May affect custom linker scripts if they rely on the exact placement of R_LARCH_ALIGN.
series_id
binutils:loongarch: resolve alignment before first linker-relaxable frag
series_role
reply
series_parts
[]
tags
  • • LoongArch
  • • assembler
  • • GAS
  • • relocation
  • • alignment
bugzilla_url
—
date
2026-09-10T00:00:00.000Z

[PATCH 3/3] LoongArch: Resolve alignment before first linker-relaxable frag

This patch optimizes alignment handling for LoongArch by converting alignment fragments that appear before the first linker-relaxable instruction into ordinary, non-linker-relaxable alignment fragments. This allows the assembler (GAS) to compute the exact NOP padding, thus avoiding the emission of R_LARCH_ALIGN relocations. Alignments that appear later remain linker-relaxable. The optimization is skipped if any R_LARCH_RELAX relocations are present, as the exact relaxable fragment cannot be determined before final addresses are known. The patch also refreshes section flags after optimization.