[PATCH v5] RISC-V: Add new relocation types for global array accesses with non-constant indices

Project / Subsystem

binutils / risc-v

Date

2026-08-04

Proposer

Liqin Weng <wengliqin@linux.spacemit.com>

Source type

public_inbox

Consensus

Proposed

Sentiment

—/10

Technical tradeoffs

  • • Introduces new relocation types, potentially increasing complexity in the linker and assembler.
  • • Enables more efficient code for a specific access pattern, leading to performance improvements.
  • • Requires updates across multiple binutils components (BFD, GAS, ld) and toolchain support.

All attributes

project
binutils
subsystem
risc-v
patch_id
—
discussion_id
20260804075202.2369022-1-wengliqin@linux.spacemit.com
source_type
public_inbox
title
[PATCH v5] RISC-V: Add new relocation types for global array accesses with non-constant indices
headline
RISC-V: Add new relocation types for global array accesses with non-constant indices
tldr
Introduces new RISC-V relocation types for efficient global array access with dynamic indices.
proposer
Liqin Weng <wengliqin@linux.spacemit.com>
consensus
Proposed
outcome
proposed
sentiment_score
—
technical_tradeoffs
  • • Introduces new relocation types, potentially increasing complexity in the linker and assembler.
  • • Enables more efficient code for a specific access pattern, leading to performance improvements.
  • • Requires updates across multiple binutils components (BFD, GAS, ld) and toolchain support.
series_id
—
series_role
cover
series_parts
[]
tags
  • • binutils
  • • RISC-V
  • • relocations
  • • optimization
  • • ABI
bugzilla_url
—
date
2026-08-04T00:00:00.000Z

[PATCH v5] RISC-V: Add new relocation types for global array accesses with non-constant indices

Liqin Weng proposes adding new RISC-V relocation types (R_RISCV_BASE_IDX_*) to improve code generation efficiency for global array accesses where the array subscript is not a compile-time constant. This patch updates BFD, GAS, and includes new test cases to support these relocation types, aligning with the RISC-V PSABI specification. The changes involve defining new relocation types, mapping internal relaxed relocations to public ELF equivalents, and documenting the new types.