From b61a3772b21541403d5c6c9de3af24c05a0c4937 Mon Sep 17 00:00:00 2001 From: Andrew McDonnell Date: Mon, 16 Jun 2014 19:58:07 +0930 Subject: [PATCH] Workaround to ensure mips / branch delayed code properly accounts function size. --- libr/anal/fcn.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libr/anal/fcn.c b/libr/anal/fcn.c index 20b11379e5..74277e2033 100644 --- a/libr/anal/fcn.c +++ b/libr/anal/fcn.c @@ -380,8 +380,17 @@ static int fcn_recurse(RAnal *anal, RAnalFunction *fcn, ut64 addr, ut8 *buf, ut6 anal->iob.read_at (anal->iob.io, op.fail, bbuf, sizeof (bbuf)); FITFCNSZ(); - // TODO: Discuss this 'return' statement, is this only necessary for mips? - return fcn_recurse (anal, fcn, op.fail, bbuf, sizeof (bbuf), depth-1); + // TODO: Discuss bypassing this 'return' statement, + // is this only necessary for branch delayed instructions? + ret = fcn_recurse (anal, fcn, op.fail, bbuf, sizeof (bbuf), depth-1); + if (!op.delay) { + // this will be all x86, arm (at least) + // without which the analysis is really slow, + // presumably because each opcode would get revisited + // (and already covered by a bb) many times + return ret; + } + // For some reason, branch delayed code (MIPS) needs to continue #if 0 // do not add xrefs for cjmps? r_anal_op_fini (&op);