binutils Newspaper
OCTOBER 6, 2026
alpha — Proposed

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

Fixes binutils linker bug on alpha where merging .got subsections after GPREL relocs are created leads to relocation errors.

This patch modifies the alpha ELF linker to prevent merging of .got subsections after Global Pointer Relative (GPREL) relocations are created. A previous change disabled merging after the first relaxation pass, but the linker’s re-evaluation of layout can restart relaxation from pass zero, leading to incorrect merges and relocation truncation errors.

In the Thread 1 participant
  1. Matt Turner <mattst88@gmail.com> proposer

    Submits a patch to prevent merging .got subsections in the alpha ELF linker after GPREL relocations have been established, addressing a bug that arises when relaxation is re-evaluated.

    “Remember that pass 1 has been reached and don't merge after that. PR ld/5276 bfd/ * elf64-alpha.c (struct alpha_elf_link_hash_table): Add no_got_merge. (elf64_alpha_relax_section): Set it once relax_pass is nonzero, and don't merge .got subsections after that. ld/ * testsuite/ld-alpha/got-merge-gprel-a.s: New. * testsuite/ld-alpha/got-merge-gprel-b.s: New. * testsuite/ld-alpha/got-merge-…”

In Details

This patch addresses a bug in the alpha ELF linker (bfd/elf64-alpha.c) where merging .got subsections can occur after GPREL16 relocations are in place. The linker's relaxation process can restart from pass 0, undoing an earlier prevention of merging. The fix introduces a no_got_merge flag to ensure subsections are not merged once GPREL relocs exist, resolving PR ld/5276.

For Context
.got
Global Offset Table: a section used in ELF executables and shared libraries to store pointers to global or static variables, allowing for position-independent code.
GPREL
Global Pointer Relative: a type of relocation used in some architectures (like Alpha) where addresses are calculated relative to a global pointer register.
relaxation
A linker optimization process that adjusts addresses and sizes of code and data sections to potentially reduce their memory footprint or improve performance, often involving multiple passes.
subsection
A smaller, contiguous part within a larger section (like .got) that can be manipulated or merged independently during linking.
relocation
Information in an object file that tells the linker how to modify certain instructions or data in the code to refer to the correct memory addresses at runtime.
pass
A single iteration of a process, such as the relaxation passes performed by the linker. Higher pass numbers usually indicate more significant or final adjustments.
Filed Under: binutilslinkeralpharelocationoptimization