binutils Newspaper
NOVEMBER 30, 2026
riscv — Proposed

riscv: relocate IFUNC references from non-alloc sections as STT_FUNC

Fixes binutils to correctly relocate IFUNC references from non-alloc sections on RISC-V.

This patch resolves an issue in binutils for RISC-V where IFUNC references from non-allocatable sections like .debug_info were not relocated. The linker’s relocation scan skipped these sections, leading to errors. The fix ensures these references are relocated as STT_FUNC, aligning with the behavior for other sections and fixing PR ld/34988.

In the Thread 1 participant
  1. Harshit Kumar <harshit7kr@gmail.com> proposer

    Proposes relocating IFUNC references from non-alloc sections as STT_FUNC to fix a bug where relocation scans skip these sections.

    “A non-alloc section is not loaded and ld.so never processes it, so relocate a reference from any non-alloc section, debugging and note sections included, as against STT_FUNC: it gets the address of the resolver.”

In Details

Similar to the SPARC patch, this addresses STT_GNU_IFUNC relocation issues in Binutils for the RISC-V architecture. The problem occurs when IFUNC symbols are referenced from non-alloc sections, causing riscv_elf_relocate_section to fail due to skipping these sections. The patch modifies the relocation handler to treat these references as STT_FUNC, resolving the bug (PR ld/34988) and ensuring correct resolution of IFUNC symbols.

For Context
STT_GNU_IFUNC
A symbol type in the ELF format used for Indirect Functions, allowing dynamic selection of function implementations at runtime.
non-alloc section
A section in an ELF object file that is not loaded into memory when the program is executed. Examples include debugging information sections.
relocation
The process by which a linker or dynamic loader resolves symbolic references and updates addresses in an object file or executable to their final locations in memory.
STT_FUNC
A symbol type in the ELF format representing a function.
PR ld/34988
A bug report filed against the GNU linker (ld) concerning the handling of IFUNC references in non-alloc sections.
Filed Under: binutilsldriscvELFrelocation