s390: handle a local IFUNC referenced only from a non-alloc section
Fixes s390 linker to correctly handle local IFUNC symbols referenced from non-allocatable sections.
This patch addresses an issue in the s390 linker where local STT_GNU_IFUNC symbols referenced only from non-allocatable sections were not handled correctly. The relocation scan skips these sections, leading to incorrect linking behavior: either the link fails without a diagnostic, or an incorrect PLT slot is used. The fix ensures that these local IFUNCs are relocated against themselves, similar to how global symbols without PLT slots are handled, across both 31-bit and 64-bit s390 backends. New test cases are included to verify the fix.
In Details
This patch series addresses a common problem across multiple architectures concerning the linking of STT_GNU_IFUNC symbols, specifically when they are local to an object file and only referenced from sections that are not intended for runtime allocation (e.g., .debug_info, .comment). The linker's relocation scan typically skips non-SEC_ALLOC sections. When an IFUNC is only present in such a section, the linker fails to find its PLT slot (or equivalent mechanism for indirect functions) and either aborts or mismanages the relocation. This patch for s390 implements a fix by ensuring th…
- s390
- A 31-bit and 64-bit computer architecture family from IBM, used in their mainframe systems.
- STT_GNU_IFUNC
- A symbol type in the ELF format that represents an Indirect Function. IFUNCs allow for dynamic selection of function implementations at runtime, typically based on processor capabilities.
- PLT
- Procedure Linkage Table. A table used in dynamically linked executables to resolve external function calls.
- Non-alloc section
- A section in an object file that is not loaded into memory when the program runs (e.g., debugging information sections). Marked by
SEC_ALLOCflag being unset. - Relocation
- The process of updating symbolic references in an object file to absolute addresses when linking. Relocations contain information about which parts of the code need to be modified and how.
- SEC_ALLOC
- A flag in BFD that indicates whether a section should be allocated memory when the program is loaded.