Honor anal.depth instead of harcoded value. Fixes aac in avr

This commit is contained in:
pancake 2018-02-07 00:02:40 +01:00
parent 52361460bb
commit 56f553b69a
5 changed files with 12 additions and 4 deletions

View File

@ -70,6 +70,7 @@ R_API RAnal *r_anal_new() {
anal->decode = true; // slow slow if not used
anal->gp = 0LL;
anal->sdb = sdb_new0 ();
anal->opt.depth = 32;
anal->opt.noncode = false; // do not analyze data by default
r_space_new (&anal->meta_spaces, "CS", meta_unset_for, meta_count_for, NULL, anal);
r_space_new (&anal->zign_spaces, "zs", zign_unset_for, zign_count_for, zign_rename_for, anal);

View File

@ -1383,7 +1383,7 @@ R_API int r_anal_fcn(RAnal *anal, RAnalFunction *fcn, ut64 addr, ut8 *buf, ut64
}
}
fcn->maxstack = 0;
ret = fcn_recurse (anal, fcn, addr, buf, len, FCN_DEPTH);
ret = fcn_recurse (anal, fcn, addr, buf, len, anal->opt.depth);
// update tinyrange for the function
r_anal_fcn_update_tinyrange_bbs (fcn);

View File

@ -2922,7 +2922,7 @@ R_API int r_core_anal_all(RCore *core) {
RBinAddr *binmain;
RBinAddr *entry;
RBinSymbol *symbol;
int depth = r_config_get_i (core->config, "anal.depth");
int depth = core->anal->opt.depth;
bool anal_vars = r_config_get_i (core->config, "anal.vars");
/* Analyze Functions */

View File

@ -191,6 +191,13 @@ static int cb_analeobjmp(void *user, void *data) {
return true;
}
static int cb_analdepth(void *user, void *data) {
RCore *core = (RCore*) user;
RConfigNode *node = (RConfigNode*) data;
core->anal->opt.depth = node->i_value;
return true;
}
static int cb_analafterjmp(void *user, void *data) {
RCore *core = (RCore*) user;
RConfigNode *node = (RConfigNode*) data;
@ -588,7 +595,6 @@ static int cb_asmbits(void *user, void *data) {
(void)r_anal_set_reg_profile (core->anal);
}
}
asmos = r_config_get (core->config, "asm.os");
asmarch = r_config_get (core->config, "asm.arch");
asmcpu = r_config_get (core->config, "asm.cpu");
@ -2234,7 +2240,7 @@ R_API int r_core_config_init(RCore *core) {
SETCB ("anal.armthumb", "false", &cb_analarmthumb, "aae computes arm/thumb changes (lot of false positives ahead)");
SETCB ("anal.eobjmp", "false", &cb_analeobjmp, "jmp is end of block mode (option)");
SETCB ("anal.afterjmp", "true", &cb_analafterjmp, "Continue analysis after jmp/ujmp");
SETI ("anal.depth", 16, "Max depth at code analysis"); // XXX: warn if depth is > 50 .. can be problematic
SETICB ("anal.depth", 16, &cb_analdepth, "Max depth at code analysis"); // XXX: warn if depth is > 50 .. can be problematic
SETICB ("anal.sleep", 0, &cb_analsleep, "Sleep N usecs every so often during analysis. Avoid 100% CPU usage");
SETPREF ("anal.calls", "false", "Make basic af analysis walk into calls");
SETPREF ("anal.autoname", "true", "Automatically set a name for the functions, may result in some false positives");

View File

@ -573,6 +573,7 @@ typedef struct r_anal_callbacks_t {
#define R_ANAL_ESIL_GOTO_LIMIT 4096
typedef struct r_anal_options_t {
int depth;
int cjmpref;
int jmpref;
int jmpabove;