diff --git a/libr/anal/anal.c b/libr/anal/anal.c index 90c08a3ad8..9c7e624c38 100644 --- a/libr/anal/anal.c +++ b/libr/anal/anal.c @@ -50,6 +50,7 @@ R_API RAnal *r_anal_new() { RAnalPlugin *static_plugin; RAnal *anal = R_NEW0 (RAnal); if (!anal) return NULL; + anal->nopskip = R_TRUE; // skip nops in code analysis anal->decode = R_TRUE; // slow slow if not used anal->sdb = sdb_new (NULL, NULL, 0); anal->sdb_fcns = sdb_ns (anal->sdb, "fcns", 1); diff --git a/libr/anal/fcn.c b/libr/anal/fcn.c index 04cbd56f5c..b1c894a255 100644 --- a/libr/anal/fcn.c +++ b/libr/anal/fcn.c @@ -333,15 +333,15 @@ repeat: } switch (op.type) { case R_ANAL_OP_TYPE_NOP: -#if 0 -// XXX: skipping spaces at the beginign breaks the analysis! this feature must be fixed before re-enable - if ((addr + undelayed_idx-oplen) == fcn->addr) { - fcn->addr = bb->addr = addr + undelayed_idx; -// idx = undelayed_idx; - goto repeat; - // continue; + if (anal->nopskip) { + if ((addr + undelayed_idx-oplen) == fcn->addr) { + //fcn->addr = bb->addr = addr + undelayed_idx; + fcn->addr += oplen; + idx = undelayed_idx; + goto repeat; + continue; + } } -#endif break; case R_ANAL_OP_TYPE_JMP: if (!r_anal_fcn_xref_add (anal, fcn, op.addr, op.jump, diff --git a/libr/anal/p/anal_gb.c b/libr/anal/p/anal_gb.c index 8e632e9e6c..4915d0ef7e 100644 --- a/libr/anal/p/anal_gb.c +++ b/libr/anal/p/anal_gb.c @@ -640,7 +640,7 @@ static int gb_custom_daa (RAnalEsil *esil) } else { if (C || (a > 0x99)) { a = (a + 0x60) & 0xff; - r_reg_setv (esil->anal, "C", 1); + r_reg_setv (esil->anal->reg, "C", 1); } if (H || ((a & 0x0f) > 0x09)) a += 0x06;; diff --git a/libr/anal/p/anal_mips_gnu.c b/libr/anal/p/anal_mips_gnu.c index bb7184702f..001c536e38 100644 --- a/libr/anal/p/anal_mips_gnu.c +++ b/libr/anal/p/anal_mips_gnu.c @@ -425,7 +425,9 @@ static int mips_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b_in, int len /* Set the profile register */ static int mips_set_reg_profile(RAnal* anal){ - const char *p = "=pc pc\n" + const char *p = +#if 0 + "=pc pc\n" "=sp sp\n" "=a0 a0\n" "=a1 a1\n" @@ -464,8 +466,9 @@ static int mips_set_reg_profile(RAnal* anal){ "gpr fp .32 120 0\n" "gpr ra .32 124 0\n" "gpr pc .32 128 0\n"; +#else // take the one from the debugger // - return strdup ( + p = "=pc pc\n" "=sp sp\n" "=bp fp\n" @@ -512,8 +515,9 @@ static int mips_set_reg_profile(RAnal* anal){ "gpr ra .64 248 0\n" /* extra */ "gpr pc .64 272 0\n" - ); - return r_reg_set_profile_string(anal->reg, p); + ; +#endif + return r_reg_set_profile_string (anal->reg, p); } struct r_anal_plugin_t r_anal_plugin_mips_gnu = { diff --git a/libr/core/bin.c b/libr/core/bin.c index d7527e7d1f..a5aaf8123f 100644 --- a/libr/core/bin.c +++ b/libr/core/bin.c @@ -1263,7 +1263,7 @@ R_API int r_core_bin_info (RCore *core, int action, int mode, int va, RCoreBinFi return ret; } -R_API int r_core_bin_set_arch_bits (RCore *r, char *name, const char * arch, ut16 bits) { +R_API int r_core_bin_set_arch_bits (RCore *r, const char *name, const char * arch, ut16 bits) { RCoreFile *cf = r_core_file_cur (r); RBinFile *binfile; diff --git a/libr/core/config.c b/libr/core/config.c index 910eeacdff..0e76ca4e3e 100644 --- a/libr/core/config.c +++ b/libr/core/config.c @@ -66,6 +66,13 @@ static inline void __setsegoff(RConfig *cfg, const char *asmarch, int asmbits) { r_config_set (cfg, "asm.segoff", (asmbits==16)?"true":"false"); } +static int cb_analnopskip (void *user, void *data) { + RCore *core = (RCore*) user; + RConfigNode *node = (RConfigNode*) data; + core->anal->nopskip = node->i_value; + return R_TRUE; +} + static int cb_analarch(void *user, void *data) { RCore *core = (RCore*) user; RConfigNode *node = (RConfigNode*) data; @@ -711,6 +718,7 @@ R_API int r_core_config_init(RCore *core) { SETI("anal.depth", 50, "Max depth at code analysis"); // XXX: warn if depth is > 50 .. can be problematic SETPREF("anal.hasnext", "true", "Continue analysis after each function"); SETPREF("anal.esil", "false", "Use the new ESIL code analysis"); + SETCB("anal.nopskip", "true", &cb_analnopskip, "Skip nops at the begining of functions"); SETCB("anal.arch", R_SYS_ARCH, &cb_analarch, "Specify the anal.arch to use"); SETCB("anal.cpu", R_SYS_ARCH, &cb_analcpu, "Specify the anal.cpu to use"); SETPREF("anal.prelude", "", "Specify an hexpair to find preludes in code"); diff --git a/libr/include/r_anal.h b/libr/include/r_anal.h index 7d8ab5de10..af7fd6acad 100644 --- a/libr/include/r_anal.h +++ b/libr/include/r_anal.h @@ -521,6 +521,7 @@ typedef struct r_anal_t { int lineswidth; // wtf int big_endian; int split; // used only from core + int nopskip; // skip nops at the begining of functions void *user; RList *fcns; RListRange *fcnstore; diff --git a/libr/include/r_core.h b/libr/include/r_core.h index 5da8eada71..a25a85b569 100644 --- a/libr/include/r_core.h +++ b/libr/include/r_core.h @@ -374,7 +374,7 @@ typedef struct r_core_bin_filter_t { } RCoreBinFilter; R_API int r_core_bin_info (RCore *core, int action, int mode, int va, RCoreBinFilter *filter, ut64 offset, const char *chksum); -R_API int r_core_bin_set_arch_bits (RCore *r, char *name, const char * arch, ut16 bits); +R_API int r_core_bin_set_arch_bits (RCore *r, const char *name, const char * arch, ut16 bits); R_API int r_core_bin_update_arch_bits (RCore *r); /* rtr */ R_API int r_core_rtr_cmds (RCore *core, const char *port);