binutils Newspaper
NOVEMBER 30, 2026
risc-v — Proposed

RISC-V: Relax eligible jumps and calls through a Zcmt table

Implements Zcmt table-jump relaxation in GNU ld for RISC-V, optimizing jumps and calls.

This patch introduces the core logic for Zcmt table-jump relaxation in GNU ld for RISC-V. It enables the linker to identify eligible jumps and calls, plan a profitable jump table, and rewrite the target sites. The passes are opt-in, targeting non-PIC executables with compatible ISA attributes. The implementation handles layout-dependent shortenings after table placement and rewriting, ensuring correct behavior for various transfer types and alignment scenarios.

In Details

This is the second patch in a series that adds opt-in Zcmt table-jump relaxation to GNU ld for RISC-V. This patch focuses on the implementation details within bfd/elfnn-riscv.c. It introduces new types and functions for managing jump table targets (JVT), including hashing and comparison logic. The linker state (riscv_elf_link_hash_table) is augmented to track JVT information. Key functions are added or modified to identify candidate symbols, initialize and manage the JVT hash table, check for eligibility based on options and ISA, create the JVT section, and perform the actual relocation r…

For Context
RISC-V
An open standard instruction set architecture (ISA) based on Reduced Instruction Set Computer principles.
Zcmt
A RISC-V standard extension that allows for table-jump relaxation, an optimization technique for jumps and calls.
table-jump relaxation
An optimization technique in linkers where indirect jumps or calls are replaced with a more efficient form, potentially using a jump table.
GNU ld
The GNU linker, responsible for combining object files and libraries into executable programs.
PIC
Position-Independent Code. Code that can run correctly regardless of where it is loaded in memory.
ISA
Instruction Set Architecture. The set of commands and instructions that a CPU can understand and execute.
JVT
Jump Vector Table. A data structure used in conjunction with table-jump relaxation to manage indirect jump targets.
Filed Under: risc-vlinkerrelaxationoptimizationperformance