Fix missing arm reference regression in aaaa ##analysis

This commit is contained in:
pancake 2024-07-05 12:17:23 +02:00 committed by GitHub
parent 8e37c73859
commit 2c3f0cb757
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 30 additions and 15 deletions

View File

@ -3441,7 +3441,8 @@ R_API int r_core_config_init(RCore *core) {
SETCB ("anal.limits", "false", (RConfigCallback)&cb_anal_limits, "restrict analysis to address range [anal.from:anal.to]");
SETCB ("anal.noret.refs", "false", (RConfigCallback)&cb_anal_noret_refs, "recursive no return checks (EXPERIMENTAL)");
SETCB ("anal.slow", "true", (RConfigCallback)&cb_anal_slow, "uses emulation and deeper analysis for better results");
SETPREF ("anal.emu", "false", "run aaef after analysis (EXPERIMENTAL)");
SETPREF ("anal.emu", "true", "run aaef after analysis");
SETPREF ("anal.emumem", "false", "run aaef with memory cache enabled after analysis (EXPERIMENTAL)");
SETCB ("anal.noret", "true", (RConfigCallback)&cb_anal_noret, "propagate noreturn attributes (EXPERIMENTAL)");
SETCB ("anal.limits", "false", (RConfigCallback)&cb_anal_limits, "restrict analysis to address range [anal.from:anal.to]");
SETICB ("anal.from", -1, (RConfigCallback)&cb_anal_from, "lower limit on the address range for analysis");

View File

@ -13844,8 +13844,14 @@ static int cmd_anal_all(RCore *core, const char *input) {
}
r_core_task_yield (&core->tasks);
}
const bool run_aaef = r_config_get_b (core->config, "anal.emu");
/// if (!r_str_startswith (asm_arch, "x86") && !r_str_startswith (asm_arch, "hex")) {
bool run_aaef = r_config_get_b (core->config, "anal.emu");
if (r_str_startswith (asm_arch, "x86") || r_str_startswith (asm_arch, "hex")) {
// hackaround
run_aaef = false;
}
if (r_arch_info (core->anal->arch, R_ARCH_INFO_ISVM) == R_ARCH_INFO_ISVM) {
run_aaef = false;
}
if (run_aaef) { // emulate all functions
// if (!r_str_startswith (asm_arch, "hex")) maybe?
// XXX moving this oustide the x86 guard breaks some tests, missing types
@ -13853,16 +13859,21 @@ static int cmd_anal_all(RCore *core, const char *input) {
logline (core, 70, "Skipping function emulation in debugger mode (aaef)");
// nothing to do
} else {
bool use_pcache = true; // false;
const bool io_cache = r_config_get_b (core->config, "io.pcache");
if (use_pcache) {
r_config_set_b (core->config, "io.pcache", true);
}
logline (core, 70, "Emulate functions to find computed references (aaef)");
r_core_cmd_call (core, "aaef");
r_core_task_yield (&core->tasks);
if (use_pcache) {
r_config_set_b (core->config, "io.pcache", io_cache);
if (r_config_get_b (core->config, "anal.emumem")) {
bool use_pcache = run_aaef; // true; // false;
const bool io_cache = r_config_get_b (core->config, "io.pcache");
if (use_pcache) {
r_config_set_b (core->config, "io.pcache", true);
}
logline (core, 70, "Emulate functions to find computed references (aaef)");
r_core_cmd_call (core, "aaef");
r_core_task_yield (&core->tasks);
if (use_pcache) {
r_config_set_b (core->config, "io.pcache", io_cache);
}
} else {
logline (core, 70, "Emulate functions to find computed references (aaef)");
r_core_cmd_call (core, "aaef");
}
}
}

View File

@ -40,10 +40,8 @@ EXPECT=<<EOF
EOF
RUN
# we shouldnt be using anal.emu=true to find this xref
NAME=aaa missing stref
FILE=bins/elf/libtoolocore.so
ARGS=-e anal.emu=true
CMDS=<<EOF
aaa
s 0x00001373

View File

@ -94,6 +94,11 @@ EXPECT=<<EOF
"origin": "logline",
"message": "Finding xrefs in noncode sections (e anal.in=io.maps.x; aav)"
},
{
"type": "WARN",
"origin": "logline",
"message": "Emulate functions to find computed references (aaef)"
},
{
"type": "WARN",
"origin": "logline",