binutils Newspaper
OCTOBER 6, 2026
loongarch — Proposed

LoongArch: Use local anchors for relocatable section symbols

Alan Modra questions the necessity of using local anchors for relocatable section symbols in LoongArch, suggesting the relaxation code should be fixed instead.

Alan Modra responds to an RFC patch for LoongArch concerning relocatable section symbols. He questions the approach of using local anchors, suggesting that the underlying issue might be within the LoongArch relaxation code itself, which apparently does not permit symbols to be optimized into a section symbol plus offset form. Modra implies that fixing the relaxation code would be a more appropriate solution unless it can be convincingly demonstrated that this is not possible.

In the Thread 2 participants
  1. Alan Modra <amodra@gmail.com> reviewer

    Questions the approach of using local anchors for LoongArch section symbols, suggesting the relaxation code should be fixed instead.

    “I'm inclined to say, "well, fix your loongarch relaxation code then", unless you can convincingly explain why that is not possible.”
  2. mengqinggang proposer

    Proposed using local anchors for relocatable section symbols in LoongArch due to limitations in its relaxation code.

    “For ld -r, when an input STT_SECTION symbol is redirected to the output section symbol, elf_link_input_bfd() folds sec->output_offset into the RELA addend. LoongArch relaxation does not allow symbols to be optimized into section symbol plus offset form.”

Technical Tradeoffs

  • Working around linker limitations with local anchors might be simpler but could obscure the root cause and potentially limit future optimizations.
  • Fixing the core relaxation mechanism is more complex but leads to a cleaner and more robust solution.

In Details

This exchange pertains to the LoongArch architecture's handling of relocatable section symbols within the GNU linker (ld). The proposer's RFC patch suggests using 'local anchors' to address a limitation where the linker's elf_link_input_bfd() function folds sec->output_offset into the RELA addend for section symbols. The problem is that LoongArch's relaxation mechanism does not support optimizing symbols into a 'section symbol + offset' form. Alan Modra, a reviewer, counters by suggesting that the fundamental issue lies within the LoongArch relaxation implementation itself and that fixi…

For Context
LoongArch
A RISC instruction set architecture developed in China, used in processors like the Loongson series.
relocatable section symbols
Symbols that represent sections within an object file and are used during the linking process to resolve addresses in a position-independent manner.
RFC
Request For Comments, indicating a proposal or discussion document seeking feedback from the community.
ld
The GNU linker, responsible for combining object files into executables or libraries.
relaxation
A linker optimization technique where instructions or addresses are adjusted after initial linking to improve code density or performance, often by using PC-relative addressing or symbol stubs.
RELA
Relocation entry with explicit addend, a type of relocation record used in ELF object files.
STT_SECTION
A symbol type in ELF that specifically refers to a section.
Filed Under: LoongArchlinkerrelocationrelaxationRFC