Use dynamically allocated *next (+15% analysis speedup + better analysis)
This commit is contained in:
parent
d7d351416d
commit
4bb63d4c2e
3 changed files with 15 additions and 15 deletions
|
|
@ -307,7 +307,7 @@ static int MACH0_(r_bin_mach0_init_items)(struct MACH0_(r_bin_mach0_obj_t)* bin)
|
|||
// TODO table of non-instructions in __text
|
||||
break;
|
||||
case LC_RPATH:
|
||||
eprintf ("--->\n");
|
||||
//eprintf ("--->\n");
|
||||
break;
|
||||
case LC_SEGMENT_64:
|
||||
case LC_SEGMENT:
|
||||
|
|
|
|||
|
|
@ -314,18 +314,24 @@ static int iscodesection(RCore *core, ut64 addr) {
|
|||
|
||||
// XXX: This function takes sometimes forever
|
||||
R_API int r_core_anal_fcn(RCore *core, ut64 at, ut64 from, int reftype, int depth) {
|
||||
int has_next = r_config_get_i (core->config, "anal.hasnext");
|
||||
RListIter *iter, *iter2;
|
||||
int buflen, fcnlen = 0;
|
||||
RAnalFunction *fcn = NULL, *fcni;
|
||||
RAnalRef *ref = NULL, *refi;
|
||||
ut64 *next = NULL;
|
||||
# define next_append(x) {\
|
||||
next = realloc (next, sizeof (ut64)*(1+nexti)); \
|
||||
next[nexti] = (x); \
|
||||
nexti++; \
|
||||
}
|
||||
int i, nexti = 0;
|
||||
ut8 *buf;
|
||||
|
||||
if (core->anal->cur && core->anal->cur->analyze_fns) {
|
||||
int result = R_ANAL_RET_ERROR;
|
||||
r_bin_bind(core->bin, &(core->anal->binb));
|
||||
result = core->anal->cur->analyze_fns( core->anal, at, from, reftype, depth);
|
||||
r_bin_bind (core->bin, &(core->anal->binb));
|
||||
result = core->anal->cur->analyze_fns (core->anal, at, from, reftype, depth);
|
||||
// do this to prevent stale usage and catch others who are using it
|
||||
//memset(&core->anal->binb, 0, sizeof(RBinBind));
|
||||
r_list_foreach (core->anal->fcns, iter, fcni) {
|
||||
|
|
@ -385,9 +391,6 @@ fcn->name = r_str_newf ("fcn.%08"PFMT64x, at);
|
|||
eprintf ("Error: malloc (buf)\n");
|
||||
goto error;
|
||||
}
|
||||
#define MAXNEXT 1032 // TODO: make it relocatable
|
||||
if (r_config_get_i (core->config, "anal.hasnext"))
|
||||
next = R_NEWS0 (ut64, MAXNEXT);
|
||||
|
||||
//eprintf ("FUNC 0x%08"PFMT64x"\n", at+fcnlen);
|
||||
do {
|
||||
|
|
@ -460,8 +463,7 @@ fcn->name = r_str_newf ("fcn.%08"PFMT64x, at);
|
|||
}
|
||||
// XXX: this looks weird
|
||||
r_anal_fcn_insert (core->anal, fcn);
|
||||
#if 1
|
||||
if (next && nexti<MAXNEXT) {
|
||||
if (has_next) {
|
||||
int i;
|
||||
ut64 addr = fcn->addr + fcn->size;
|
||||
for (i=0; i<nexti; i++)
|
||||
|
|
@ -472,10 +474,9 @@ fcn->name = r_str_newf ("fcn.%08"PFMT64x, at);
|
|||
r_cons_clear_line ();
|
||||
eprintf ("FUNC 0x%08"PFMT64x" > 0x%08"PFMT64x"\r",
|
||||
fcn->addr, fcn->addr + fcn->size);
|
||||
next[nexti++] = fcn->addr + fcn->size;
|
||||
next_append (fcn->addr+fcn->size);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
r_list_foreach (fcn->refs, iter, refi) {
|
||||
if (refi->addr != UT64_MAX) {
|
||||
switch (refi->type) {
|
||||
|
|
@ -507,7 +508,7 @@ fcn->name = r_str_newf ("fcn.%08"PFMT64x, at);
|
|||
} while (fcnlen != R_ANAL_RET_END);
|
||||
free (buf);
|
||||
|
||||
if (next) {
|
||||
if (has_next) {
|
||||
for (i=0; i<nexti; i++) {
|
||||
if (!next[i]) continue;
|
||||
r_core_anal_fcn (core, next[i], from, 0, depth-1);
|
||||
|
|
@ -548,9 +549,8 @@ error:
|
|||
#endif
|
||||
}
|
||||
}
|
||||
if (next) {
|
||||
if (nexti<MAXNEXT)
|
||||
next[nexti++] = fcn->addr + fcn->size;
|
||||
if (has_next) {
|
||||
next_append (fcn->addr+fcn->size);
|
||||
for (i=0; i<nexti; i++) {
|
||||
if (!next[i]) continue;
|
||||
r_core_anal_fcn (core, next[i], next[i], 0, depth-1);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ R_API RSList *r_slist_add (RSList *s, void *data, ut64 from, ut64 to) {
|
|||
item->data = data;
|
||||
r_list_append (s->list, item); // item must be alloacted by slices
|
||||
// find slot
|
||||
slot = r_slist_get_slot(s, from);
|
||||
slot = r_slist_get_slot (s, from);
|
||||
if (slot<0) {
|
||||
//r_slist_optimize ();
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Reference in a new issue