binutils Newspaper
NOVEMBER 30, 2026
risc-v — Proposed

RISC-V: Implement GOT load relaxation (--relax-got)

Informs about a preceding patch for fixing partial PC-relative relaxation issues related to the --relax-got feature in binutils.

Luke Zhuang is following up on the patch for implementing RISC-V GOT load relaxation (--relax-got). He informs the list that a related patch, addressing issues with partial PC-relative relaxation, has recently been submitted. This context is important for understanding the ongoing development and potential dependencies for the --relax-got feature, which aims to optimize Global Offset Table (GOT) load sequences in RISC-V executables compiled with -fPIC.

In the Thread 2 participants
  1. Luke Zhuang <luke.zhuang@linux.alibaba.com> contributor

    Provides an update on a related patch fixing PC-relative relaxation issues, which is relevant to the --relax-got feature.

    “A preceding patch for fixing partial pcrel relaxation issue is just submitted: https://sourceware.org/pipermail/binutils/2026-November/152964.html”
  2. Jiawei <jiawei@iscas.ac.cn> proposer

    Originally proposed the patch for RISC-V GOT load relaxation.

    “Implement GOT load relaxation as described in the RISC-V psABI: https://riscv-non-isa.github.io/riscv-elf-psabi-doc/#_got_load_relaxation When --relax-got is enabled, the linker converts GOT indirect loads (auipc+lw/ld via GOT) into more efficient sequences:”

Technical Tradeoffs

  • The `--relax-got` feature provides performance benefits by optimizing GOT loads.
  • Ensuring correctness requires careful handling of relaxation issues, as highlighted by the related patch.
  • The optimization is optional, guarded by a flag, to avoid impacting code that might rely on specific GOT load behaviors.

In Details

This message provides context for the ongoing development of the --relax-got feature in binutils for RISC-V. Luke Zhuang points to a recently submitted patch that addresses partial PC-relative relaxation issues, which is a dependency or related fix for the main GOT load relaxation implementation. The --relax-got feature itself aims to optimize GOT indirect loads by converting them to more efficient PC-relative or absolute sequences, as detailed in the RISC-V psABI.

For Context
RISC-V
An open-source instruction set architecture (ISA) based on Reduced Instruction Set Computing principles.
GOT
Global Offset Table. A table used by position-independent code (PIC) to store addresses of external symbols, allowing efficient linking.
relaxation
A linker optimization process where symbolic or placeholder addresses are replaced with actual, final addresses, potentially leading to more efficient instructions.
PC-relative
An addressing mode where an instruction's operand is specified as an offset relative to the program counter (PC).
--relax-got
A binutils linker flag that enables specific optimizations for GOT load instructions on RISC-V.
psABI
Processor-Specific Application Binary Interface. Defines conventions for how software components interact at the binary level for a particular processor architecture.
-fPIC
A compiler flag that generates Position-Independent Code, necessary for shared libraries and some executable types.
Filed Under: binutilsrisc-vlinkeroptimizationpatch