RISC-V: ".option arch" with unimplemented extensions
Corrects assembler behavior for RISC-V architecture extensions, ensuring unimplemented extensions are rejected.
This patch addresses an issue in the RISC-V assembler where certain unimplemented extensions, like ‘+p’, were accepted when using the .option arch directive. The fix modifies the riscv_update_subset1 function to correctly handle the explicit_subset parameter, ensuring that only valid and implemented extensions are accepted. This change aims to prevent the assembler from incorrectly processing or ignoring unsupported architecture features, thereby maintaining stricter adherence to the RISC-V specification.
- proposer
Proposes changes to `riscv_update_subset1` to correctly reject unimplemented RISC-V extensions specified via `.option arch`.
“While full specifications like rv32ip are rejected, +p was accepted so far. The same diagnostic wants issuing there, though. As it turns out, riscv_update_subset1() unconditionally passing "true" to riscv_parse_add_subset() is wrong. As it further turns out, riscv_update_subset1()'s "explicit_subset" parameter is really used as only a boolean. Convert it to a real boolean (inverting sense), and r…”
In Details
This patch modifies the RISC-V assembler's handling of the .option arch directive, specifically concerning the riscv_update_subset1 function in elfxx-riscv.c. Previously, the assembler incorrectly accepted syntax like .option arch,+p, even though the '+p' extension might not be fully implemented or recognized. The fix refactors riscv_update_subset1 to correctly use its parameters to distinguish between explicit .option arch arguments and implicit extensions. It renames explicit_subset to exts and converts an implicit boolean flag into a proper bool parameter, ensuring that u…
- RISC-V
- An open-standard instruction set architecture (ISA) based on reduced instruction set computer principles. It is modular and extensible.
- .option arch
- An assembler directive used in binutils to specify or modify the target architecture and its extensions for RISC-V code generation.
- extension
- In the context of RISC-V, an extension is a set of additional instructions that augment the base ISA (e.g., 'M' for integer multiplication/division, 'A' for atomic operations, 'F'/'D' for floating-point, 'V' for vector operations). They are often denoted by letters appended to the base ISA, like 'RV64IMAFD'.
- assembler directive
- A command within an assembly language source file that provides information to the assembler, such as defining data, controlling the assembly process, or specifying target features.
- ISA
- Instruction Set Architecture. The part of the processor architecture visible to the assembly language programmer or compiler writer.