* Simplify type assignment in r_anal
* Include fcn type in 'rabin2 -r' output
This commit is contained in:
parent
cc9cefa74e
commit
ead4e9502f
|
@ -237,7 +237,7 @@ static int rabin_show_imports() {
|
|||
if (rad) {
|
||||
r_flag_name_filter (import->name);
|
||||
if (import->size)
|
||||
printf ("af+ 0x%08"PFMT64x" %"PFMT64d" fcn.imp.%s\n",
|
||||
printf ("af+ 0x%08"PFMT64x" %"PFMT64d" fcn.imp.%s i\n",
|
||||
va?baddr+import->rva:import->offset, import->size, import->name);
|
||||
printf ("fs imports\n");
|
||||
printf ("f imp.%s @ 0x%08"PFMT64x"\n",
|
||||
|
|
|
@ -60,8 +60,6 @@ R_API int r_anal_fcn(RAnal *anal, RAnalFcn *fcn, ut64 addr, ut8 *buf, ut64 len,
|
|||
fcn->addr = addr;
|
||||
if (reftype == R_ANAL_REF_TYPE_CODE)
|
||||
fcn->type = R_ANAL_FCN_TYPE_LOC;
|
||||
else if (reftype == R_ANAL_REF_TYPE_SYM)
|
||||
fcn->type = R_ANAL_FCN_TYPE_SYM;
|
||||
else fcn->type = R_ANAL_FCN_TYPE_FCN;
|
||||
while (idx < len) {
|
||||
if ((oplen = r_anal_aop (anal, &aop, addr+idx, buf+idx, len-idx)) == 0) {
|
||||
|
|
|
@ -615,6 +615,7 @@ R_API int r_core_anal_fcn_cc(RCore *core, ut64 addr) {
|
|||
R_API int r_core_anal_all(RCore *core) {
|
||||
RList *list;
|
||||
RListIter *iter;
|
||||
RAnalFcn *fcni;
|
||||
RBinAddr *binmain;
|
||||
RBinAddr *entry;
|
||||
RBinSymbol *symbol;
|
||||
|
@ -627,18 +628,22 @@ R_API int r_core_anal_all(RCore *core) {
|
|||
/* Main */
|
||||
if ((binmain = r_bin_get_sym (core->bin, R_BIN_SYM_MAIN)) != NULL)
|
||||
r_core_anal_fcn (core, va?baddr+binmain->rva:binmain->offset, -1,
|
||||
R_ANAL_REF_TYPE_SYM, depth);
|
||||
R_ANAL_REF_TYPE_NULL, depth);
|
||||
/* Entries */
|
||||
if ((list = r_bin_get_entries (core->bin)) != NULL)
|
||||
r_list_foreach (list, iter, entry)
|
||||
r_core_anal_fcn (core, va?baddr+entry->rva:entry->offset, -1,
|
||||
R_ANAL_REF_TYPE_SYM, depth);
|
||||
R_ANAL_REF_TYPE_NULL, depth);
|
||||
/* Symbols (Imports are already analized by rabin2 on init) */
|
||||
if ((list = r_bin_get_symbols (core->bin)) != NULL)
|
||||
r_list_foreach (list, iter, symbol)
|
||||
if (!strncmp (symbol->type,"FUNC", 4))
|
||||
r_core_anal_fcn (core, va?baddr+symbol->rva:symbol->offset, -1,
|
||||
R_ANAL_REF_TYPE_SYM, depth);
|
||||
R_ANAL_REF_TYPE_NULL, depth);
|
||||
/* Set fcn type to R_ANAL_FCN_TYPE_SYM for symbols */
|
||||
r_list_foreach (core->anal->fcns, iter, fcni)
|
||||
if (!memcmp (fcni->name, "fcn.sym.", 8) || !memcmp (fcni->name, "sym.", 4))
|
||||
fcni->type = R_ANAL_FCN_TYPE_SYM;
|
||||
|
||||
return R_TRUE;
|
||||
}
|
||||
|
|
|
@ -145,7 +145,8 @@ static void gdiff_diff_fcn(RList *fcns, RList *fcns2) {
|
|||
iter = r_list_iterator (fcns);
|
||||
while (r_list_iter_next (iter)) {
|
||||
fcn = r_list_iter_get (iter);
|
||||
if (fcn->type != R_ANAL_FCN_TYPE_FCN || fcn->diff->type != R_ANAL_DIFF_TYPE_NULL)
|
||||
if ((fcn->type != R_ANAL_FCN_TYPE_FCN && fcn->type != R_ANAL_FCN_TYPE_SYM) ||
|
||||
fcn->diff->type != R_ANAL_DIFF_TYPE_NULL)
|
||||
continue;
|
||||
ot = 0;
|
||||
mfcn = mfcn2 = NULL;
|
||||
|
@ -159,8 +160,8 @@ static void gdiff_diff_fcn(RList *fcns, RList *fcns2) {
|
|||
maxsize = fcn2->size;
|
||||
minsize = fcn->size;
|
||||
}
|
||||
if (fcn2->type != R_ANAL_FCN_TYPE_FCN || fcn2->diff->type != R_ANAL_DIFF_TYPE_NULL ||
|
||||
(maxsize * THRESHOLDFCN > minsize))
|
||||
if ((fcn2->type != R_ANAL_FCN_TYPE_FCN && fcn2->type != R_ANAL_FCN_TYPE_SYM) ||
|
||||
fcn2->diff->type != R_ANAL_DIFF_TYPE_NULL || (maxsize * THRESHOLDFCN > minsize))
|
||||
continue;
|
||||
r_diff_buffers_distance (NULL, fcn->fingerprint, fcn->size,
|
||||
fcn2->fingerprint, fcn2->size, NULL, &t);
|
||||
|
|
|
@ -288,9 +288,7 @@ enum {
|
|||
R_ANAL_REF_TYPE_NULL = 0,
|
||||
R_ANAL_REF_TYPE_CODE = 'c', // code ref
|
||||
R_ANAL_REF_TYPE_CALL = 'C', // code ref (call)
|
||||
R_ANAL_REF_TYPE_DATA = 'd', // mem ref
|
||||
R_ANAL_REF_TYPE_SYM = 's', // sym
|
||||
R_ANAL_REF_TYPE_IMP = 'i' // imp
|
||||
R_ANAL_REF_TYPE_DATA = 'd' // mem ref
|
||||
} RAnalRefType;
|
||||
|
||||
typedef struct r_anal_ref_t {
|
||||
|
|
Loading…
Reference in New Issue