Alpha linker diagnoses IFUNC references in deleted sections
Alpha linker now detects and reports IFUNC references where the symbol's section was removed during linking, preventing startup crashes.
This commit enhances the Alpha linker to diagnose and report invalid references to IFUNC symbols whose sections have been deleted during the linking process. Previously, such references could lead to an R_ALPHA_NONE relocation in .rela.iplt, causing a crash at program startup. The linker now identifies these inconsistencies, reporting the symbol, relocation, and section name, thus preventing runtime failures.
In Details
This change addresses an issue where sections containing IFUNC symbols might be discarded during linking, but references to those IFUNCs remain in the .rela.iplt section. When elf64_alpha_emit_dynrel writes R_ALPHA_NONE for a relocation whose output section has been removed, and .eh_frame editing further deletes the relocation's slot later, it leads to an executable that faults at startup. The linker now counts input section slots and output relocation entries for .rela.iplt, reporting a mismatch to diagnose the problem. It also ensures that final_link checks for consistency betwe…
- 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. - R_ALPHA_NONE
- An Alpha-specific ELF relocation type indicating that no relocation is to be performed. This is typically used for symbolic relocations that have been resolved or are no longer needed.
- .rela.iplt
- A section in an ELF file that holds relocation entries for indirect function calls (IFUNCs) that are resolved by the dynamic linker or C library startup code.
- ELF relocation
- Information in an object file that describes how to modify addresses and other values when linking. Relocations are necessary to correctly place code and data in memory, especially when dealing with shared libraries or position-independent code.