Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Feb 14, 2023
1 parent 6ce133c commit b732629
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
24 changes: 24 additions & 0 deletions libr/anal/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,29 @@ R_API void r_anal_block_unref(RAnalBlock *bb) {
}
}

#if 1
R_API void r_anal_block_successor_addrs_foreach(RAnalBlock *block, RAnalAddrCb cb, void *user) {
#define CB_ADDR(addr) do { \
if (addr == UT64_MAX) { \
break; \
} \
if (!cb (addr, user)) { \
return; \
} \
} while (0);

CB_ADDR (block->jump);
CB_ADDR (block->fail);
if (block->switch_op && block->switch_op->cases) {
RListIter *iter;
RAnalCaseOp *caseop;
r_list_foreach (block->switch_op->cases, iter, caseop) {
CB_ADDR (caseop->jump);
}
}
#undef CB_ADDR
}
#else
R_API void r_anal_block_successor_addrs_foreach(RAnalBlock *block, RAnalAddrCb cb, void *user) {
cb (block->jump, user);
cb (block->fail, user);
Expand All @@ -437,6 +460,7 @@ R_API void r_anal_block_successor_addrs_foreach(RAnalBlock *block, RAnalAddrCb c
}
}
}
#endif

typedef struct r_anal_block_recurse_context_t {
RAnal *anal;
Expand Down
4 changes: 2 additions & 2 deletions libr/anal/fcn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ static int fcn_recurse(RAnal *anal, RAnalFunction *fcn, ut64 addr, ut64 len, int
bb->cond->type = op->cond;
}
#if 1
if (op->ptr != UT64_MAX) {
if (anal->opt.jmptbl) {
ut64 table_size, default_case;
table_size = anal->cmpval + 1;
default_case = op->fail; // is this really default case?
Expand Down Expand Up @@ -1518,7 +1518,7 @@ static int fcn_recurse(RAnal *anal, RAnalFunction *fcn, ut64 addr, ut64 len, int
if (bb && bb->size == 0) {
r_anal_function_remove_block (fcn, bb);
}
r_anal_block_update_hash (bb);
// r_anal_block_update_hash (bb); // XXX
r_anal_block_unref (bb);
free (movbasereg);
return ret;
Expand Down

0 comments on commit b732629

Please sign in to comment.