binutils Newspaper
OCTOBER 6, 2026
loongarch — Proposed

LoongArch: Emit relocations even after .option norelax

Ensures LoongArch relocations are emitted even when relaxation is disabled.

This patch corrects an issue in the LoongArch assembler (gas) where relocations spanning a relax fragment were not emitted when .option norelax was active. The fix removes a global check for relaxation status in _loongarch_force_relocation_sub_same, instead relying on the relocation’s coverage of a relax fragment to determine if it should be emitted.

In Details

This patch addresses a bug in LoongArch's GAS where the .option norelax directive prevents the emission of relocations that would normally be subject to relaxation. The fix removes the global LARCH_OPTS.relax check within _loongarch_force_relocation_sub_same, ensuring that relocations are emitted based on their fragment coverage rather than the global relaxation state.

For Context
relocation
Information in an object file that describes how to modify (relocate) certain memory addresses when the code or data is loaded into memory at a different address than the one it was compiled for. This is crucial for position-independent code and dynamic linking.
.option norelax
An assembler directive that disables code or data relaxation for the target architecture. Relaxation is a process where the assembler adjusts instruction sizes or addresses to optimize code, and disabling it can be necessary for specific scenarios.
relax fragment
A section of code or data within an object file that is subject to relaxation by the assembler. The assembler may modify addresses or instruction sizes within these fragments to achieve optimizations.
Filed Under: loongarchgasrelocationsassembler