alpha: emit R_ALPHA_IRELATIVE in PIC links
Use R_ALPHA_IRELATIVE for IFUNC references in PIC alpha links to correctly store resolver addresses.
This patch modifies the alpha ELF linker to emit R_ALPHA_IRELATIVE relocations for IFUNC references in Position-Independent Code (PIC) links. In PIC, references to IFUNCs previously used R_ALPHA_RELATIVE, which stored the resolver’s address. The new R_ALPHA_IRELATIVE relocation correctly stores the address returned by the IFUNC’s resolver. This change ensures proper handling of IFUNCs in PIC environments without altering memory layout for existing RELATIVE relocations.
In Details
This patch updates the alpha ELF backend to use R_ALPHA_IRELATIVE instead of R_ALPHA_RELATIVE for IFUNC references within PIC (Position-Independent Code) executables. In a PIC context, an IFUNC reference resolved by the linker would normally receive the address of the resolver function. This patch ensures that the correct mechanism, R_ALPHA_IRELATIVE, is used to store the actual address returned by the IFUNC resolver, leveraging existing space reserved for RELATIVE relocations.
- 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.
- 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.
- 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.
- R_ALPHA_RELATIVE
- 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 non-IFUNCs, it typically stores the base address of the GOT entry.