RISC-V: add an "arch=" disassembler option
Reviewer Jiawei expresses concern about handling invalid ISA strings in the RISC-V disassembler's new 'arch=' option and suggests adding a test case.
A patch introduces an ‘arch=’ option to the RISC-V disassembler to override the default ISA, particularly useful for core files. A reviewer raises concerns about the unconditional update of the default architecture and the lack of error checking during subset parsing, which could leave the disassembler in an inconsistent state. The reviewer suggests preserving the previous valid state on parsing failure and adding a test case.
- reviewer
Raises concerns about the handling of invalid ISA strings and suggests preserving the previous state on parsing failure, along with adding a test case.
“The 'riscv_dis_set_arch' updates 'default_arch' unconditionally, while 'riscv_dis_parse_subset' releases the existing subset list without checking whether 'riscv_parse_subset succeeds'. An invalid value could therefore leave the disassembler with a partially updated architecture state.”
- proposer
Submitted a patch to add an 'arch=' option to the RISC-V disassembler to override the ISA, especially for core files.
Technical Tradeoffs
- Adding an "arch=" option provides flexibility but requires careful validation of ISA strings to maintain disassembler integrity.
- Balancing the default ISA inference with user-provided overrides, ensuring precedence rules are clear and consistently applied.
In Details
This discussion concerns a patch to binutils' RISC-V disassembler, introducing an "arch=" option. This option allows overriding the default ISA string used for disassembly, which is typically inferred from the object file's architecture attribute or defaults to rv64gc. The motivation stems from scenarios like analyzing core files where the executable's ISA is unknown. The reviewer's feedback focuses on robust error handling for invalid ISA strings and ensuring architectural state consistency within the disassembler.
- RISC-V
- An open-standard instruction set architecture (ISA) based on reduced instruction set computer (RISC) principles.
- disassembler
- A program that translates machine code (binary) back into assembly language.
- ISA
- Instruction Set Architecture. Defines the set of instructions that a processor can execute.
- core file
- A file that contains a snapshot of a program's memory and state at the time it crashed.