[PATCH v1] LoongArch: Fix relaxation alignment with ld -r (PR 33236)

Project / Subsystem

binutils / loongarch

Date

2026-05-29

Proposer

mengqinggang <mengqinggang@loongson.cn>

Source type

public_inbox

Consensus

Proposed

Sentiment

/10

Technical tradeoffs

  • Adding align sections and relocations increases the size of the intermediate object files.
  • Disabling the default section start address calculation could potentially impact other linking scenarios, although the patch aims to minimize this.

All attributes

project
binutils
subsystem
loongarch
patch_id
discussion_id
20260529074340.943231-1-mengqinggang@loongson.cn
source_type
public_inbox
title
[PATCH v1] LoongArch: Fix relaxation alignment with ld -r (PR 33236)
headline
LoongArch: Fix Relaxation Alignment with ld -r
tldr
This patch fixes an alignment issue in LoongArch when using `ld -r` by adding an align section and relocation.
proposer
mengqinggang <mengqinggang@loongson.cn>
consensus
Proposed
outcome
proposed
sentiment_score
technical_tradeoffs
  • Adding align sections and relocations increases the size of the intermediate object files.
  • Disabling the default section start address calculation could potentially impact other linking scenarios, although the patch aims to minimize this.
series_id
series_role
standalone
series_parts
[]
tags
  • LoongArch
  • linker
  • relaxation
  • alignment
  • ld -r
bugzilla_url
date
2026-05-29T00:00:00.000Z

[PATCH v1] LoongArch: Fix relaxation alignment with ld -r (PR 33236)

This patch fixes an issue in LoongArch where section alignment could be incorrect when using ld -r (partial linking). The problem occurs because section alignment can’t be adjusted for objects generated by ld -r, and if previous sections are relaxed, subsequent sections may be misaligned. The fix involves adding an align section and an align relocation before each section when ld -r is used and disabling the default section start address calculation. This approach mirrors a fix already implemented in ld.lld.