diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c index 7ace584fe4a..5c4382b99f0 100644 --- a/opcodes/riscv-dis.c +++ b/opcodes/riscv-dis.c @@ -68,6 +68,10 @@ static bool no_aliases = false; /* If set, disassemble with numeric registers. */ static bool is_numeric = false; +/* Reset when either arch or option is changed. */ +static bool is_init_csr = false; + + static void set_default_riscv_dis_options (void) { @@ -178,6 +182,8 @@ init_dis_per_arch_and_options (void) /* If arch has Zfinx extension, use GPR to disassemble. */ if (riscv_subset_supports (&riscv_rps_dis, "zfinx")) riscv_fpr_names = riscv_gpr_names; + /* Reset CSR hashtable because `priv-spec' option may change the names. */ + is_init_csr = false; } /* Print one argument from an array. */ @@ -534,10 +540,9 @@ print_insn_args (const char *oparg, insn_t l, bfd_vma pc, disassemble_info *info case 'E': { static const char *riscv_csr_hash[4096]; /* Total 2^12 CSRs. */ - static bool init_csr = false; unsigned int csr = EXTRACT_OPERAND (CSR, l); - if (!init_csr) + if (!is_init_csr) { unsigned int i; for (i = 0; i < 4096; i++) @@ -558,6 +563,7 @@ print_insn_args (const char *oparg, insn_t l, bfd_vma pc, disassemble_info *info DECLARE_CSR (name, num, class, define_version, abort_version) #include "opcode/riscv-opc.h" #undef DECLARE_CSR + is_init_csr = true; } if (riscv_csr_hash[csr] != NULL)