mirror of
https://github.com/capstone-engine/capstone
synced 2026-08-11 16:26:07 -04:00
Fix selection of mips disasm handler (#1022)
* Fix selection of mips disasm handler handle->disasm was incorrectly set to Mips64_getInstruction if CS_MODE_MIPS32R6 was set but CS_MODE_32 was not set. Now, CS_MODE_32 is set automatically if CS_MODE_MIPS32R6 is set. * Align with current style
This commit is contained in:
parent
20343cc03b
commit
94bce437e8
1 changed files with 13 additions and 1 deletions
|
|
@ -9,6 +9,16 @@
|
|||
#include "MipsInstPrinter.h"
|
||||
#include "MipsMapping.h"
|
||||
|
||||
// Returns mode value with implied bits set
|
||||
static inline cs_mode updated_mode(cs_mode mode)
|
||||
{
|
||||
if (mode & CS_MODE_MIPS32R6) {
|
||||
mode |= CS_MODE_32;
|
||||
}
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
static cs_err init(cs_struct *ud)
|
||||
{
|
||||
MCRegisterInfo *mri;
|
||||
|
|
@ -30,7 +40,8 @@ static cs_err init(cs_struct *ud)
|
|||
ud->insn_name = Mips_insn_name;
|
||||
ud->group_name = Mips_group_name;
|
||||
|
||||
if (ud->mode & CS_MODE_32 || ud->mode & CS_MODE_MIPS32R6)
|
||||
ud->mode = updated_mode(ud->mode);
|
||||
if (ud->mode & CS_MODE_32)
|
||||
ud->disasm = Mips_getInstruction;
|
||||
else
|
||||
ud->disasm = Mips64_getInstruction;
|
||||
|
|
@ -41,6 +52,7 @@ static cs_err init(cs_struct *ud)
|
|||
static cs_err option(cs_struct *handle, cs_opt_type type, size_t value)
|
||||
{
|
||||
if (type == CS_OPT_MODE) {
|
||||
value = updated_mode(value);
|
||||
if (value & CS_MODE_32)
|
||||
handle->disasm = Mips_getInstruction;
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue