binutils Newspaper
JUNE 15, 2026
risc-v Ready to Land

RISC-V: riscv_parse_subset_t's isa_spec is only parser input

Makes the ``isa_spec`` field in the ``riscv_parse_subset_t`` struct a pointer-to-const to clarify it's only an input to the parser.

This patch modifies the riscv_parse_subset_t struct to make the isa_spec field a pointer to a constant value. This change clarifies that the parsing process won’t alter the isa_spec field, which specifies the RISC-V specification class.

In the Thread 1 participant
  1. Jiawei <jiawei@iscas.ac.cn> proposer

    States that making the field a pointer-to-const clarifies that parsing won't alter the field and removes indirection from ``riscv_get_default_ext_version``.

    “Make the field pointer-to-const and drop indirection from riscv_get_default_ext_version(). This way it's more clear that parsing won't alter the field.”

In Details

The RISC-V backend uses the riscv_parse_subset_t struct to manage the parsing of RISC-V architecture strings. The isa_spec field indicates the specification class (e.g., draft, ratified). This patch changes the field to be a pointer to const, signaling that the parser should not modify this value. The affected code is in bfd/elfxx-riscv.c and bfd/elfxx-riscv.h.

For Context

When the compiler parses the RISC-V architecture string, it uses a data structure (riscv_parse_subset_t) to keep track of the parsing state. The isa_spec field in this structure indicates which version of the RISC-V specification is being used. This patch makes it clear that the parser doesn't change the specification version during parsing.

Filed Under: risc-visa_specconst correctness