binutils Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
loongarch

LoongArch: Linker handles local IFUNC in non-alloc sections

Fixes the LoongArch linker to correctly handle local IFUNC symbols when they are only referenced from non-allocatable sections.

The LoongArch linker previously failed to correctly process local STT_GNU_IFUNC symbols if they were exclusively referenced from non-allocatable sections. This was because the relocation scan would skip these sections, preventing the IFUNC symbol from being found. This change modifies the linker’s behavior to treat such local IFUNC symbols similarly to global ones, ensuring they are processed correctly even without a PLT entry, thus resolving bugs related to symbol resolution and debugging information.

In Details

This commit addresses an issue in the LoongArch ELF backend for the GNU linker (ld) and BFD. Local STT_GNU_IFUNC symbols, when only referenced from sections marked with SEC_ALLOC=0 (non-allocatable), would not be picked up by the relocation scan because it skips such sections. This PR modifies loongarch_elf_relocate_section to handle these symbols, treating them like STT_FUNC for relocation purposes, thus resolving PR ld/34988. The fix also includes new test cases for both debugging and note sections.

For Context
IFUNC
Indirect Function. A symbol that resolves to a function pointer, allowing for runtime selection of the function implementation, often used for architecture-specific optimizations.
STT_GNU_IFUNC
A symbol type in the ELF file format that denotes an Indirect Function, as defined by GNU extensions.
non-alloc section
A section within an executable or object file that does not occupy memory when the program is run. These sections are often used for debugging information or metadata.
PLT
Procedure Linkage Table. A small piece of code in an executable that resolves calls to dynamically linked external functions at runtime.
BFD
Binary File Descriptor. A library within GNU Binutils that provides a common interface for accessing and manipulating various executable file formats.
ELF
Executable and Linkable Format. A common standard file format for executables, object code, shared libraries, and core dumps on many Unix-like systems.
Filed Under: LoongArchlinkerELFIFUNC