Alpha PIC links now emit R_ALPHA_IRELATIVE for IFUNCs
Alpha linker correctly emits R_ALPHA_IRELATIVE for PIC links involving IFUNCs.
This commit modifies the Alpha linker to emit the R_ALPHA_IRELATIVE relocation type when handling PIC (Position Independent Code) links that involve IFUNCs (Indirect Functions). Previously, the linker would emit R_ALPHA_RELATIVE, which would resolve to the IFUNC’s resolver rather than the actual function selected by the resolver. This change ensures that the correct relocation is used, improving the correctness of PIC linking for IFUNCs on Alpha.
In Details
In the Alpha ELF backend, IFUNC references in PIC code were incorrectly handled. Instead of emitting R_ALPHA_IRELATIVE, the linker emitted R_ALPHA_RELATIVE. This commit corrects that by emitting R_ALPHA_IRELATIVE when an IFUNC is encountered in a PIC link, ensuring the dynamic linker resolves to the correct function. Non-PIC links and preemptible IFUNCs are handled as before.
- PIC
- Position Independent Code allows a program to be loaded at any memory address without modification. It's crucial for shared libraries and modern executables.
- IFUNC
- Indirect Function, a mechanism allowing a function symbol to resolve to different implementations at runtime, often based on CPU features. It's resolved via a separate 'resolver' function.
- R_ALPHA_IRELATIVE
- An Alpha-specific ELF relocation type. It's used in dynamic linking to set a memory location to the address returned by an IFUNC's resolver.
- R_ALPHA_RELATIVE
- An Alpha-specific ELF relocation type used for position-dependent code. It calculates an address relative to the base of the executable or shared library.
- dynamic linker
- The system component responsible for loading shared libraries and resolving symbols at runtime. It interprets relocation entries in the executable or library.