binutils Newspaper
JUNE 15, 2026
gas Proposed

gas: Add --reloc-section-sym={all, internal, none} option for ELF

GAS gets a new option to control conversion of local symbols to section symbols in relocations, aiding debugging and symbol preservation.

A new assembler option, --reloc-section-sym, controls the conversion of local symbols to section symbols (STT_SECTION) in ELF relocations. This conversion, which minimizes .symtab size, can now be disabled or limited to compiler-generated symbols. The option helps with debugging and supports tools that rely on preserved symbol names.

In the Thread 3 participants
  1. Fangrui Song <maskray@sourceware.org> proposer

    Proposes a new assembler option `--reloc-section-sym` to control conversion of local symbols to section symbols in ELF relocations.

    “Add --reloc-section-sym to control this conversion: - all (default): convert all eligible local symbols - internal: only convert compiler-generated locals (.L prefix) - none: never convert; keep all symbols as-is in relocations”
  2. Jan Beulich <jbeulich@suse.com> reviewer

    Requests confirmation that the new tests pass on a wide range of targets.

    “Okay, provided you checked the new tests pass for a wide range of targets.”
  3. Fangrui Song <i@maskray.me> contributor

    Replies to the review from Jan Beulich.

Technical Tradeoffs

  • Smaller `.symtab` size vs. preserving symbol names for debugging.
  • Increased complexity in the assembler.

In Details

The GNU Assembler (GAS) converts local symbols to section symbols in ELF relocations under specific conditions, reducing the size of the .symtab. The --reloc-section-sym option provides finer-grained control over this conversion. This affects ELF symbol table generation and relocation processing.

For Context

The GNU Assembler (GAS) translates assembly code into machine code. During this process, it generates relocations, which specify how addresses need to be adjusted when the code is linked. Symbols represent addresses of code or data. This patch introduces a new option to control how local symbols are handled during relocation, which can be useful for debugging and other specialized tools.

Filed Under: assemblergasrelocationelfsymbols