binutils Newspaper
NOVEMBER 30, 2026
risc-v — Proposed

RISC-V: Add opt-in Zcmt table-jump relaxation

Introduces an opt-in Zcmt table-jump relaxation feature to GNU ld for RISC-V, enhancing optimization.

This patch series introduces opt-in Zcmt table-jump relaxation to GNU ld for RISC-V. This feature, building on prior work, allows the linker to optimize jumps and calls by utilizing a jump table. It is off by default and requires explicit enabling. The series addresses a regression in text-to-fini range handling, defers certain layout-dependent choices, and ensures correct behavior when the table is not profitable or selected. The implementation has been tested extensively on RISC-V Linux, passing numerous linker tests.

In the Thread 1 participant
  1. Jiawei <jiawei@iscas.ac.cn> proposer

    Presents a series of patches adding opt-in Zcmt table-jump relaxation for RISC-V in GNU ld, detailing changes since v4 and testing results.

    “This series adds opt-in Zcmt table-jump relaxation to GNU ld. The relocation definitions (4b013df1822f) and objdump support with its standalone tests (7310b8560eae) are already upstream and are not resent. Changes since v4: - Introduce --relax-tbljal[=zcmt] and --no-relax-tbljal before adding the backend. Table-jump relaxation is off by default throughout.”

In Details

This is the cover letter for a three-part series introducing Zcmt table-jump relaxation to GNU ld for RISC-V. The Zcmt extension provides a mechanism for indirect jumps and calls to be optimized by the linker into a jump table, reducing code size and potentially improving performance. This series adds the necessary infrastructure in BFD (elfnn-riscv.c), linker passes for analyzing and rewriting jump sites, and test cases. Key aspects include making the feature opt-in via new command-line options (--relax-tbljal), handling various edge cases like non-PIC executables, ISA compatibility, and…

For Context
Zcmt
A RISC-V standard extension that enables table-jump relaxation, an optimization technique for jumps and calls.
table-jump relaxation
An optimization technique where the linker replaces indirect jumps or calls with a more efficient form, often utilizing a jump table, to reduce code size or improve performance.
GNU ld
The GNU linker, responsible for combining object files and libraries into executable programs.
RISC-V
An open standard instruction set architecture (ISA) based on Reduced Instruction Set Computer principles.
opt-in
A feature that is disabled by default and must be explicitly enabled by the user or developer.
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.
relaxation
An optimization process in linkers that adjusts code, such as branch offsets, to improve performance or reduce code size.
Filed Under: risc-vlinkerrelaxationoptimizationperformance