binutils Newspaper
JUNE 15, 2026
risc-v Proposed

RISC-V: Output undefined symbols as dynamic symbols

This patch fixes an issue in the RISC-V linker that prevented undefined symbols from being resolved by the dynamic linker when using --unresolved-symbols=ignor…

The patch addresses an issue in the RISC-V linker where undefined symbols were not being correctly output as dynamic symbols when the --unresolved-symbols=ignore-in-object-file option was used. This would lead to either a crash when linking with -no-pie or an error message when linking with -pie. The fix involves re-introducing the output of undefined symbols as dynamic symbols, which was removed by commit 9e10fcf71c11. This ensures that these symbols can be resolved by the dynamic linker at runtime.

In the Thread 1 participant
  1. Vivian Wang <wangruikang@iscas.ac.cn> proposer

    Proposes a patch to output undefined symbols as dynamic symbols in the RISC-V linker, fixing an issue where these symbols were not being correctly resolved when using the ``--unresolved-symbols=ignore-in-object-file`` option.

    “Therefore, in order to fix the issue, also output undefined symbols as dynamic symbols.”

In Details

When linking RISC-V code, undefined symbols (e.g., external functions not defined in the current object file) need to be handled so the dynamic linker can resolve them at runtime. The patch modifies bfd/elfnn-riscv.c to ensure that these undefined symbols are output as dynamic symbols, which was unintentionally disabled by a prior commit. This ensures that the dynamic linker can resolve these symbols, preventing crashes or errors during program execution.

For Context

When a program calls a function or uses a variable defined in a separate piece of code (a library, say), the linker must resolve that reference. The dynamic linker handles this resolution at *runtime*, when the program is already running. This patch for the RISC-V architecture ensures that the linker emits the right metadata for undefined symbols, so the dynamic linker can do its job and the program doesn't crash.

Filed Under: RISC-Vlinkerdynamic symbolsundefined symbolsbfd