Alpha linker supports IFUNC symbols in non-PIC links
Alpha linker now handles IFUNC symbols in non-Position Independent links by using a new `.rela.iplt` section.
This commit enables the Alpha linker to correctly handle IFUNC symbols in non-PIC (non-Position Independent) links. It introduces a new .rela.iplt section to store dynamic relocations for IFUNC references, which is processed by ld.so or the C library startup code. The section is precisely sized to avoid issues with unused relocation slots. The linker also correctly handles IFUNC symbols defined in discarded sections and re-merges GOT entries during relaxation.
In Details
This patch modifies the Alpha linker to support IFUNC symbols in non-PIC binaries. For non-PIC links, a new section .rela.iplt is created to hold R_ALPHA_IRELATIVE relocations for IFUNC references. This section is placed alongside other dynamic relocations and is handled by ld.so or the static executable's C library startup code. Unlike .rela.dyn, .rela.iplt must be sized exactly, as every entry is processed. Sizing is performed in late_size_sections after discarded sections are removed. The GOT entries corresponding to IFUNC references are marked and their counts are adjusted dur…
- 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. - PIC
- Position Independent Code. Code that can be executed in any memory location without modification. This is often used for shared libraries and position-independent executables (PIE).
- non-PIC link
- A link edit that does not generate Position Independent Code. The resulting executable may have fixed addresses and might not be suitable for use as a shared library.
- .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.
- GOT
- Global Offset Table. A table used in position-independent code to store addresses of external functions and global variables, allowing them to be resolved at runtime.
- relaxation
- A process during linking where the linker adjusts addresses and offsets to optimize code, for example, by choosing shorter branch instructions.