mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-25 23:34:57 +00:00
Fix #4393
This commit is contained in:
parent
9c998618aa
commit
2c70142294
@ -222,6 +222,19 @@ R_API ut64 r_core_anal_address (RCore *core, ut64 addr) {
|
||||
return types;
|
||||
}
|
||||
|
||||
/*this only autoname those function that start with fcn.* or sym.func.* */
|
||||
R_API void r_core_anal_autoname_all_fcns(RCore *core) {
|
||||
RListIter *it;
|
||||
RAnalFunction *fcn;
|
||||
r_list_foreach (core->anal->fcns, it, fcn) {
|
||||
char *name = r_core_anal_fcn_autoname (core, fcn->addr, 0);
|
||||
if (name && (!strncmp (fcn->name, "fcn.", 4) || !strncmp (fcn->name, "sym.func.", 9))) {
|
||||
r_flag_rename (core->flags, r_flag_get (core->flags, fcn->name), name);
|
||||
free (fcn->name);
|
||||
fcn->name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* suggest a name for the function at the address 'addr'.
|
||||
* If dump is true, every strings associated with the function is printed */
|
||||
R_API char *r_core_anal_fcn_autoname(RCore *core, ut64 addr, int dump) {
|
||||
@ -236,8 +249,7 @@ R_API char *r_core_anal_fcn_autoname(RCore *core, ut64 addr, int dump) {
|
||||
RFlagItem *f = r_flag_get_i (core->flags, ref->addr);
|
||||
if (f) {
|
||||
if (dump) {
|
||||
r_cons_printf ("0x%08"PFMT64x" 0x%08"PFMT64x" %s\n",
|
||||
ref->at, ref->addr, f->name);
|
||||
r_cons_printf ("0x%08"PFMT64x" 0x%08"PFMT64x" %s\n", ref->at, ref->addr, f->name);
|
||||
}
|
||||
if (strstr (f->name, "isatty"))
|
||||
use_isatty = 1;
|
||||
@ -264,8 +276,7 @@ R_API char *r_core_anal_fcn_autoname(RCore *core, ut64 addr, int dump) {
|
||||
return strdup ("parse_args"); // main?
|
||||
}
|
||||
if (use_isatty) {
|
||||
char *ret = r_str_newf ("sub.setup_tty_%s_%x",
|
||||
do_call, addr & 0xfff);
|
||||
char *ret = r_str_newf ("sub.setup_tty_%s_%x", do_call, addr & 0xfff);
|
||||
free (do_call);
|
||||
return ret;
|
||||
}
|
||||
|
@ -891,8 +891,7 @@ static int cmd_anal_fcn(RCore *core, const char *input) {
|
||||
{
|
||||
char *name = r_core_anal_fcn_autoname (core, core->offset, 0);
|
||||
if (name) {
|
||||
r_cons_printf ("afn %s 0x%08" PFMT64x "\n",
|
||||
name, core->offset);
|
||||
r_cons_printf ("afn %s 0x%08" PFMT64x "\n", name, core->offset);
|
||||
free (name);
|
||||
}
|
||||
}
|
||||
@ -3627,7 +3626,7 @@ static int cmd_anal_all(RCore *core, const char *input) {
|
||||
"aac", " [len]", "analyze function calls (af @@ `pi len~call[1]`)",
|
||||
"aae", " [len]", "analyze references with ESIL",
|
||||
"aar", " [len]", "analyze len bytes of instructions for references",
|
||||
"aan", "", "afna @@ fcn*",
|
||||
"aan", "", "autoname functions that either start with fcn.* or sym.func.*",
|
||||
"aas", " [len]", "analyze symbols (af @@= `isq~[0]`)",
|
||||
"aat", " [len]", "analyze all consecutive functions in section",
|
||||
"aap", "", "find and analyze function preludes",
|
||||
@ -3645,7 +3644,7 @@ static int cmd_anal_all(RCore *core, const char *input) {
|
||||
r_core_cmd0 (core, "af @@= `isq~[0]`");
|
||||
r_core_cmd0 (core, "af @ entry0");
|
||||
break;
|
||||
case 'n': r_core_cmd0 (core, ".afna @@ fcn.*"); break;
|
||||
case 'n': r_core_anal_autoname_all_fcns (core); break; //aan
|
||||
case 'p': // "aap"
|
||||
if (*input == '?') {
|
||||
// TODO: accept parameters for ranges
|
||||
@ -3697,11 +3696,9 @@ static int cmd_anal_all(RCore *core, const char *input) {
|
||||
eprintf ("[*] Use -AA or aaaa to perform additional experimental analysis.\n");
|
||||
}
|
||||
r_config_set_i (core->config, "anal.calls", c);
|
||||
if (r_config_get_i (core->config, "anal.autoname")) {
|
||||
rowlog (core, "Construct a function name for all fcn.* (.afna @@ fcn.*)");
|
||||
r_core_cmd0 (core, ".afna @@ fcn.*");
|
||||
rowlog_done (core);
|
||||
}
|
||||
rowlog (core, "Constructing a function name for fcn.* and sym.func.* functions");
|
||||
r_core_anal_autoname_all_fcns (core);
|
||||
rowlog_done (core);
|
||||
if (core->cons->breaked)
|
||||
goto jacuzzi;
|
||||
r_core_cmd0 (core, "s-");
|
||||
|
@ -341,6 +341,7 @@ R_API ut64 r_core_anal_get_bbaddr(RCore *core, ut64 addr);
|
||||
R_API int r_core_anal_bb_seek(RCore *core, ut64 addr);
|
||||
R_API int r_core_anal_fcn(RCore *core, ut64 at, ut64 from, int reftype, int depth);
|
||||
R_API char *r_core_anal_fcn_autoname(RCore *core, ut64 addr, int dump);
|
||||
R_API void r_core_anal_autoname_all_fcns(RCore *core);
|
||||
R_API int r_core_anal_fcn_list(RCore *core, const char *input, int rad);
|
||||
R_API int r_core_anal_fcn_list_size(RCore *core);
|
||||
R_API void r_core_anal_fcn_labels(RCore *core, RAnalFunction *fcn, int rad);
|
||||
|
Loading…
x
Reference in New Issue
Block a user