mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-24 22:00:18 +00:00
Fix noreturn issue introduced with the flag_get_at aproximation
This commit is contained in:
parent
d505ecfacf
commit
72e874c2ac
@ -465,7 +465,7 @@ R_API bool r_anal_noreturn_add(RAnal *anal, const char *name, ut64 addr) {
|
||||
tmp_name = name;
|
||||
} else {
|
||||
RAnalFunction *fcn = r_anal_get_fcn_in (anal, addr, -1);
|
||||
RFlagItem *fi = anal->flb.get_at (anal->flb.f, addr);
|
||||
RFlagItem *fi = anal->flb.get_at (anal->flb.f, addr, false);
|
||||
if (!fcn && !fi) {
|
||||
eprintf ("Cant find Function at given address\n");
|
||||
return false;
|
||||
@ -559,10 +559,10 @@ R_API bool r_anal_noreturn_at(RAnal *anal, ut64 addr) {
|
||||
int ofs = anal->flb.f->space_idx;
|
||||
anal->flb.set_fs (anal->flb.f, "imports");
|
||||
anal->flb.f->space_strict = true;
|
||||
RFlagItem *fi = anal->flb.get_at (anal->flb.f, addr);
|
||||
RFlagItem *fi = anal->flb.get_at (anal->flb.f, addr, false);
|
||||
if (!fi) {
|
||||
anal->flb.set_fs (anal->flb.f, "symbols");
|
||||
fi = anal->flb.get_at (anal->flb.f, addr);
|
||||
fi = anal->flb.get_at (anal->flb.f, addr, false);
|
||||
}
|
||||
anal->flb.f->space_idx = ofs;
|
||||
anal->flb.f->space_strict = oss;
|
||||
|
@ -716,7 +716,7 @@ repeat:
|
||||
if (!strcmp (anal->cur->arch, "mips")) {
|
||||
//Looks like this flags check is useful only for mips
|
||||
// do not skip nops if there's a flag at starting address
|
||||
RFlagItem *fi = anal->flb.get_at (anal->flb.f, addr);
|
||||
RFlagItem *fi = anal->flb.get_at (anal->flb.f, addr, false);
|
||||
if (!fi || strncmp (fi->name, "sym.", 4)) {
|
||||
if ((addr + delay.un_idx - oplen) == fcn->addr) {
|
||||
fcn->addr += oplen;
|
||||
@ -746,7 +746,12 @@ repeat:
|
||||
if (anal->opt.jmpref) {
|
||||
(void) r_anal_fcn_xref_add (anal, fcn, op.addr, op.jump, R_ANAL_REF_TYPE_CODE);
|
||||
}
|
||||
if (r_anal_noreturn_at (anal, op.jump) || (op.jump < fcn->addr && !anal->opt.jmpabove)) {
|
||||
if (!anal->opt.jmpabove && (op.jump < fcn->addr)) {
|
||||
FITFCNSZ ();
|
||||
r_anal_op_fini (&op);
|
||||
return R_ANAL_RET_END;
|
||||
}
|
||||
if (r_anal_noreturn_at (anal, op.jump)) {
|
||||
FITFCNSZ ();
|
||||
r_anal_op_fini (&op);
|
||||
return R_ANAL_RET_END;
|
||||
@ -779,6 +784,7 @@ repeat:
|
||||
bb->fail = UT64_MAX;
|
||||
}
|
||||
recurseAt (op.jump);
|
||||
FITFCNSZ();
|
||||
gotoBeachRet ();
|
||||
#endif
|
||||
} else {
|
||||
|
@ -466,7 +466,7 @@ static int core_anal_fcn(RCore *core, ut64 at, ut64 from, int reftype, int depth
|
||||
}
|
||||
fcn->addr = at;
|
||||
r_anal_fcn_set_size (fcn, 0);
|
||||
RFlagItem *fi = r_flag_get_at (core->flags, at);
|
||||
RFlagItem *fi = r_flag_get_at (core->flags, at, false);
|
||||
if (fi && fi->name && strncmp (fi->name, "sect", 4)) {
|
||||
fcn->name = strdup (fi->name);
|
||||
} else {
|
||||
|
@ -2113,7 +2113,7 @@ static void r_core_cmd_bp(RCore *core, const char *input) {
|
||||
list = r_debug_frames (core->dbg, addr);
|
||||
r_list_foreach (list, iter, frame) {
|
||||
char flagdesc[1024], flagdesc2[1024], pcstr[32], spstr[32];
|
||||
RFlagItem *f = r_flag_get_at (core->flags, frame->addr);
|
||||
RFlagItem *f = r_flag_get_at (core->flags, frame->addr, true);
|
||||
|
||||
flagdesc[0] = flagdesc2[0] = 0;
|
||||
|
||||
@ -2135,9 +2135,9 @@ static void r_core_cmd_bp(RCore *core, const char *input) {
|
||||
"%s", f->name);
|
||||
}
|
||||
}
|
||||
f = r_flag_get_at (core->flags, frame->addr);
|
||||
f = r_flag_get_at (core->flags, frame->addr, true);
|
||||
if (f && !strchr (f->name, '.')) {
|
||||
f = r_flag_get_at (core->flags, frame->addr-1);
|
||||
f = r_flag_get_at (core->flags, frame->addr - 1, true);
|
||||
}
|
||||
if (f) {
|
||||
if (f->offset != addr) {
|
||||
@ -2447,7 +2447,7 @@ static void trace_traverse_pre (RTreeNode *n, RTreeVisitor *vis) {
|
||||
r_cons_printf (" ");
|
||||
}
|
||||
if (_core) {
|
||||
RFlagItem *f = r_flag_get_at (_core->flags, tn->addr);
|
||||
RFlagItem *f = r_flag_get_at (_core->flags, tn->addr, true);
|
||||
if (f) {
|
||||
name = f->name;
|
||||
}
|
||||
|
@ -678,11 +678,11 @@ eprintf ("WTF 'f .xxx' adds a variable to the function? ?!!?(%s)\n");
|
||||
addr = core->offset;
|
||||
break;
|
||||
default:
|
||||
addr = r_num_math (core->num, input+2);
|
||||
addr = r_num_math (core->num, input + 2);
|
||||
break;
|
||||
}
|
||||
core->flags->space_strict = true;
|
||||
f = r_flag_get_at (core->flags, addr);
|
||||
f = r_flag_get_at (core->flags, addr, true);
|
||||
core->flags->space_strict = false;
|
||||
if (f) {
|
||||
if (f->offset != addr) {
|
||||
|
@ -327,11 +327,13 @@ static int cmd_info(void *data, const char *input) {
|
||||
case 's':
|
||||
if (input[1] == '.') {
|
||||
ut64 addr = core->offset + (core->print->cur_enabled? core->print->cur: 0);
|
||||
RFlagItem *f = r_flag_get_at (core->flags, addr);
|
||||
RFlagItem *f = r_flag_get_at (core->flags, addr, false);
|
||||
if (f) {
|
||||
if (f->offset == addr || !f->offset)
|
||||
if (f->offset == addr || !f->offset) {
|
||||
r_cons_printf ("%s", f->name);
|
||||
else r_cons_printf ("%s+%d", f->name, (int)(addr-f->offset));
|
||||
} else {
|
||||
r_cons_printf ("%s+%d", f->name, (int)(addr-f->offset));
|
||||
}
|
||||
}
|
||||
input++;
|
||||
break;
|
||||
|
@ -3743,7 +3743,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
} else {
|
||||
a = b = "";
|
||||
}
|
||||
f = r_flag_get_at (core->flags, v);
|
||||
f = r_flag_get_at (core->flags, v, true);
|
||||
fn = NULL;
|
||||
if (f) {
|
||||
st64 delta = (v - f->offset);
|
||||
@ -3837,7 +3837,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
} else {
|
||||
a = b = "";
|
||||
}
|
||||
f = r_flag_get_at (core->flags, v);
|
||||
f = r_flag_get_at (core->flags, v, true);
|
||||
fn = NULL;
|
||||
if (f) {
|
||||
st64 delta = (v - f->offset);
|
||||
@ -3880,7 +3880,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
} else {
|
||||
a = b = "";
|
||||
}
|
||||
f = r_flag_get_at (core->flags, v);
|
||||
f = r_flag_get_at (core->flags, v, true);
|
||||
fn = NULL;
|
||||
if (f) {
|
||||
st64 delta = (v - f->offset);
|
||||
|
@ -1649,7 +1649,7 @@ R_API void r_core_prompt_loop(RCore *r) {
|
||||
|
||||
static int prompt_flag (RCore *r, char *s, size_t maxlen) {
|
||||
const char DOTS[] = "...";
|
||||
const RFlagItem *f = r_flag_get_at (r->flags, r->offset);
|
||||
const RFlagItem *f = r_flag_get_at (r->flags, r->offset, false);
|
||||
if (!f) return false;
|
||||
|
||||
if (f->offset < r->offset) {
|
||||
|
@ -788,7 +788,7 @@ static void ds_show_refs(RDisasmState *ds) {
|
||||
r_list_foreach (list, iter, ref) {
|
||||
cmt = r_meta_get_string (ds->core->anal, R_META_TYPE_COMMENT, ref->addr);
|
||||
flagi = r_flag_get_i (ds->core->flags, ref->addr);
|
||||
flagat = r_flag_get_at (ds->core->flags, ref->addr);
|
||||
flagat = r_flag_get_at (ds->core->flags, ref->addr, false);
|
||||
ds_align_comment (ds);
|
||||
if (ds->show_color) {
|
||||
r_cons_strcat (ds->color_comment);
|
||||
@ -1621,7 +1621,7 @@ static void ds_print_lines_left(RDisasmState *ds) {
|
||||
sfi.name = ds->fcn->name;
|
||||
ds->lastflag = &sfi;
|
||||
} else {
|
||||
RFlagItem *fi = r_flag_get_at (core->flags, ds->at);
|
||||
RFlagItem *fi = r_flag_get_at (core->flags, ds->at, false);
|
||||
if (fi) { // && (!ds->lastflag || fi->offset != ds->at)) {
|
||||
sfi.offset = fi->offset;
|
||||
sfi.name = fi->name;
|
||||
@ -2392,7 +2392,7 @@ static void ds_print_cc_update(RDisasmState *ds) {
|
||||
tmp[0] = 0;
|
||||
r_anal_cc_update (core->anal, &cc, &ds->analop);
|
||||
if (ccstr) {
|
||||
RFlagItem *flag = r_flag_get_at (core->flags, cc.jump);
|
||||
RFlagItem *flag = r_flag_get_at (core->flags, cc.jump, false);
|
||||
if (flag && ccstr) {
|
||||
int delta = 0;
|
||||
if (f) { delta = cc.jump-flag->offset; }
|
||||
|
@ -285,7 +285,7 @@ static int analyzeFunction(RCore *core, ut64 addr) {
|
||||
sdb_num_set (db, "size", getFunctionSize (db), 0);
|
||||
|
||||
// receiving a possible flag to label the new function
|
||||
fi = r_flag_get_at (core->flags, addr);
|
||||
fi = r_flag_get_at (core->flags, addr, false);
|
||||
if (fi && fi->name && strncmp (fi->name, "sect", 4)) {
|
||||
function_label = strdup (fi->name);
|
||||
} else {
|
||||
|
@ -813,7 +813,7 @@ R_API int r_core_visual_xrefs_X (RCore *core) {
|
||||
r_cons_clear00 ();
|
||||
} else {
|
||||
r_list_foreach (fun->refs, iter, refi) {
|
||||
RFlagItem *f = r_flag_get_at (core->flags, refi->addr);
|
||||
RFlagItem *f = r_flag_get_at (core->flags, refi->addr, false);
|
||||
if (f) {
|
||||
eprintf ("%s\n", f->name);
|
||||
}
|
||||
@ -2188,15 +2188,15 @@ R_API void r_core_visual_title (RCore *core, int color) {
|
||||
core->flags->space_strict = true;
|
||||
core->anal->flb.set_fs (core->flags, "symbols");
|
||||
if (core->flags->space_idx != -1) {
|
||||
f = core->anal->flb.get_at (core->flags, addr);
|
||||
f = core->anal->flb.get_at (core->flags, addr, false);
|
||||
}
|
||||
core->flags->space_strict = oss;
|
||||
core->flags->space_idx = osi;
|
||||
if (!f) {
|
||||
f = r_flag_get_at (core->flags, addr);
|
||||
f = r_flag_get_at (core->flags, addr, false);
|
||||
}
|
||||
#else
|
||||
RFlagItem *f = r_flag_get_at (core->flags, addr);
|
||||
RFlagItem *f = r_flag_get_at (core->flags, addr, false);
|
||||
#endif
|
||||
if (f) {
|
||||
if (f->offset == addr || !f->offset)
|
||||
|
@ -350,7 +350,7 @@ R_API RFlagItem *r_flag_get_i2(RFlag *f, ut64 off) {
|
||||
|
||||
/* returns the last flag item defined before or at the given offset.
|
||||
* NULL is returned if such a item is not found. */
|
||||
R_API RFlagItem *r_flag_get_at(RFlag *f, ut64 off) {
|
||||
R_API RFlagItem *r_flag_get_at(RFlag *f, ut64 off, bool closest) {
|
||||
RFlagItem *item, *nice = NULL;
|
||||
RListIter *iter;
|
||||
|
||||
@ -361,7 +361,7 @@ R_API RFlagItem *r_flag_get_at(RFlag *f, ut64 off) {
|
||||
if (item->offset == off) {
|
||||
return evalFlag (f, item);
|
||||
}
|
||||
if (off > item->offset) {
|
||||
if (closest && off > item->offset) {
|
||||
if (!nice || nice->offset < item->offset) {
|
||||
nice = item;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ typedef struct r_flag_t {
|
||||
|
||||
typedef bool (*RFlagExistAt)(RFlag *f, const char *flag_prefix, ut16 fp_size, ut64 off);
|
||||
typedef RFlagItem* (*RFlagGet)(RFlag *f, const char *name);
|
||||
typedef RFlagItem* (*RFlagGetAt)(RFlag *f, ut64 addr);
|
||||
typedef RFlagItem* (*RFlagGetAt)(RFlag *f, ut64 addr, bool closest);
|
||||
typedef RFlagItem* (*RFlagSet)(RFlag *f, const char *name, ut64 addr, ut32 size);
|
||||
typedef int (*RFlagSetSpace)(RFlag *f, const char *name);
|
||||
|
||||
@ -91,7 +91,7 @@ R_API bool r_flag_exist_at(RFlag *f, const char *flag_prefix, ut16 fp_size, ut64
|
||||
R_API RFlagItem *r_flag_get(RFlag *f, const char *name);
|
||||
R_API RFlagItem *r_flag_get_i(RFlag *f, ut64 off);
|
||||
R_API RFlagItem *r_flag_get_i2(RFlag *f, ut64 off);
|
||||
R_API RFlagItem *r_flag_get_at(RFlag *f, ut64 off);
|
||||
R_API RFlagItem *r_flag_get_at(RFlag *f, ut64 off, bool closest);
|
||||
R_API const RList* /*<RFlagItem*>*/ r_flag_get_list(RFlag *f, ut64 off);
|
||||
R_API char *r_flag_get_liststr(RFlag *f, ut64 off);
|
||||
R_API int r_flag_unset(RFlag *f, RFlagItem *item);
|
||||
|
Loading…
Reference in New Issue
Block a user