RISC-V: Add new relocation types for global array accesses with non-constant indices
Introduces new RISC-V relocation types for efficient global array access with dynamic 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.
- proposer
Introduces new RISC-V relocation types to optimize global array accesses with non-constant indices.
“This patch introduces support for new RISC-V relocation types (R_RISCV_BASE_IDX_*) to enable more efficient code generation for global array accesses with non-constant array subscripts.”
In Details
This patch introduces new relocation types (R_RISCV_BASE_IDX_*) to the RISC-V toolchain, specifically within binutils (BFD, GAS, ld). These relocations are designed to optimize accesses to global arrays when the index is not a constant. This involves defining new ELF relocation types, handling their relaxation and emission, and updating associated tools and tests to support this new capability as per the RISC-V PSABI specification.
- RISC-V
- An open-standard instruction set architecture (ISA) based on reduced instruction set computing principles.
- relocation types
- Information in an object file that tells the linker how to modify memory addresses and other data when combining multiple object files into an executable or shared library.
- global array accesses
- Operations (read or write) performed on elements of an array that is allocated in the global data segment of a program.
- non-constant indices
- Array subscripts that are determined at runtime, rather than being fixed values known at compile time.
- GAS
- The GNU Assembler, part of the GNU Binutils suite, which translates assembly language code into object files.
- BFD
- Binary File Descriptor library, part of GNU Binutils, which provides a common interface to various object file formats.
- PSABI
- Platform-Specific Application Binary Interface. Defines conventions for how software components interact at the binary level for a specific platform or architecture.
- relaxation
- A process during linking where initially generated, potentially less optimal, instructions or addresses are replaced with more efficient ones, often utilizing specialized relocation types.