binutils Newspaper
NOVEMBER 30, 2026
risc-v — Proposed

RISC-V: Check HI20 relocation bounds before instruction access

Proposes a bounds check for RISC-V HI20 relocations to prevent crashes during relaxation and final linking.

This RFC proposes adding a bounds check for HI20 instruction accesses in the RISC-V ELF backend. The check ensures that the complete instruction fits within the section before relaxation or final access occurs. It also suggests validating the deletion window in the relaxation code. The author is seeking feedback and guidance on the best way to integrate this check, potentially as a follow-up to a related bug.

In the Thread 1 participant
  1. Dorian Vail <snozns@outlook.com> proposer

    Proposes a bounds check for RISC-V HI20 relocation accesses to prevent crashes and improve robustness.

    “The proposal checks that the relocation's complete instruction fits in the section before relaxation or final relocation accesses the contents.”

In Details

This RFC targets the RISC-V ELF backend in binutils, specifically addressing potential crashes related to HI20 relocations. The proposed change involves validating that the instruction generated by a HI20 relocation fits within the target section's bounds *before* the relaxation process or final relocation logic accesses the instruction bytes. This is a proactive measure against out-of-bounds accesses that could corrupt memory or cause crashes, as hinted by Bugzilla #33773.

For Context
RISC-V
An open-standard instruction set architecture based on RISC principles.
HI20
A type of RISC-V relocation that encodes a 20-bit immediate value, often used for PC-relative addressing.
ELF
Executable and Linkable Format, a common standard for object file formats on Unix-like systems.
relaxation
A linker optimization process where instructions are modified to use shorter encodings or different addressing modes, often to improve code density or performance.
bounds check
A check to ensure that data access operations stay within the allocated memory boundaries.
Filed Under: binutilsrisc-vrelocationlinkersecurity