Add anal.gpfixed instead of anal.gp2 and use in aae

This commit is contained in:
Florian Märkl 2019-06-19 20:27:53 +02:00 committed by radare
parent 5bf329eb78
commit 06ef4cc92b
3 changed files with 13 additions and 3 deletions

View File

@ -4505,6 +4505,7 @@ static inline bool canal_isThumb(RCore *core) {
R_API void r_core_anal_esil(RCore *core, const char *str, const char *target) {
bool cfg_anal_strings = r_config_get_i (core->config, "anal.strings");
bool emu_lazy = r_config_get_i (core->config, "emu.lazy");
bool gp_fixed = r_config_get_i (core->config, "anal.gpfixed");
RAnalEsil *ESIL = core->anal->esil;
ut64 refptr = 0LL;
const char *pcname;
@ -4605,6 +4606,12 @@ R_API void r_core_anal_esil(RCore *core, const char *str, const char *target) {
}
}
ut64 gp = r_config_get_i (core->config, "anal.gp");
const char *gp_reg = NULL;
if (!strcmp (core->anal->cur->arch, "mips")) {
gp_reg = "gp";
}
int opalign = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_ALIGN);
const char *sn = r_reg_get_name (core->anal->reg, R_REG_NAME_SN);
if (!sn) {
@ -4696,6 +4703,9 @@ R_API void r_core_anal_esil(RCore *core, const char *str, const char *target) {
}
r_anal_esil_set_pc (ESIL, cur);
r_reg_setv (core->anal->reg, pcname, cur + op.size);
if (gp_fixed && gp_reg) {
r_reg_setv (core->anal->reg, gp_reg, gp);
}
(void)r_anal_esil_parse (ESIL, esilstr);
// looks like ^C is handled by esil_parse !!!!
//r_anal_esil_dumpstack (ESIL);

View File

@ -2750,7 +2750,7 @@ R_API int r_core_config_init(RCore *core) {
SETPREF ("anal.a2f", "false", "Use the new WIP analysis algorithm (core/p/a2f), anal.depth ignored atm");
SETCB ("anal.roregs", "gp,zero", (RConfigCallback)&cb_anal_roregs, "Comma separated list of register names to be readonly");
SETICB ("anal.gp", 0, (RConfigCallback)&cb_anal_gp, "Set the value of the GP register (MIPS)");
SETI ("anal.gp2", 0, "Set anal.gp before emulating each instruction (workaround)");
SETPREF ("anal.gpfixed", "true", "Set gp register to anal.gp before emulating each instruction in aae");
SETCB ("anal.limits", "false", (RConfigCallback)&cb_anal_limits, "Restrict analysis to address range [anal.from:anal.to]");
SETCB ("anal.rnr", "false", (RConfigCallback)&cb_anal_rnr, "Recursive no return checks (EXPERIMENTAL)");
SETCB ("anal.limits", "false", (RConfigCallback)&cb_anal_limits, "Restrict analysis to address range [anal.from:anal.to]");

View File

@ -4351,8 +4351,8 @@ static void mipsTweak(RDisasmState *ds) {
RCore *core = ds->core;
//const char *asm_arch = r_config_get (core->config, "asm.arch");
//if (asm_arch && *asm_arch && strstr (asm_arch, "mips")) {
ut64 gp = r_config_get_i (core->config, "anal.gp2");
if (gp && gp !=UT64_MAX) {
if (r_config_get_i (core->config, "anal.gpfixed")) {
ut64 gp = r_config_get_i (core->config, "anal.gp");
r_reg_setv (core->anal->reg, "gp", gp);
}
//}