binutils Newspaper
OCTOBER 6, 2026
risc-v — Proposed

RISC-V: Add elf_link_hash_entry to relax_func args.

Pass elf_link_hash_entry to relaxation functions for consistent TLS handling.

This patch modifies RISC-V relaxation functions in binutils to accept an elf_link_hash_entry argument. This change is part of a larger effort to unify TLS handling and ensure that all necessary symbol information is available during the relaxation process. By passing the hash entry, the relaxation functions can correctly process TLS-related relocations, improving the robustness of TLS support.

In Details

This patch adds an elf_link_hash_entry argument to various RISC-V relaxation helper functions in bfd/elfnn-riscv.c, such as _bfd_riscv_relax_pc and _bfd_riscv_relax_section. While some of these functions do not currently use the argument, it's introduced for consistency with other relaxation functions, particularly those involved in TLS handling (as seen in related patches). This change prepares the relaxation infrastructure to properly access symbol information through the hash table during the relocation processing, which is crucial for advanced features like TLSDESC.

For Context
elf_link_hash_entry
A data structure used by the linker to store information about symbols during the linking process, including their type, address, and other attributes.
Relaxation
A linker optimization process that adjusts addresses and instructions after an initial layout to improve code density or fix addressability issues.
TLS
Thread-Local Storage. A mechanism that provides each thread with its own copy of a variable.
Relocation
Information in an object file that describes how to modify addresses and other values when the file is linked with other files or loaded into memory.
Filed Under: risc-vlinkertlsrelaxation