Add RISC-V note types to readelf
Readelf now supports displaying new RISC-V note types for vector, tagged address control, and user CFI.
This patch updates the readelf utility to recognize and display three new RISC-V-specific ELF note types: NT_RISCV_VECTOR, NT_RISCV_TAGGED_ADDR_CTRL, and NT_RISCV_USER_CFI. These additions align binutils with recent definitions in the Linux kernel’s ELF headers, enabling better inspection of RISC-V executables.
- proposer
Adds definitions and string values for three new RISC-V note types to binutils' readelf.
“Add definitions and string values for note types * NT_RISCV_VECTOR 0x901 * NT_RISCV_TAGGED_ADDR_CTRL 0x902 * NT_RISCV_USER_CFI 0x903”
- reviewer
Acknowledges the patch as largely okay, but points out a minor nit regarding the formatting of comment lines in the header file.
“Largely okay, one nit:”
Technical Tradeoffs
- Improves visibility into RISC-V binaries by supporting new note types.
- Minimal performance impact, primarily affects parsing of ELF files with these notes.
In Details
This patch adds support for new RISC-V ELF note types (NT_RISCV_VECTOR, NT_RISCV_TAGGED_ADDR_CTRL, NT_RISCV_USER_CFI) to the readelf utility. These notes, defined in Linux kernel headers, provide information about RISC-V specific features, such as vector registers and control flow integrity state. The change ensures readelf can correctly parse and display these notes when examining RISC-V ELF binaries.
- readelf
- A command-line utility that displays information about ELF (Executable and Linkable Format) files, including headers, section details, symbol tables, and notes.
- ELF note
- A section in an ELF file that contains miscellaneous information, often vendor-specific, for tools or the runtime environment. Notes are identified by a name and a type.
- NT_RISCV_VECTOR
- An ELF note type specific to RISC-V, intended to describe the state of vector registers.
- NT_RISCV_TAGGED_ADDR_CTRL
- An ELF note type for RISC-V that conveys control information related to tagged memory addressing.
- NT_RISCV_USER_CFI
- An ELF note type for RISC-V, likely related to user-space Control Flow Integrity (CFI) state, possibly for shadow stack information.