mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-17 12:48:41 +00:00
Load types and cc info on asm.arch change
This commit is contained in:
parent
3be9aa12be
commit
ed4e5afbbb
@ -4,10 +4,12 @@
|
||||
|
||||
#include <r_anal.h>
|
||||
#define DB anal->sdb_cc
|
||||
|
||||
R_API int r_anal_cc_exist (RAnal *anal, const char *convention) {
|
||||
const char *x = sdb_const_get (DB, convention, 0);
|
||||
return x && *x && !strcmp (x, "cc");
|
||||
}
|
||||
|
||||
R_API const char *r_anal_cc_arg(RAnal *anal, const char *convention, int n) {
|
||||
const char *query, *ret;
|
||||
if (n < 1) {
|
||||
@ -22,13 +24,16 @@ R_API const char *r_anal_cc_arg(RAnal *anal, const char *convention, int n) {
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
R_API const char *r_anal_cc_ret(RAnal *anal, const char *convention) {
|
||||
char *query = sdb_fmt (-1, "cc.%s.ret", convention);
|
||||
return sdb_const_get (DB, query, 0);
|
||||
}
|
||||
|
||||
R_API const char *r_anal_cc_default(RAnal *anal) {
|
||||
return sdb_const_get (DB, "default.cc", 0);
|
||||
}
|
||||
|
||||
R_API const char *r_anal_cc_to_constant(RAnal *anal, char *convention) {
|
||||
char *query = sdb_fmt (-1, "cc.%s.name", convention);
|
||||
return sdb_const_get (DB, query, 0);
|
||||
|
@ -421,9 +421,9 @@ static void sdb_concat_by_path (Sdb *s, const char *path) {
|
||||
sdb_merge (s, db);
|
||||
sdb_close (db);
|
||||
sdb_free (db);
|
||||
|
||||
}
|
||||
static void r_anal_type_init(RCore *core) {
|
||||
|
||||
R_API void r_core_anal_type_init(RCore *core) {
|
||||
Sdb *types = core->anal->sdb_types;
|
||||
const char *anal_arch = r_config_get (core->config, "anal.arch");
|
||||
const char *os = r_config_get (core->config, "asm.os");
|
||||
@ -443,11 +443,10 @@ static void r_anal_type_init(RCore *core) {
|
||||
}
|
||||
}
|
||||
|
||||
static void r_anal_cc_init(RCore *core) {
|
||||
const char *anal_arch = r_config_get (core->config, "anal.arch");
|
||||
char *dbpath;
|
||||
R_API void r_core_anal_cc_init(RCore *core) {
|
||||
Sdb *db;
|
||||
dbpath = sdb_fmt (-1, DBSPATH"/cc-%s-%d.sdb", anal_arch,
|
||||
const char *anal_arch = r_config_get (core->config, "anal.arch");
|
||||
char *dbpath = sdb_fmt (-1, DBSPATH"/cc-%s-%d.sdb", anal_arch,
|
||||
r_config_get_i (core->config, "asm.bits"));
|
||||
if (r_file_exists (dbpath)) {
|
||||
db = sdb_new (0, dbpath, 0);
|
||||
@ -593,15 +592,15 @@ static int bin_info(RCore *r, int mode) {
|
||||
}
|
||||
|
||||
for (i = 0; info->sum[i].type; i++) {
|
||||
int len;
|
||||
RBinHash *h = &info->sum[i];
|
||||
ut64 hash = r_hash_name_to_bits (h->type);
|
||||
RHash *rh = r_hash_new (true, hash);
|
||||
len = r_hash_calculate (rh, hash, (const ut8*)
|
||||
int len = r_hash_calculate (rh, hash, (const ut8*)
|
||||
binfile->buf->buf+h->from, h->to);
|
||||
if (len < 1) eprintf ("Invaild wtf\n");
|
||||
if (len < 1) {
|
||||
eprintf ("Invaild wtf\n");
|
||||
}
|
||||
r_hash_free (rh);
|
||||
|
||||
r_cons_printf ("%s\t%d-%dc\t", h->type, h->from, h->to+h->from);
|
||||
for (j = 0; j < h->len; j++) {
|
||||
r_cons_printf ("%02x", h->buf[j]);
|
||||
@ -611,8 +610,8 @@ static int bin_info(RCore *r, int mode) {
|
||||
pair_str ("guid", info->guid, mode, true);
|
||||
if (IS_MODE_JSON (mode)) r_cons_printf ("}");
|
||||
}
|
||||
r_anal_type_init (r);
|
||||
r_anal_cc_init (r);
|
||||
r_core_anal_type_init (r);
|
||||
r_core_anal_cc_init (r);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,6 @@ static int cb_asmarch(void *user, void *data) {
|
||||
if (core->anal->bits) {
|
||||
bits = core->anal->bits;
|
||||
}
|
||||
|
||||
if (*node->value == '?') {
|
||||
rasm2_list (core, NULL, node->value[1]);
|
||||
return false;
|
||||
@ -195,12 +194,10 @@ static int cb_asmarch(void *user, void *data) {
|
||||
if (!*node->value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!r_asm_use (core->assembler, node->value)) {
|
||||
eprintf ("asm.arch: cannot find (%s)\n", node->value);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (core->assembler && core->assembler->cur) {
|
||||
bits = core->assembler->cur->bits;
|
||||
if (8 & bits) {
|
||||
@ -265,6 +262,9 @@ static int cb_asmarch(void *user, void *data) {
|
||||
// set endian of display to match binary
|
||||
core->print->big_endian = bigbin;
|
||||
}
|
||||
/* reload types and cc info */
|
||||
r_core_anal_type_init (core);
|
||||
r_core_anal_cc_init (core);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -247,6 +247,9 @@ R_API ut64 r_core_get_asmqjmps(RCore *core, const char *str);
|
||||
R_API void r_core_set_asmqjmps(RCore *core, char *str, size_t len, int i);
|
||||
R_API char* r_core_add_asmqjmp(RCore *core, ut64 addr);
|
||||
|
||||
R_API void r_core_anal_type_init(RCore *core);
|
||||
R_API void r_core_anal_cc_init(RCore *core);
|
||||
|
||||
R_API void r_core_list_io(RCore *core);
|
||||
/* visual marks */
|
||||
R_API void r_core_visual_mark_seek(RCore *core, ut8 ch);
|
||||
|
Loading…
x
Reference in New Issue
Block a user