mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-08 06:47:33 +00:00
Implement stackptr analysis in MIPS and add ALIGN stackop type
This commit is contained in:
parent
c28dce2359
commit
20b49f1615
@ -75,7 +75,6 @@ static int meta_count_for(void *user, int idx) {
|
||||
|
||||
R_API RAnal *r_anal_new() {
|
||||
int i;
|
||||
RAnalPlugin *static_plugin;
|
||||
RAnal *anal = R_NEW0 (RAnal);
|
||||
if (!anal) return NULL;
|
||||
anal->os = strdup (R_SYS_OS);
|
||||
|
@ -8,6 +8,7 @@
|
||||
// http://www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html
|
||||
|
||||
#define OPERAND(x) insn->detail->mips.operands[x]
|
||||
#define REGID(x) insn->detail->mips.operands[x].reg
|
||||
#define REG(x) cs_reg_name (*handle, insn->detail->mips.operands[x].reg)
|
||||
#define IMM(x) insn->detail->mips.operands[x].imm
|
||||
#define MEMBASE(x) cs_reg_name(*handle, insn->detail->mips.operands[x].mem.base)
|
||||
@ -692,6 +693,10 @@ static int analop(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len)
|
||||
SET_VAL (op, 2);
|
||||
SET_SRC_DST_3_REG_OR_IMM (op);
|
||||
op->type = R_ANAL_OP_TYPE_ADD;
|
||||
if (REGID(0) == MIPS_REG_SP) {
|
||||
op->stackop = R_ANAL_STACK_INC;
|
||||
op->stackptr = -IMM(2);
|
||||
}
|
||||
break;
|
||||
case MIPS_INS_SUB:
|
||||
case MIPS_INS_SUBV:
|
||||
@ -729,6 +734,9 @@ static int analop(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len)
|
||||
SET_VAL (op,2);
|
||||
SET_SRC_DST_3_REG_OR_IMM (op);
|
||||
op->type = R_ANAL_OP_TYPE_AND;
|
||||
if (REGID(0) == MIPS_REG_SP) {
|
||||
op->stackop = R_ANAL_STACK_ALIGN;
|
||||
}
|
||||
break;
|
||||
case MIPS_INS_NOT:
|
||||
op->type = R_ANAL_OP_TYPE_NOT;
|
||||
|
@ -1376,7 +1376,9 @@ static void handle_print_stackptr (RCore *core, RDisasmState *ds) {
|
||||
if (ds->show_stackptr) {
|
||||
r_cons_printf ("%5d%s", ds->stackptr,
|
||||
ds->analop.type==R_ANAL_OP_TYPE_CALL?">":
|
||||
ds->stackptr>ds->ostackptr?"+":ds->stackptr<ds->ostackptr?"-":" ");
|
||||
ds->analop.stackop == R_ANAL_STACK_ALIGN? "=":
|
||||
ds->stackptr > ds->ostackptr? "+":
|
||||
ds->stackptr < ds->ostackptr? "-": " ");
|
||||
ds->ostackptr = ds->stackptr;
|
||||
ds->stackptr += ds->analop.stackptr;
|
||||
/* XXX if we reset the stackptr 'ret 0x4' has not effect.
|
||||
|
@ -528,6 +528,7 @@ enum {
|
||||
R_ANAL_STACK_INC,
|
||||
R_ANAL_STACK_GET,
|
||||
R_ANAL_STACK_SET,
|
||||
R_ANAL_STACK_ALIGN,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
Loading…
x
Reference in New Issue
Block a user