binutils Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
bfd/risc-v

RISC-V linker relaxation pass updated to include hash entry

The RISC-V linker's relaxation pass now passes the elf_link_hash_entry to helper functions.

This commit modifies the RISC-V linker’s relaxation handling to pass the elf_link_hash_entry as an argument to various relaxation helper functions in bfd/elfnn-riscv.c. While not all helpers use this new argument immediately, it provides necessary context for future enhancements and ensures consistency within the relaxation process.

In Details

In bfd/elfnn-riscv.c, this commit refactors relaxation functions to accept struct elf_link_hash_entry *h as an argument. This includes riscv_pcgp_hi_reloc structure and the riscv_record_pcgp_hi_reloc function. Although h is marked as unused in some internal relaxation helpers (_bfd_riscv_relax_*), its inclusion ensures that the relaxation pass has access to symbol table information, which is crucial for more complex relaxation scenarios like those involving TLS.

For Context
relaxation
A linker optimization process that adjusts instruction addresses and forms to optimize code size or enable features like TLS access in static executables.
RISC-V
An open-standard instruction set architecture based on reduced instruction set computing principles.
linker
A program that combines object files and libraries into a single executable file or library.
elf_link_hash_entry
An internal data structure used by the linker to manage symbols during the linking process.
Filed Under: risc-vlinkerrelaxationinternal