binutils Newspaper
OCTOBER 6, 2026
bfd — Proposed — Sentiment 6 / 10

LoongArch: Use local anchors for relocatable section symbols

Gopi Kumar Bulusu questions whether linker defects map section start to section offset and asks about desired behavior.

Gopi Kumar Bulusu responds to an RFC patch regarding LoongArch local anchors, questioning the impact of input vs. output section differences on the assembler and incremental linking. He suggests examining the documented behavior for section access and understanding if the current mapping of section start to section offset is by design or a linker defect.

In the Thread 2 participants
  1. Gopi Kumar Bulusu <gopi@sankhya.com> reviewer

    Asks clarifying questions about section mapping and desired behavior, suggesting an investigation into potential linker defects.

    “The basic difference between input section and output section should not impact assembler. Ideally it should not impact an incremental link that does not alter input/output section mapping. I would start by checking the desired documented behavior when a section is accessed and then ask the question what it should be. Is there a linker defect that makes it map section start to a section offset -…”
  2. mengqinggang <mengqinggang@loongson.cn> proposer

    Provides context on the RFC patch and its implications for LoongArch relaxation.

    “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

  • Ensuring the correct handling of section offsets and their interaction with relocations under LoongArch's relaxation constraints.
  • Potential impact on incremental linking and assembler behavior when input and output sections differ.

In Details

This exchange discusses a LoongArch RFC patch for binutils that proposes using local anchors for relocatable section symbols. The core issue is how the linker (ld -r) handles STT_SECTION symbols when redirected to output section symbols, specifically how sec->output_offset is folded into RELA addends. LoongArch's relaxation constraints prevent optimization into section symbol plus offset, necessitating this change. The reviewer questions the fundamental interaction between input/output sections and linker behavior.

For Context
STT_SECTION
A symbol table entry type indicating a section symbol.
RELA
A type of relocation entry that includes an addend.
LoongArch relaxation
A feature in the LoongArch architecture that allows for code optimization, potentially by adjusting instruction encoding based on symbol positions.
local anchors
A mechanism to create stable references within sections that can be updated during linking or relaxation without altering relocation addends.
ld -r
An option for the GNU linker (ld) that performs a partial link, similar to an incremental link, producing an intermediate object file.
bfd
Binary File Descriptor library, used by GNU Binutils to handle various object file formats.
Filed Under: linkerloongarchrelocationoptimizationrfc