mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-27 08:12:44 +00:00
Add RAnal.Stack.RESET and handle it for arm64
This commit is contained in:
parent
45093ffb49
commit
3d89f2cc21
@ -418,6 +418,8 @@ R_API const char *r_anal_stackop_tostring (int s) {
|
||||
return "get";
|
||||
case R_ANAL_STACK_SET:
|
||||
return "set";
|
||||
case R_ANAL_STACK_RESET:
|
||||
return "reset";
|
||||
}
|
||||
return "unk";
|
||||
}
|
||||
|
@ -855,6 +855,15 @@ static void anop64 (RAnalOp *op, cs_insn *insn) {
|
||||
break;
|
||||
case ARM64_INS_SUB:
|
||||
op->type = R_ANAL_OP_TYPE_SUB;
|
||||
if (REGID64(0) == ARM64_REG_SP) {
|
||||
if (REGID64(1) == ARM64_REG_SP) {
|
||||
op->stackop = R_ANAL_STACK_INC;
|
||||
op->stackptr = IMM64(2);
|
||||
} else {
|
||||
op->stackop = R_ANAL_STACK_RESET;
|
||||
op->stackptr = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ARM64_INS_ADD:
|
||||
op->type = R_ANAL_OP_TYPE_ADD;
|
||||
@ -864,6 +873,11 @@ static void anop64 (RAnalOp *op, cs_insn *insn) {
|
||||
op->type = R_ANAL_OP_TYPE_CMOV;
|
||||
break;
|
||||
case ARM64_INS_MOV:
|
||||
if (REGID64(0) == ARM64_REG_SP) {
|
||||
op->stackop = R_ANAL_STACK_RESET;
|
||||
op->stackptr = 0;
|
||||
}
|
||||
/* fallthru */
|
||||
case ARM64_INS_MOVI:
|
||||
case ARM64_INS_MOVK:
|
||||
case ARM64_INS_MOVN:
|
||||
|
@ -1425,12 +1425,16 @@ static void handle_print_cycles(RCore *core, RDisasmState *ds) {
|
||||
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->analop.type == R_ANAL_OP_TYPE_CALL?">":
|
||||
ds->analop.stackop == R_ANAL_STACK_ALIGN? "=":
|
||||
ds->stackptr > ds->ostackptr? "+":
|
||||
ds->stackptr < ds->ostackptr? "-": " ");
|
||||
ds->ostackptr = ds->stackptr;
|
||||
ds->stackptr += ds->analop.stackptr;
|
||||
if (ds->analop.stackop == R_ANAL_STACK_RESET) {
|
||||
ds->stackptr = 0;
|
||||
} else {
|
||||
ds->stackptr += ds->analop.stackptr;
|
||||
}
|
||||
/* XXX if we reset the stackptr 'ret 0x4' has not effect.
|
||||
* Use RAnalFunction->RAnalOp->stackptr? */
|
||||
if (ds->analop.type == R_ANAL_OP_TYPE_RET)
|
||||
|
@ -526,6 +526,7 @@ enum {
|
||||
R_ANAL_STACK_INC,
|
||||
R_ANAL_STACK_GET,
|
||||
R_ANAL_STACK_SET,
|
||||
R_ANAL_STACK_RESET,
|
||||
R_ANAL_STACK_ALIGN,
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user