Make riscv_parse_subset_t's isa_spec only parser input
The `isa_spec` field in RISC-V subset parsing is now read-only, clarifying its role as input.
This commit clarifies the purpose of the isa_spec field within the riscv_parse_subset_t structure by converting it to a pointer-to-const. This modification, along with removing an indirection in riscv_get_default_ext_version(), ensures that the parsing logic treats isa_spec strictly as input and cannot inadvertently alter its value. This improves code clarity and reinforces the immutability of the specification class during parsing, preventing potential side effects.
In Details
The riscv_parse_subset_t structure in the RISC-V BFD backend (bfd/elfxx-riscv.h) is used to pass context to the ISA extension parsing functions. Its isa_spec field indicates the ISA specification class (e.g., 'draft' or 'stable') to be used for default extension versions. This commit changes isa_spec to const enum riscv_spec_class *, making it a pointer to a constant. This explicitly marks isa_spec as an input parameter that the parser should not modify. The corresponding adjustment in riscv_get_default_ext_version() removes an unnecessary indirection when accessing this value,…
For Context
Imagine you have a detailed instruction manual for building something (like a RISC-V processor's features), and you hand it to someone to follow. This commit is like putting that manual into a read-only binder. The isa_spec field within the Binutils tools specifies which version of the RISC-V instruction set architecture (ISA) rules to follow (e.g., a 'draft' version versus a 'stable' one). By making this field 'read-only' (pointer-to-const), the developers are making it clear that the part of the tool that *reads* these rules should not accidentally *change* them. This makes the code more robust and easier for other developers to understand, as it explicitly defines what parts of the system are for input only.