mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-08 14:58:54 +00:00
Always show all the archinfo, even when not provided by the plug ##analysis
This commit is contained in:
parent
52efddb2c6
commit
6896f6f6a7
@ -485,6 +485,14 @@ R_API void r_anal_purge(RAnal *anal) {
|
||||
r_anal_purge_imports (anal);
|
||||
}
|
||||
|
||||
|
||||
static int default_archinfo(int res, int q) {
|
||||
if (res < 1) {
|
||||
return 1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// XXX deprecate. use r_arch_info() when all anal plugs get moved
|
||||
// XXX this function should NEVER return -1. it should provide all valid values, even if the delegate does not
|
||||
R_API R_DEPRECATE int r_anal_archinfo(RAnal *anal, int query) {
|
||||
@ -497,17 +505,15 @@ R_API R_DEPRECATE int r_anal_archinfo(RAnal *anal, int query) {
|
||||
const char *const b = anal->config->arch;
|
||||
if (!strcmp (a, b)) {
|
||||
int res = r_arch_info (anal->arch, query);
|
||||
if (res != -1) {
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
return default_archinfo (res, query);
|
||||
}
|
||||
}
|
||||
int res = -1;
|
||||
// this is the anal archinfo fallback
|
||||
if (anal->cur && anal->cur->archinfo) {
|
||||
return anal->cur->archinfo (anal, query);
|
||||
res = anal->cur->archinfo (anal, query);
|
||||
}
|
||||
return -1;
|
||||
return default_archinfo (res, query);
|
||||
}
|
||||
|
||||
R_API bool r_anal_is_aligned(RAnal *anal, const ut64 addr) {
|
||||
|
@ -2239,7 +2239,7 @@ static void core_anal_bytes(RCore *core, const ut8 *buf, int len, int nops, int
|
||||
(void)r_asm_disassemble (core->rasm, &asmop, buf + idx, len - idx);
|
||||
esilstr = R_STRBUF_SAFEGET (&op.esil);
|
||||
opexstr = R_STRBUF_SAFEGET (&op.opex);
|
||||
char *mnem = strdup (r_asm_op_get_asm (&asmop));
|
||||
char *mnem = strdup (r_str_get (r_asm_op_get_asm (&asmop)));
|
||||
char *sp = strchr (mnem, ' ');
|
||||
if (sp) {
|
||||
*sp = 0;
|
||||
@ -6157,50 +6157,30 @@ static void cmd_anal_info(RCore *core, const char *input) {
|
||||
PJ *pj = pj_new ();
|
||||
pj_o (pj);
|
||||
int v = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_MIN_OP_SIZE);
|
||||
if (v > 0) {
|
||||
pj_ki (pj, "minopsz", v);
|
||||
}
|
||||
pj_ki (pj, "minopsz", v);
|
||||
v = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_MAX_OP_SIZE);
|
||||
if (v > 0) {
|
||||
pj_ki (pj, "maxopsz", v);
|
||||
}
|
||||
pj_ki (pj, "maxopsz", v);
|
||||
v = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_INV_OP_SIZE);
|
||||
if (v > 0) {
|
||||
pj_ki (pj, "invopsz", v);
|
||||
}
|
||||
pj_ki (pj, "invopsz", v);
|
||||
v = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_DATA_ALIGN);
|
||||
if (v > 0) {
|
||||
pj_ki (pj, "dtalign", v);
|
||||
}
|
||||
pj_ki (pj, "dtalign", v);
|
||||
v = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_ALIGN);
|
||||
if (v > 0) {
|
||||
pj_ki (pj, "pcalign", v);
|
||||
}
|
||||
pj_ki (pj, "pcalign", v);
|
||||
pj_end (pj);
|
||||
char *s = pj_drain (pj);
|
||||
r_cons_printf ("%s\n", s);
|
||||
free (s);
|
||||
} else {
|
||||
int v = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_MIN_OP_SIZE);
|
||||
if (v > 0) {
|
||||
r_cons_printf ("minopsz %d\n", v);
|
||||
}
|
||||
r_cons_printf ("minopsz %d\n", v);
|
||||
v = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_MAX_OP_SIZE);
|
||||
if (v > 0) {
|
||||
r_cons_printf ("maxopsz %d\n", v);
|
||||
}
|
||||
r_cons_printf ("maxopsz %d\n", v);
|
||||
v = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_INV_OP_SIZE);
|
||||
if (v > 0) {
|
||||
r_cons_printf ("invopsz %d\n", v);
|
||||
}
|
||||
r_cons_printf ("invopsz %d\n", v);
|
||||
v = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_DATA_ALIGN);
|
||||
if (v > 0) {
|
||||
r_cons_printf ("dtalign %d\n", v);
|
||||
}
|
||||
r_cons_printf ("dtalign %d\n", v);
|
||||
v = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_ALIGN);
|
||||
if (v > 0) {
|
||||
r_cons_printf ("pcalign %d\n", v);
|
||||
}
|
||||
r_cons_printf ("pcalign %d\n", v);
|
||||
}
|
||||
break;
|
||||
case 'i': // "aii"
|
||||
|
@ -46,6 +46,7 @@ snes
|
||||
minopsz 1
|
||||
maxopsz 3
|
||||
invopsz 1
|
||||
dtalign 1
|
||||
pcalign 1
|
||||
0x00400000
|
||||
0x00400039
|
||||
|
@ -245,7 +245,7 @@ nth paddr vaddr bind type size lib name
|
||||
e cfg.bigendian=false
|
||||
e asm.bits=64
|
||||
e asm.dwarf=false
|
||||
e asm.pcalign=0
|
||||
e asm.pcalign=1
|
||||
fs imports
|
||||
fs symbols
|
||||
fs exports
|
||||
@ -293,7 +293,7 @@ block 0x100
|
||||
e cfg.bigendian=false
|
||||
e asm.bits=64
|
||||
e asm.dwarf=false
|
||||
e asm.pcalign=0
|
||||
e asm.pcalign=1
|
||||
baddr 0x0
|
||||
binsz 1024
|
||||
bits 64
|
||||
@ -314,7 +314,7 @@ va false
|
||||
e cfg.bigendian=false
|
||||
e asm.bits=64
|
||||
e asm.dwarf=false
|
||||
e asm.pcalign=0
|
||||
e asm.pcalign=1
|
||||
EOF
|
||||
RUN
|
||||
|
||||
|
@ -10,6 +10,7 @@ EOF
|
||||
EXPECT=<<EOF
|
||||
minopsz 2
|
||||
maxopsz 8
|
||||
invopsz 1
|
||||
dtalign 2
|
||||
pcalign 2
|
||||
--
|
||||
|
Loading…
x
Reference in New Issue
Block a user