binutils Newspaper
NOVEMBER 30, 2026
alpha — Proposed

alpha: don't merge .got subsections once GPREL relocs exist

Fixes a linker bug on Alpha where .got subsections could be merged after GPREL relocations were created, causing errors.

This patch addresses a bug in the Alpha linker where merging of .got subsections could still occur even after GPREL16 relocations were established. This merging was happening because the linker could re-run relaxation passes from the beginning, leading to errors like ‘relocation truncated to fit’. The fix prevents merging of .got subsections after the relaxation pass has progressed beyond the initial stage.

In the Thread 2 participants
  1. Matt Turner proposer

    Proposed a fix for the Alpha linker bug related to .got subsection merging after GPREL relocs.

    “But ldelf_map_segments reruns lang_relax_sections, starting again from pass 0, when it has to redo the layout. Merging can then still happen after GPREL16 relocs exist, giving relocation truncated to fit: GPREL16 against symbol `...' Remember that pass 1 has been reached and don't merge after that.”
  2. Alan Modra <amodra@gmail.com> maintainer

    Applied the patch, indicating acceptance.

    “Applied, thanks.”

Technical Tradeoffs

  • Fixes a bug that could lead to linker errors.
  • Potentially simplifies the relaxation process by preventing certain merges.

In Details

This patch modifies bfd/elf64-alpha.c to prevent the merging of .got subsections in the Alpha ELF linker. The issue arises because ldelf_map_segments can trigger lang_relax_sections multiple times. If a relaxation pass has already processed GPREL16 relocations (indicated by relax_pass being non-zero), further merging of .got sections is disallowed. This avoids a specific relocation error on Alpha targets.

For Context
Alpha
A 64-bit RISC instruction set architecture developed by Digital Equipment Corporation (DEC).
.got
Global Offset Table, a section in an executable or object file used for indirect function calls and global variable access, especially in position-independent code.
subsections
Smaller divisions within a larger section of an object file, allowing for more fine-grained control over layout and relaxation.
GPREL
Global Pointer Relative, a type of relocation used in position-independent code on some architectures, where addresses are relative to a global pointer.
relaxation
A linker optimization process where the linker adjusts the size and addresses of code and data sections to optimize for size or performance, often after initial assembly.
Filed Under: linkerAlpharelocationoptimization