binutils Newspaper
JUNE 15, 2026
risc-v Proposed

RISC-V: Also output undefined symbols as dynamic symbols

A RISC-V linker change ensures undefined symbols are treated as dynamic symbols when linking with `--unresolved-symbols=ignore-in-object-file`, fixing crashes…

Vivian Wang identified that recent binutils changes cause RISC-V linkers to misbehave when encountering undefined symbols, specifically crashing or throwing errors when the desired behavior (with --unresolved-symbols=ignore-in-object-file) is to leave the symbol unresolved for the dynamic linker. The proposed patch restores the emission of dynamic symbols for undefined symbols, fixing a regression and a failing test case. Nelson Chu questions the RISC-V-specific nature of the fix.

In the Thread 1 participant
  1. Nelson Chu <nelson.chu1990@gmail.com> other

    Questions why the proposed fix is specific to RISC-V, wondering if other targets handle undefined symbols differently and if the patch might be missing some broader context.

    “Just curious, it seems other targets don't need to handle bfd_link_hash_undefined in the following codes, so why and what's the difference between riscv and others?”

In Details

The bfd (Binary File Descriptor) library within binutils provides a generic interface for manipulating object files. The RISC-V port needs to handle undefined symbols specially during linking, particularly when --unresolved-symbols=ignore-in-object-file is specified. Recent changes inadvertently stopped outputting dynamic symbols for undefined symbols, leading to incorrect code generation. The patch addresses this by ensuring that undefined symbols are treated as dynamic symbols, allowing the dynamic linker to resolve them at runtime.

For Context

When compiling and linking code, the linker resolves references between different parts of the program. Sometimes, a program might refer to a symbol (like a function or variable) that is not defined in the current object file. The --unresolved-symbols=ignore-in-object-file linker option tells the linker to leave these undefined symbols unresolved and expect the dynamic linker (which runs when the program starts) to resolve them. This patch ensures that on RISC-V, these undefined symbols are correctly marked for dynamic linking, preventing crashes or errors.

Filed Under: binutilsrisc-vlinkerdynamic linkingundefined symbols