RISC-V: Recognize $x.<any> and $d.<any> mapping symbols
Binutils now correctly recognizes RISC-V mapping symbols like $x.<n> and $d.<n>, improving objdump's disassembly.
This patch enhances binutils’ handling of RISC-V mapping symbols by recognizing suffixes like ‘.
- proposer
Submits a patch to binutils to correctly recognize RISC-V mapping symbols with suffixes, such as $x.<n> and $d.<n>, which are emitted by clang.
“The psABI allows a ".<any>" suffix on the $x and $d mapping symbols, and clang emits $x.<n>. objdump only handled the bare names, so it kept the previous ISA or state and printed the symbols as labels.”
- contributor
The original author of the work, whose patch is being submitted by Kito Cheng.
- reviewer
Reviews the patch, suggesting the use of `startswith()` for the checks and noting that this change will be committed.
“Use startswith() for these checks, and for the existing $xrv one too.”
- reviewer
Asks a clarifying question about the change, specifically regarding the use of `startswith()`.
“On 20.11.2026 15:26, Kito Cheng wrote: > From: Jerry Zhang Jian <jerry.zhangjian@sifive.com> > > The psABI allows a ".<any>" suffix on the $x and $d mapping symbols, and clang emits $x.<n>. objdump only handled the bare names, so it kept the previous ISA or state and printed the symbols as labels.”
Technical Tradeoffs
- Improves disassembly accuracy for RISC-V code using specific compiler extensions.
- Ensures better compliance with RISC-V psABI conventions.
In Details
This patch modifies bfd/cpu-riscv.c to correctly identify RISC-V mapping symbols that include suffixes, such as $x.rv32 or $d.lstm. The psABI allows these suffixes, and compilers like clang emit them. The previous implementation in objdump (via BFD) only recognized the base symbols $x and $d, misinterpreting suffixed symbols as standard labels. The fix uses strncmp (updated to startswith in a later revision) to handle these suffixed symbols, improving disassembly accuracy.
- RISC-V
- An open-standard instruction set architecture based on RISC principles.
- psABI
- The Application Binary Interface specific to the Platform, often referring to conventions for function calls, data types, and symbol naming.
- objdump
- A utility that displays information from object files, including disassembly.
- mapping symbols
- Special symbols used in RISC-V to indicate processor ISA extensions or modes.
- BFD
- Binutils Format Description, a library used by binutils to support various object file formats.