Make type matching independent of bb list order ##anal

This commit is contained in:
Florian Märkl 2020-01-15 10:27:20 +01:00 committed by radare
parent 50040f8810
commit a68ff59a32
3 changed files with 12 additions and 0 deletions

View File

@ -453,6 +453,11 @@ static void type_match(RCore *core, ut64 addr, char *fcn_name, ut64 baddr, const
r_cons_break_pop ();
}
static int bb_cmpaddr(const void *_a, const void *_b) {
const RAnalBlock *a = _a, *b = _b;
return a->addr > b->addr ? 1 : (a->addr < b->addr ? -1 : 0);
}
R_API void r_core_anal_type_match(RCore *core, RAnalFunction *fcn) {
RAnalBlock *bb;
RListIter *it;
@ -503,6 +508,7 @@ R_API void r_core_anal_type_match(RCore *core, RAnalFunction *fcn) {
return;
}
r_cons_break_push (NULL, NULL);
r_list_sort (fcn->bbs, bb_cmpaddr); // TODO: The algorithm can be more accurate if blocks are followed by their jmp/fail, not just by address
r_list_foreach (fcn->bbs, it, bb) {
ut64 addr = bb->addr;
int i = 0;

View File

@ -80,6 +80,11 @@ R_API void r_load_panels_layout(RCore *core, const char *_name);
static int r_core_cmd_subst_i(RCore *core, char *cmd, char* colon, bool *tmpseek);
static int bb_cmpaddr(const void *_a, const void *_b) {
const RAnalBlock *a = _a, *b = _b;
return a->addr > b->addr ? 1 : (a->addr < b->addr ? -1 : 0);
}
static void cmd_debug_reg(RCore *core, const char *str);
#include "cmd_quit.c"
#include "cmd_hash.c"

View File

@ -879,6 +879,7 @@ R_API void r_core_link_stroff(RCore *core, RAnalFunction *fcn) {
r_config_set_i (core->config, "dbg.follow", 0);
ut64 oldoff = core->offset;
r_cons_break_push (NULL, NULL);
r_list_sort (fcn->bbs, bb_cmpaddr); // TODO: The algorithm can be more accurate if blocks are followed by their jmp/fail, not just by address
r_list_foreach (fcn->bbs, it, bb) {
ut64 at = bb->addr;
ut64 to = bb->addr + bb->size;