mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-13 16:18:33 +00:00
Add anal.nopskip config var
This commit is contained in:
parent
c185ca44c8
commit
a7395d5afc
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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;;
|
||||
|
@ -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 = {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user