Alpha linker rejects non-zero addend for IFUNC references
Alpha linker now rejects references to IFUNCs with non-zero addends, as R_ALPHA_IRELATIVE relocation cannot accommodate offsets.
This commit updates the Alpha linker to reject references to IFUNC symbols that include a non-zero addend. The R_ALPHA_IRELATIVE relocation, used for IFUNCs, embeds the resolver’s address in its addend field, leaving no room for an additional offset. References originating from R_ALPHA_LITERAL or R_ALPHA_REFQUAD with an addend are now diagnosed as errors.
In Details
The R_ALPHA_IRELATIVE relocation type is used to provide the address of an IFUNC resolver. This relocation's addend field is used to store the resolver's address, precluding any additional offset from the symbol. Consequently, relocations like R_ALPHA_LITERAL or R_ALPHA_REFQUAD that are resolved as IFUNC references and carry an addend are invalid. This commit adds checks in bfd/elf64-alpha.c to detect and reject such cases, particularly those involving local symbols in shared libraries which are not dynamically bound and thus also rejected.
- IFUNC
- Indirect Function. A mechanism that allows a function call to be resolved at runtime to one of potentially several implementations, typically based on system features or hardware capabilities. This is also known as
GNU_IFUNC. - addend
- A value added to a symbol's address or a relocation value during the linking process. In ELF, addends are often part of the relocation entry itself.
- R_ALPHA_IRELATIVE
- An ELF relocation type specific to the Alpha architecture, used for indirect function calls. It indicates that the relocation value should be the address of the symbol plus an addend, which is typically used to calculate the address of the IFUNC resolver.
- R_ALPHA_LITERAL
- An Alpha-specific ELF relocation type, likely used for referencing literal pool entries.
- R_ALPHA_REFQUAD
- An Alpha-specific ELF relocation type, likely used for referencing quad-word symbols.