binutils Newspaper
JUNE 15, 2026
gas Proposed

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

Adds a new assembler option to control the conversion of local symbols to section symbols in relocation entries.

This patch (in reply to the original proposal) introduces the --reloc-section-sym option to the GNU assembler for ELF targets. This option controls how the assembler handles local symbols in relocations, allowing users to convert all eligible local symbols to section symbols (all), only compiler-generated locals (internal), or keep all symbols as is (none). The change can be useful for debugging and tools relying on preserved symbol names. A maintainer has requested confirmation that the new tests pass for a wide range of targets.

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

    Proposes a new assembler option `--reloc-section-sym` to control the conversion of local symbols to section symbols in relocation entries.

    “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> maintainer

    Acknowledges the proposal and requests verification of the new tests across multiple target architectures.

    “Okay, provided you checked the new tests pass for a wide range of targets. In particular ...”

Technical Tradeoffs

  • Reduced symbol table size when converting local symbols to section symbols.
  • Potential loss of information about individual local symbols in the symbol table, which may complicate debugging.
  • Increased complexity in the assembler code to support the new option.

In Details

When generating relocations, gas can convert local symbols to section symbols (STT_SECTION) to reduce the size of the .symtab. This optimization is controlled by the --reloc-section-sym option. The relevant code resides in gas/config/tc-*.c files and the ELF backend. This feature interacts with symbol table generation and relocation processing.

For Context

The GNU assembler (gas) translates assembly code into object files. Relocations are adjustments that the linker makes to the code and data sections when combining object files. Symbols represent memory locations, functions, or variables. Local symbols are typically only visible within a single object file. This patch allows users to control how the assembler represents local symbols within relocation entries, potentially affecting the size and debuggability of the final executable.

Filed Under: gasassemblerELFrelocationsymbol table