mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-23 14:28:07 +00:00
Add anal.rnr option
This commit is contained in:
parent
536654bb9f
commit
a0b12e3506
@ -558,6 +558,7 @@ R_API int r_anal_noreturn_drop(RAnal *anal, const char *expr) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool r_anal_noreturn_at_name(RAnal *anal, const char *name) {
|
||||
if (sdb_bool_get (anal->sdb_types, K_NORET_FUNC(name), NULL)) {
|
||||
return true;
|
||||
@ -574,7 +575,7 @@ static bool r_anal_noreturn_at_name(RAnal *anal, const char *name) {
|
||||
}
|
||||
|
||||
R_API bool r_anal_noreturn_at_addr(RAnal *anal, ut64 addr) {
|
||||
return sdb_bool_get (anal->sdb_types, K_NORET_ADDR(addr), NULL);
|
||||
return sdb_bool_get (anal->sdb_types, K_NORET_ADDR (addr), NULL);
|
||||
}
|
||||
|
||||
bool noreturn_recurse(RAnal *anal, ut64 addr) {
|
||||
@ -585,7 +586,8 @@ bool noreturn_recurse(RAnal *anal, ut64 addr) {
|
||||
eprintf ("Couldn't read buffer\n");
|
||||
return false;
|
||||
}
|
||||
r_anal_op (anal, &op, addr, bbuf, sizeof (bbuf));
|
||||
// TODO: check return value
|
||||
(void)r_anal_op (anal, &op, addr, bbuf, sizeof (bbuf));
|
||||
switch (op.type & R_ANAL_OP_TYPE_MASK) {
|
||||
case R_ANAL_OP_TYPE_JMP:
|
||||
if (op.jump == UT64_MAX) {
|
||||
@ -605,8 +607,7 @@ bool noreturn_recurse(RAnal *anal, ut64 addr) {
|
||||
recurse_addr = op.jump;
|
||||
break;
|
||||
}
|
||||
if (recurse_addr == UT64_MAX
|
||||
|| recurse_addr == addr) {
|
||||
if (recurse_addr == UT64_MAX || recurse_addr == addr) {
|
||||
return false;
|
||||
}
|
||||
return r_anal_noreturn_at (anal, recurse_addr);
|
||||
@ -639,7 +640,10 @@ R_API bool r_anal_noreturn_at(RAnal *anal, ut64 addr) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return noreturn_recurse (anal, addr);
|
||||
if (anal->recursive_noreturn) {
|
||||
return noreturn_recurse (anal, addr);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// based on anal hint we construct a list of RAnalRange to handle
|
||||
|
@ -277,8 +277,8 @@ static int cb_analarch(void *user, void *data) {
|
||||
if (!aa || strcmp (aa, node->value)) {
|
||||
eprintf ("anal.arch: cannot find '%s'\n", node->value);
|
||||
} else {
|
||||
r_config_set (core->config, "anal.arch", "null");
|
||||
return true;
|
||||
r_config_set (core->config, "anal.arch", "null");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -1966,6 +1966,12 @@ static int cb_anal_limits(void *user, RConfigNode *node) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int cb_anal_rnr(void *user, RConfigNode *node) {
|
||||
RCore *core = (RCore*)user;
|
||||
core->anal->recursive_noreturn = node->i_value;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int cb_anal_jmptbl(void *user, void *data) {
|
||||
RCore *core = (RCore*) user;
|
||||
RConfigNode *node = (RConfigNode*) data;
|
||||
@ -2142,6 +2148,8 @@ R_API int r_core_config_init(RCore *core) {
|
||||
SETPREF ("anal.a2f", "false", "Use the new WIP analysis algorithm (core/p/a2f), anal.depth ignored atm");
|
||||
SETICB ("anal.gp", 0, (RConfigCallback)&cb_anal_gp, "Set the value of the GP register (MIPS)");
|
||||
SETCB ("anal.limits", "false", (RConfigCallback)&cb_anal_limits, "Restrict analysis to address range [anal.from:anal.to]");
|
||||
SETCB ("anal.rnr", "false", (RConfigCallback)&cb_anal_rnr, "Recursive no return checks (EXPERIMENTAL)");
|
||||
SETCB ("anal.limits", "false", (RConfigCallback)&cb_anal_limits, "Restrict analysis to address range [anal.from:anal.to]");
|
||||
SETICB ("anal.from", -1, (RConfigCallback)&cb_anal_from, "Lower limit on the address range for analysis");
|
||||
SETICB ("anal.to", -1, (RConfigCallback)&cb_anal_from, "Upper limit on the address range for analysis");
|
||||
n = NODECB ("anal.in", "io.maps", &cb_searchin);
|
||||
|
@ -640,7 +640,7 @@ typedef struct r_anal_t {
|
||||
dict *dict_refs;
|
||||
dict *dict_xrefs;
|
||||
#endif
|
||||
|
||||
bool recursive_noreturn;
|
||||
RSpaces meta_spaces;
|
||||
RSpaces zign_spaces;
|
||||
char *zign_path;
|
||||
|
Loading…
x
Reference in New Issue
Block a user