Alpha: Set DF_TEXTREL directly, avoid spurious flags
Fixes Alpha linker to correctly set DF_TEXTREL flag, preventing incorrect dynamic linking behavior.
This commit corrects an issue in the Alpha ELF backend where the DF_TEXTREL flag was being incorrectly set by ORing DT_TEXTREL into info->flags. This unintentionally introduced other flags like DF_SYMBOLIC and DF_STATIC_TLS, causing shared libraries with text relocations against global symbols to be treated as if linked with -Bsymbolic. This could lead to dlopen failures and incorrect relaxation of TLS references. The fix directly sets DF_TEXTREL using its correct value.
In Details
The elf64_alpha_calc_dynrel_sizes function incorrectly ORed DT_TEXTREL (value 22) into info->flags. Since DF_TEXTREL (value 4) is a bit within DT_FLAGS (value 1), and the bits for DF_SYMBOLIC and DF_STATIC_TLS were also present in DT_TEXTREL's value, these flags were inadvertently set. This caused issues with dynamic linking, particularly for shared libraries with text relocations, leading to potential dlopen failures and incorrect TLS relaxation behavior due to elf64_alpha_relax_sec reading info->flags. The change replaces info->flags |= DT_TEXTREL; with `info->flags…
- DF_TEXTREL
- An ELF dynamic section flag indicating that the executable or shared library contains relocation entries in a read-only (text) section. This requires special handling by the dynamic linker.
- DT_TEXTREL
- A dynamic tag, often used in older contexts or by mistake, that is numerically similar to DF_TEXTREL but can imply other flags when ORed into a flag field.
- DF_SYMBOLIC
- An ELF dynamic section flag that causes symbols to be resolved using symbol-lookup rules similar to linking with the
-Bsymbolicoption, affecting how symbols in shared libraries are referenced. - DF_STATIC_TLS
- An ELF dynamic section flag related to Thread-Local Storage (TLS) that indicates static TLS, affecting how TLS variables are accessed.
- relocation
- A directive in an object file that tells the linker how to modify addresses to correctly reference symbols or locations in the final executable or shared library.
- TLS
- Thread-Local Storage, a mechanism for allocating data that is specific to each thread of execution.