Recognize RISC-V $x.<any> and $d.<any> mapping symbols
Binutils now correctly interprets RISC-V mapping symbols with suffixes for better debugging information.
This commit improves Binutils’ handling of RISC-V mapping symbols used for debugging. The psABI specification allows for suffixes like . <any> on $x and $d mapping symbols, which compilers like Clang can emit (e.g., $x. <n>). Previously, Binutils’ disassembler (objdump) and other tools only recognized the bare symbols, leading to incorrect interpretation or display of debugging information. The change updates the recognition logic to use startswith() for these symbols, ensuring that suffixed mapping symbols are properly identified.
In Details
This patch enhances the RISC-V support in Binutils, specifically in bfd/cpu-riscv.c and opcodes/riscv-dis.c, to correctly handle RISC-V psABI mapping symbols that include suffixes. The riscv_elf_is_mapping_symbols function is updated to use startswith() to match symbols like $d.<any> and $x.<any>, in addition to the existing $xrv prefix check. This is necessary because Clang can emit symbols such as $x. <n>, and older matching logic was too strict. This change ensures that objdump and other tools can correctly identify these symbols, which are crucial for accurate debugging an…
- psABI
- The Application Binary Interface (ABI) for the process- and thread-local storage mechanisms in POSIX-compliant systems. For RISC-V, it defines conventions for function calls, register usage, and symbol naming.
- mapping symbols
- Special symbols used in debugging information that map specific register or state values to meaningful names. In RISC-V,
$xand$dare examples related to register file access. - objdump
- A standard Unix utility that displays information from object files. It can show disassembly, symbol tables, and other details.