mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-11 23:16:05 +00:00
arm asm.varsub supports asm.pseudo for fp (#10071)
This commit is contained in:
parent
04108092f4
commit
e32542aa85
@ -5108,6 +5108,7 @@ static bool cmd_anal_refs(RCore *core, const char *input) {
|
||||
}
|
||||
} else if (input[1] == 'j') { // "axtj"
|
||||
bool asm_varsub = r_config_get_i (core->config, "asm.varsub");
|
||||
core->parser->pseudo = r_config_get_i (core->config, "asm.pseudo");
|
||||
core->parser->relsub = r_config_get_i (core->config, "asm.relsub");
|
||||
core->parser->localvar_only = r_config_get_i (core->config, "asm.varsub_only");
|
||||
r_cons_printf ("[");
|
||||
@ -5169,6 +5170,7 @@ static bool cmd_anal_refs(RCore *core, const char *input) {
|
||||
RAnalFunction *fcn;
|
||||
char *comment;
|
||||
bool asm_varsub = r_config_get_i (core->config, "asm.varsub");
|
||||
core->parser->pseudo = r_config_get_i (core->config, "asm.pseudo");
|
||||
core->parser->relsub = r_config_get_i (core->config, "asm.relsub");
|
||||
core->parser->localvar_only = r_config_get_i (core->config, "asm.varsub_only");
|
||||
if (core->parser->relsub) {
|
||||
|
@ -583,7 +583,7 @@ static RDisasmState * ds_init(RCore *core) {
|
||||
ds->midflags = r_config_get_i (core->config, "asm.midflags");
|
||||
ds->midcursor = r_config_get_i (core->config, "asm.midcursor");
|
||||
ds->decode = r_config_get_i (core->config, "asm.decode");
|
||||
ds->pseudo = r_config_get_i (core->config, "asm.pseudo");
|
||||
core->parser->pseudo = ds->pseudo = r_config_get_i (core->config, "asm.pseudo");
|
||||
if (ds->pseudo) {
|
||||
ds->atabs = 0;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ typedef struct r_parse_t {
|
||||
void *user;
|
||||
int flagspace;
|
||||
int notin_flagspace;
|
||||
bool pseudo;
|
||||
bool relsub; // replace rip relative expressions in instruction
|
||||
bool localvar_only; // if true use only the local variable name (e.g. [local_10h] instead of [ebp + local10h])
|
||||
int relsub_addr;
|
||||
|
@ -280,18 +280,26 @@ static bool varsub(RParse *p, RAnalFunction *f, ut64 addr, int oplen, char *data
|
||||
spargs = p->varlist (p->anal, f, 's');
|
||||
bool ucase = IS_UPPER (*tstr);
|
||||
r_list_foreach (bpargs, iter, var) {
|
||||
char *reg = p->anal->reg->name[R_REG_NAME_BP];
|
||||
char *tmplt = NULL;
|
||||
if (var->delta > -10 && var->delta < 10) {
|
||||
oldstr = r_str_newf ("[%s, %d]",
|
||||
p->anal->reg->name[R_REG_NAME_BP],
|
||||
var->delta);
|
||||
if (p->pseudo) {
|
||||
char sign = '+';
|
||||
int delta = var->delta;
|
||||
if (var->delta < 0) {
|
||||
sign = '-';
|
||||
delta = -delta;
|
||||
}
|
||||
oldstr = r_str_newf ("[%s %c %d]", reg, sign, delta);
|
||||
} else {
|
||||
oldstr = r_str_newf ("[%s, %d]", reg, var->delta);
|
||||
}
|
||||
} else if (var->delta > 0) {
|
||||
oldstr = r_str_newf ("[%s, 0x%x]",
|
||||
p->anal->reg->name[R_REG_NAME_BP],
|
||||
var->delta);
|
||||
tmplt = p->pseudo ? "[%s + 0x%x]" : "[%s, 0x%x]";
|
||||
oldstr = r_str_newf (tmplt, reg, var->delta);
|
||||
} else {
|
||||
oldstr = r_str_newf ("[%s, -0x%x]",
|
||||
p->anal->reg->name[R_REG_NAME_BP],
|
||||
-var->delta);
|
||||
tmplt = p->pseudo ? "[%s - 0x%x]" : "[%s, -0x%x]";
|
||||
oldstr = r_str_newf (tmplt, reg, -var->delta);
|
||||
}
|
||||
if (ucase) {
|
||||
char *comma = strchr (oldstr, ',');
|
||||
@ -303,9 +311,7 @@ static bool varsub(RParse *p, RAnalFunction *f, ut64 addr, int oplen, char *data
|
||||
}
|
||||
if (strstr (tstr, oldstr)) {
|
||||
newstr = r_str_newf ("[%s %c %s]",
|
||||
p->anal->reg->name[R_REG_NAME_BP],
|
||||
var->delta > 0 ? '+' : '-',
|
||||
var->name);
|
||||
reg, var->delta > 0 ? '+' : '-', var->name);
|
||||
if (ucase) {
|
||||
char *comma = strchr (newstr, ' ');
|
||||
if (comma) {
|
||||
|
@ -25,6 +25,7 @@ R_API RParse *r_parse_new() {
|
||||
p->parsers->free = NULL; // memleak
|
||||
p->notin_flagspace = -1;
|
||||
p->flagspace = -1;
|
||||
p->pseudo = false;
|
||||
p->relsub = false;
|
||||
p->minval = 0x100;
|
||||
p->localvar_only = false;
|
||||
|
Loading…
Reference in New Issue
Block a user