x86: handle a local IFUNC referenced only from a non-alloc section
Fixes binutils to correctly handle local IFUNC symbols when referenced only from non-alloc sections on x86 architectures.
This patch series aims to resolve an issue in the x86 linker where local STT_GNU_IFUNC symbols, when referenced solely from non-allocatable sections, are not processed correctly. The linker aborts because the relocation scan bypasses these sections, preventing the necessary hash entry creation. The solution involves using a new common helper function, _bfd_elf_ifunc_nonalloc_reloc, to manage these symbols, providing a consistent error message for unresolvable relocations, similar to how global symbols are handled.
- proposer
Proposes to use the common `_bfd_elf_ifunc_nonalloc_reloc` function to handle local STT_GNU_IFUNC symbols referenced from non-alloc sections on x86, aligning behavior with global symbols and providing appropriate error reporting.
“Handle the symbol with _bfd_elf_ifunc_nonalloc_reloc, like a global one, and use the existing "non-alloc section" error for the reject case. Master aborts for a global symbol there too; give it the same error.”
In Details
This patch addresses a bug in the binutils linker for x86 architectures (i386 and x86-64) where local IFUNC symbols are mishandled if their only references originate from non-allocatable sections. The current relocation scan excludes these sections, leading to a failure to create essential symbol information. The fix leverages a new BFD-level helper function (_bfd_elf_ifunc_nonalloc_reloc) to uniformly process such IFUNC references, ensuring they either resolve correctly, are skipped, or generate a diagnostic error, mirroring the behavior established for global IFUNC symbols.
- STT_GNU_IFUNC
- A symbol type in the ELF format that represents an indirect function. The linker and dynamic loader resolve this symbol to a specific function pointer at runtime, allowing for architecture-specific or version-specific function implementations.
- non-alloc section
- An ELF section that is not loaded into memory when the program is executed. These sections are often used for debugging information, notes, or other metadata.
- relocation scan
- The process by which the linker identifies and resolves references between different parts of an executable or library. This involves examining relocation entries in object files.
- IFUNC
- Indirect Function. Similar to STT_GNU_IFUNC, it's a mechanism to select a function implementation at runtime based on certain criteria.
- DWARF
- A debugging data format used by many compilers and debuggers. It stores information about variables, types, and source code locations.