From db299d28cc2b6e4b2fd68d876b080071b95f1c91 Mon Sep 17 00:00:00 2001 From: pancake Date: Tue, 12 Sep 2023 23:45:58 +0200 Subject: [PATCH] Fix arch.riscv.vs plugin (decoding always failed) ##arch --- libr/arch/p/capstone.inc.c | 10 +++++++--- libr/arch/p/mcs96/plugin.c | 1 - libr/arch/p/riscv_cs/plugin.c | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libr/arch/p/capstone.inc.c b/libr/arch/p/capstone.inc.c index 983aeb3888..89ad8ec108 100644 --- a/libr/arch/p/capstone.inc.c +++ b/libr/arch/p/capstone.inc.c @@ -76,14 +76,18 @@ static bool r_arch_cs_init(RArchSession *as, csh *cs_handle) { } #else if (*cs_handle) { - if (as->config->syntax == R_ARCH_SYNTAX_ATT) { + switch (as->config->syntax) { + case R_ARCH_SYNTAX_ATT: cs_option (*cs_handle, CS_OPT_SYNTAX, CS_OPT_SYNTAX_ATT); + break; #if CS_API_MAJOR >= 4 - } else if (as->config->syntax == R_ARCH_SYNTAX_MASM) { + case R_ARCH_SYNTAX_MASM: cs_option (*cs_handle, CS_OPT_SYNTAX, CS_OPT_SYNTAX_MASM); + break; #endif - } else { + default: cs_option (*cs_handle, CS_OPT_SYNTAX, CS_OPT_SYNTAX_INTEL); + break; } } #endif diff --git a/libr/arch/p/mcs96/plugin.c b/libr/arch/p/mcs96/plugin.c index 02336dbfc5..9ffc3b96ac 100644 --- a/libr/arch/p/mcs96/plugin.c +++ b/libr/arch/p/mcs96/plugin.c @@ -119,7 +119,6 @@ static bool decode(RArchSession *as, RAnalOp *op, RArchDecodeMask mask) { // WORDs must be aligned at even byte boundaries in the address space static int archinfo(RArchSession *as, ut32 q) { - // R2_590 switch (q) { case R_ANAL_ARCHINFO_ALIGN: return 1; diff --git a/libr/arch/p/riscv_cs/plugin.c b/libr/arch/p/riscv_cs/plugin.c index 6d296f676a..d0da61c439 100644 --- a/libr/arch/p/riscv_cs/plugin.c +++ b/libr/arch/p/riscv_cs/plugin.c @@ -259,7 +259,7 @@ static void set_opdir(RAnalOp *op) { } #define CSINC RISCV -#define CSINC_MODE (as->config->bits == 64)? CS_MODE_RISCV64: CS_MODE_RISCV32 +#define CSINC_MODE (CS_MODE_RISCVC | ((as->config->bits == 64)? CS_MODE_RISCV64: CS_MODE_RISCV32)) #include "../capstone.inc.c" static bool riscv_decode(RArchSession *a, RAnalOp *op, RArchDecodeMask mask) {