alpha: support STT_GNU_IFUNC
Adds support for GNU_IFUNC symbol type to the Alpha linker, enabling indirect function resolution.
This series of patches introduces support for STT_GNU_IFUNC (Indirect Functions) to the Alpha linker. This enables the linker to correctly handle IFUNCs, which allow a symbol to resolve to different function implementations at runtime based on a resolver. The changes include allocating the R_ALPHA_IRELATIVE relocation type, handling IFUNC references in PIC and non-PIC links, and ensuring compatibility with glibc. Until dynamic linker or C library support is widespread, existing binaries will continue to use the resolver’s address, preventing regressions.
In Details
This patch series enables the Alpha linker to fully support STT_GNU_IFUNC symbols. It introduces the necessary R_ALPHA_IRELATIVE relocation type (patch 3) and modifies relocation handling for both PIC (patch 5) and non-PIC (patch 7) links to correctly capture the address returned by an IFUNC's resolver. The series also includes general code cleanup and preparation for IFUNC support. The immediate impact is minimal as dynamic linker and C library support are still developing, but it lays the groundwork for future IFUNC usage on Alpha.
- STT_GNU_IFUNC
- A symbol type in the ELF format that represents an Indirect Function. An IFUNC symbol's resolved address is determined at runtime by a resolver function, allowing for platform-specific or optimized function implementations.
- IFUNC
- Indirect Function. A mechanism allowing a symbol to resolve to different function implementations at runtime, typically chosen by a resolver function. Similar to a function pointer but resolved at link or load time.
- PIC
- Position-Independent Code. Code that can be loaded and run at any memory address without modification. Essential for shared libraries and modern executable security.
- R_ALPHA_IRELATIVE
- An Alpha ELF relocation type used in dynamic linking to calculate the final address of a symbol by adding the load address of the shared object to the symbol's addend. For IFUNCs, it stores the address returned by the resolver.
- resolver
- A function that determines the actual address of an IFUNC at runtime, often based on system characteristics.