binutils Newspaper
OCTOBER 6, 2026
alpha — Proposed

alpha: set DF_TEXTREL rather than DT_TEXTREL in info->flags

Correctly sets DF_TEXTREL flag in linker info to avoid misinterpreting read-only relocations.

This patch corrects a long-standing issue in the alpha ELF linker where DT_TEXTREL was incorrectly OR-ed into info->flags as DF_TEXTREL. This misuse led to misinterpretations by the dynamic linker, causing shared libraries with text relocations in read-only sections to be treated as if linked with -Bsymbolic. It also caused incorrect relaxation of TLS references. The fix replaces the incorrect DT_TEXTREL with the proper DF_TEXTREL flag, resolving these issues.

In Details

This patch corrects an error in elf64_alpha_calc_dynrel_sizes where the dynamic tag DT_TEXTREL (value 22) was OR-ed into bfd_link_info::flags, which is intended to hold ELF dynamic flags like DF_TEXTREL (value 4). This conflation caused the dynamic linker to incorrectly apply flags like DF_SYMBOLIC and DF_STATIC_TLS, leading to issues with shared library linking (-Bsymbolic) and TLS relaxation. The fix ensures that only the DF_TEXTREL bit is set when a dynamic relocation occurs in a read-only section.

For Context
DF_TEXTREL
An ELF dynamic flag indicating that the executable contains relocations against read-only sections. This requires special handling by the dynamic linker.
DT_TEXTREL
A dynamic tag in the ELF header that indicates text relocations. The value used in the alpha implementation was conflated with DF_TEXTREL.
dynamic linker
A system program (e.g., ld.so) that resolves symbols and loads shared libraries for an executable at runtime.
TLS
Thread-Local Storage. A mechanism that allows variables to have distinct values for each thread.
relaxation
An optimization process by the linker that replaces generic relocations with more efficient, architecture-specific ones, often based on assumptions about the final memory layout.
Filed Under: alphalinkerelfrelocationdynamic linker