Deduplicate java function entries.
This commit is contained in:
David CARLIER 2018-09-08 16:28:54 +00:00 committed by radare
parent 3b88e32ea8
commit 1eae637f4b
2 changed files with 11 additions and 1 deletions

View File

@ -568,6 +568,13 @@ static int analyze_method(RAnal *anal, RAnalFunction *fcn, RAnalState *state) {
return state->anal_ret_val;
}
static int functionCmp(const void *a, const void *b) {
const RAnalFunction *fa = (const RAnalFunction *)a;
const RAnalFunction *fb = (const RAnalFunction *)b;
return strcmp (fa->name, fb->name);
}
static int java_analyze_fns_from_buffer( RAnal *anal, ut64 start, ut64 end, int reftype, int depth) {
int result = R_ANAL_RET_ERROR;
ut64 addr = start;
@ -619,6 +626,7 @@ static int java_analyze_fns( RAnal *anal, ut64 start, ut64 end, int reftype, int
RBinJavaField *method = NULL;
RListIter *methods_iter, *bin_obs_iter;
RList * bin_objs_list = get_java_bin_obj_list (anal);
RList * anal_fcns = NULL;
ut8 analyze_all = 0;
//RAnalRef *ref = NULL;
@ -658,6 +666,8 @@ static int java_analyze_fns( RAnal *anal, ut64 start, ut64 end, int reftype, int
}
} // End of methods loop
}// end of bin_objs list loop
anal_fcns = r_list_clone (anal->fcns);
anal->fcns = r_list_uniq (anal_fcns, functionCmp);
return result;
}

View File

@ -2295,7 +2295,7 @@ R_API ut64 r_bin_java_parse_methods(RBinJavaObj *bin, const ut64 offset, const u
// get main code attr
bin->main_code_attr = r_bin_java_get_attr_from_field (method, R_BIN_JAVA_ATTR_TYPE_CODE_ATTR, 0);
} else if (method && (!strcmp ((const char *) method->name, "<init>") || !strcmp ((const char *) method->name, "init"))) {
IFDBG eprintf("FOund an init function.\n");
IFDBG eprintf("Found an init function.\n");
bin->entrypoint = method;
bin->entrypoint_code_attr = r_bin_java_get_attr_from_field (method, R_BIN_JAVA_ATTR_TYPE_CODE_ATTR, 0);
} else if (method && (!strcmp ((const char *) method->name, "<cinit>") || !strcmp ((const char *) method->name, "cinit"))) {