mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-27 07:00:30 +00:00
Remove asm.features, improve RBinInfo with flags and abi details ##bin
* asm.features has been replaced with asm.abi * For non-abi elf-flags check the RBinInfo.flags field * Respect asm.cpu from bin.cpu * Use asm.abi from mips.gnu instead of fuzzy abi detection via features
This commit is contained in:
parent
430d6e2310
commit
f10a1a335e
@ -4445,10 +4445,6 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len, RAn
|
||||
mode |= CS_MODE_V8;
|
||||
}
|
||||
}
|
||||
if (a->config->bits != 64 && R_STR_ISNOTEMPTY (a->config->features) &&
|
||||
strstr (a->config->features, "v8")) {
|
||||
mode |= CS_MODE_V8;
|
||||
}
|
||||
if (mode != a->cs_omode || a->config->bits != a->cs_obits) {
|
||||
if (a->cs_handle != 0) {
|
||||
cs_close (&a->cs_handle);
|
||||
@ -4547,10 +4543,6 @@ static char *arm_mnemonics(RAnal *a, int id, bool json) {
|
||||
mode |= CS_MODE_V8;
|
||||
}
|
||||
}
|
||||
if (a->config->bits != 64 && R_STR_ISNOTEMPTY (a->config->features) &&
|
||||
strstr (a->config->features, "v8")) {
|
||||
mode |= CS_MODE_V8;
|
||||
}
|
||||
if (mode != a->cs_omode || a->config->bits != a->cs_obits) {
|
||||
if (a->cs_handle != 0) {
|
||||
cs_close (&a->cs_handle);
|
||||
|
@ -12,7 +12,6 @@ static R_TH_LOCAL unsigned long Offset = 0;
|
||||
static R_TH_LOCAL RStrBuf *buf_global = NULL;
|
||||
static R_TH_LOCAL ut8 bytes[8] = { 0 };
|
||||
static R_TH_LOCAL char *pre_cpu = NULL;
|
||||
static R_TH_LOCAL char *pre_features = NULL;
|
||||
static R_TH_LOCAL int mips_mode = 0;
|
||||
|
||||
static int symbol_at_address(bfd_vma addr, struct disassemble_info *info) {
|
||||
@ -1130,10 +1129,6 @@ static int disassemble(RAnal *a, RAnalOp *op, const ut8 *buf, int len) {
|
||||
memcpy (&bytes, buf, R_MIN (len, 8));
|
||||
|
||||
const char *cpu = a->config->cpu;
|
||||
if ((cpu != pre_cpu) && (a->config->features != pre_features)) {
|
||||
free (disasm_obj.disassembler_options);
|
||||
memset (&disasm_obj, '\0', sizeof (struct disassemble_info));
|
||||
}
|
||||
|
||||
/* prepare disassembler */
|
||||
if (cpu && (!pre_cpu || !strcmp (cpu, pre_cpu))) {
|
||||
@ -1166,21 +1161,16 @@ static int disassemble(RAnal *a, RAnalOp *op, const ut8 *buf, int len) {
|
||||
disasm_obj.mach = bfd_mach_mips_loongson_2f;
|
||||
}
|
||||
|
||||
const char *features = a->config->features;
|
||||
if (features && (!pre_features || !strcmp (features, pre_features))) {
|
||||
free (disasm_obj.disassembler_options);
|
||||
if (strstr (features, "n64")) {
|
||||
disasm_obj.disassembler_options = r_str_new ("abi=n64");
|
||||
} else if (strstr (features, "n32")) {
|
||||
disasm_obj.disassembler_options = r_str_new ("abi=n32");
|
||||
} else if (strstr (features, "o32")) {
|
||||
disasm_obj.disassembler_options = r_str_new ("abi=o32");
|
||||
}
|
||||
pre_features = r_str_dup (pre_features, features);
|
||||
const char *abi = a->config->abi;
|
||||
// const char *features = a->config->features;
|
||||
disasm_obj.disassembler_options = NULL;
|
||||
if (R_STR_ISNOTEMPTY (abi)) {
|
||||
// n32, n64, o32
|
||||
disasm_obj.disassembler_options = r_str_newf ("abi=%s", abi);
|
||||
}
|
||||
|
||||
mips_mode = a->config->bits;
|
||||
disasm_obj.arch = CPU_LOONGSON_2F;
|
||||
disasm_obj.arch = CPU_LOONGSON_2F; // XXX should be different see .mach
|
||||
disasm_obj.buffer = (ut8 *)&bytes;
|
||||
disasm_obj.read_memory_func = &mips_buffer_read_memory;
|
||||
disasm_obj.symbol_at_address_func = &symbol_at_address;
|
||||
@ -1200,6 +1190,7 @@ static int disassemble(RAnal *a, RAnalOp *op, const ut8 *buf, int len) {
|
||||
op->mnemonic = r_strbuf_drain (buf_global);
|
||||
buf_global = NULL;
|
||||
}
|
||||
free (disasm_obj.disassembler_options);
|
||||
return op->size;
|
||||
}
|
||||
|
||||
@ -1931,6 +1922,7 @@ RAnalPlugin r_anal_plugin_mips_gnu = {
|
||||
.name = "mips.gnu",
|
||||
.desc = "MIPS code analysis plugin",
|
||||
.license = "LGPL3",
|
||||
.cpus = "mips64r2,mips32r2,mips64,mips32,loongson3a,gs464,gs464e,gs264e,loongson2e,loongson2f,mips32/64",
|
||||
.arch = "mips",
|
||||
.bits = 32,
|
||||
.esil = true,
|
||||
|
@ -130,25 +130,26 @@ R_API void r_bin_info_free(RBinInfo *rb) {
|
||||
return;
|
||||
}
|
||||
r_list_free (rb->file_hashes);
|
||||
free (rb->intrp);
|
||||
free (rb->file);
|
||||
free (rb->charset);
|
||||
free (rb->type);
|
||||
free (rb->bclass);
|
||||
free (rb->rclass);
|
||||
free (rb->arch);
|
||||
free (rb->cpu);
|
||||
free (rb->machine);
|
||||
free (rb->os);
|
||||
free (rb->subsystem);
|
||||
free (rb->default_cc);
|
||||
free (rb->rpath);
|
||||
free (rb->guid);
|
||||
free (rb->debug_file_name);
|
||||
free (rb->abi);
|
||||
free (rb->actual_checksum);
|
||||
free (rb->arch);
|
||||
free (rb->bclass);
|
||||
free (rb->charset);
|
||||
free (rb->claimed_checksum);
|
||||
free (rb->compiler);
|
||||
free (rb->head_flag);
|
||||
free (rb->cpu);
|
||||
free (rb->debug_file_name);
|
||||
free (rb->default_cc);
|
||||
free (rb->file);
|
||||
free (rb->flags);
|
||||
free (rb->guid);
|
||||
free (rb->intrp);
|
||||
free (rb->machine);
|
||||
free (rb->os);
|
||||
free (rb->rclass);
|
||||
free (rb->rpath);
|
||||
free (rb->subsystem);
|
||||
free (rb->type);
|
||||
free (rb);
|
||||
}
|
||||
|
||||
@ -975,6 +976,21 @@ static void list_xtr_archs(RBin *bin, PJ *pj, int mode) {
|
||||
}
|
||||
}
|
||||
|
||||
static char *get_arch_string(const char *arch, int bits, RBinInfo *info) {
|
||||
RStrBuf *sb = r_strbuf_new ("");
|
||||
r_strbuf_appendf (sb, "%s_%d", arch, bits);
|
||||
if (R_STR_ISNOTEMPTY (info->cpu)) {
|
||||
r_strbuf_appendf (sb, " cpu=%s", info->cpu);
|
||||
}
|
||||
if (R_STR_ISNOTEMPTY (info->abi)) {
|
||||
r_strbuf_appendf (sb, " abi=%s", info->abi);
|
||||
}
|
||||
if (R_STR_ISNOTEMPTY (info->machine)) {
|
||||
r_strbuf_appendf (sb, " machine=%s", info->machine);
|
||||
}
|
||||
return r_strbuf_drain (sb);
|
||||
}
|
||||
|
||||
R_API void r_bin_list_archs(RBin *bin, PJ *pj, int mode) {
|
||||
r_return_if_fail (bin);
|
||||
|
||||
@ -1015,7 +1031,6 @@ R_API void r_bin_list_archs(RBin *bin, PJ *pj, int mode) {
|
||||
ut64 obj_size = obj->obj_size;
|
||||
const char *arch = info? info->arch: NULL;
|
||||
const char *machine = info? info->machine: "unknown_machine";
|
||||
const char *h_flag = info? info->head_flag: NULL;
|
||||
char * str_fmt;
|
||||
if (!arch) {
|
||||
snprintf (unk, sizeof (unk), "unk_0");
|
||||
@ -1035,9 +1050,12 @@ R_API void r_bin_list_archs(RBin *bin, PJ *pj, int mode) {
|
||||
pj_ki (pj, "bits", bits);
|
||||
pj_kn (pj, "offset", boffset);
|
||||
pj_kn (pj, "size", obj_size);
|
||||
if (R_STR_ISNOTEMPTY (info->abi)) {
|
||||
pj_ks (pj, "abi", info->abi);
|
||||
}
|
||||
if (!strcmp (arch, "mips")) {
|
||||
pj_ks (pj, "isa", info->cpu);
|
||||
pj_ks (pj, "features", info->features);
|
||||
pj_ks (pj, "flags", info->flags);
|
||||
}
|
||||
if (machine) {
|
||||
pj_ks (pj, "machine", machine);
|
||||
@ -1045,9 +1063,7 @@ R_API void r_bin_list_archs(RBin *bin, PJ *pj, int mode) {
|
||||
pj_end (pj);
|
||||
break;
|
||||
default:
|
||||
str_fmt = h_flag && strcmp (h_flag, "unknown_flag")
|
||||
? r_str_newf ("%s_%i %s", arch, bits, h_flag) \
|
||||
: r_str_newf ("%s_%i", arch, bits);
|
||||
str_fmt = get_arch_string (arch, bits, info);
|
||||
r_table_add_rowf (table, fmt, 0, boffset, obj_size, str_fmt, machine);
|
||||
free (str_fmt);
|
||||
bin->cb_printf ("%s", r_table_tostring (table));
|
||||
@ -1069,9 +1085,12 @@ R_API void r_bin_list_archs(RBin *bin, PJ *pj, int mode) {
|
||||
pj_ki (pj, "bits", bits);
|
||||
pj_kn (pj, "offset", boffset);
|
||||
pj_kn (pj, "size", obj_size);
|
||||
if (R_STR_ISNOTEMPTY (info->abi)) {
|
||||
pj_ks (pj, "abi", info->abi);
|
||||
}
|
||||
if (!strcmp (arch, "mips")) {
|
||||
pj_ks (pj, "isa", info->cpu);
|
||||
pj_ks (pj, "features", info->features);
|
||||
pj_ks (pj, "flags", info->flags);
|
||||
}
|
||||
if (machine) {
|
||||
pj_ks (pj, "machine", machine);
|
||||
@ -1079,9 +1098,7 @@ R_API void r_bin_list_archs(RBin *bin, PJ *pj, int mode) {
|
||||
pj_end (pj);
|
||||
break;
|
||||
default:
|
||||
str_fmt = h_flag && strcmp (h_flag, "unknown_flag")
|
||||
? r_str_newf ("%s_%i %s", arch, bits, h_flag)
|
||||
: r_str_newf ("%s_%i", arch, bits);
|
||||
str_fmt = get_arch_string (arch, bits, info);
|
||||
r_table_add_rowf (table, fmt, 0, boffset, obj_size, str_fmt, "");
|
||||
free (str_fmt);
|
||||
bin->cb_printf ("%s", r_table_tostring (table));
|
||||
|
@ -820,7 +820,7 @@ static Sdb *store_versioninfo_gnu_versym(ELFOBJ *bin, Elf_(Shdr) *shdr, int sz)
|
||||
break;
|
||||
default:
|
||||
free (tmp_val);
|
||||
tmp_val = r_str_newf ("%x ", data[i+j] & 0x7FFF);
|
||||
tmp_val = r_str_newf ("%x ", data[i + j] & 0x7FFF);
|
||||
check_def = true;
|
||||
if (bin->version_info[DT_VERSIONTAGIDX (DT_VERNEED)]) {
|
||||
Elf_(Verneed) vn;
|
||||
@ -2177,19 +2177,46 @@ char* Elf_(r_bin_elf_get_arch)(ELFOBJ *bin) {
|
||||
default: return strdup ("Unknown or unsupported arch");
|
||||
}
|
||||
}
|
||||
|
||||
char* Elf_(r_bin_elf_get_abi)(ELFOBJ *bin) {
|
||||
Elf_(Ehdr)* ehdr = (Elf_(Ehdr) *) &bin->ehdr;
|
||||
ut32 eflags = bin->ehdr.e_flags;
|
||||
|
||||
if (ehdr->e_machine == EM_MIPS) {
|
||||
if (is_elfclass64 (ehdr)) {
|
||||
return strdup ("n64");
|
||||
switch (ehdr->e_machine) {
|
||||
case EM_68K:
|
||||
if (eflags & 0x1000000) {
|
||||
return strdup ("68000");
|
||||
}
|
||||
if (is_mips_n32 (ehdr)) {
|
||||
return strdup ("n32");
|
||||
if (eflags & 0x810000) {
|
||||
return strdup ("cpu32");
|
||||
}
|
||||
if (is_mips_o32 (ehdr)) {
|
||||
return strdup ("o32");
|
||||
if (eflags == 0) {
|
||||
return strdup ("68020");
|
||||
}
|
||||
case EM_ARM:
|
||||
{
|
||||
int v = (eflags >> 24);
|
||||
const char *arg = "";
|
||||
if (eflags & 0x800000) {
|
||||
arg = " be8";
|
||||
} else if (eflags & 0x400000) {
|
||||
arg = " le8";
|
||||
}
|
||||
return r_str_newf ("eabi%d%s", v, arg);
|
||||
}
|
||||
case EM_MIPS:
|
||||
{
|
||||
if (is_elfclass64 (ehdr)) {
|
||||
return strdup ("n64");
|
||||
}
|
||||
if (is_mips_n32 (ehdr)) {
|
||||
return strdup ("n32");
|
||||
}
|
||||
if (is_mips_o32 (ehdr)) {
|
||||
return strdup ("o32");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -2198,39 +2225,21 @@ char* Elf_(r_bin_elf_get_cpu)(ELFOBJ *bin) {
|
||||
if (bin->phdr && bin->ehdr.e_machine == EM_MIPS) {
|
||||
const ut32 mipsType = bin->ehdr.e_flags & EF_MIPS_ARCH;
|
||||
switch (mipsType) {
|
||||
case EF_MIPS_ARCH_1: return strdup ("mips1");
|
||||
case EF_MIPS_ARCH_2: return strdup ("mips2");
|
||||
case EF_MIPS_ARCH_3: return strdup ("mips3");
|
||||
case EF_MIPS_ARCH_4: return strdup ("mips4");
|
||||
case EF_MIPS_ARCH_5: return strdup ("mips5");
|
||||
case EF_MIPS_ARCH_32: return strdup ("mips32");
|
||||
case EF_MIPS_ARCH_64: return strdup ("mips64");
|
||||
case EF_MIPS_ARCH_32R2: return strdup ("mips32r2");
|
||||
case EF_MIPS_ARCH_64R2: return strdup ("mips64r2");
|
||||
default : return strdup (" Unknown mips ISA");
|
||||
case EF_MIPS_ARCH_1: return strdup ("mips1");
|
||||
case EF_MIPS_ARCH_2: return strdup ("mips2");
|
||||
case EF_MIPS_ARCH_3: return strdup ("mips3");
|
||||
case EF_MIPS_ARCH_4: return strdup ("mips4");
|
||||
case EF_MIPS_ARCH_5: return strdup ("mips5");
|
||||
case EF_MIPS_ARCH_32: return strdup ("mips32");
|
||||
case EF_MIPS_ARCH_64: return strdup ("mips64");
|
||||
case EF_MIPS_ARCH_32R2: return strdup ("mips32r2");
|
||||
case EF_MIPS_ARCH_64R2: return strdup ("mips64r2");
|
||||
default : return strdup ("Unknown mips ISA");
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* Elf_(r_bin_elf_get_head_flag)(ELFOBJ *bin) {
|
||||
char *head_flag = NULL;
|
||||
char *str = Elf_(r_bin_elf_get_cpu) (bin);
|
||||
if (str) {
|
||||
head_flag = r_str_append (head_flag, str);
|
||||
free (str);
|
||||
}
|
||||
str = Elf_(r_bin_elf_get_abi) (bin);
|
||||
if (str) {
|
||||
head_flag = r_str_appendf (head_flag, " %s", str);
|
||||
free (str);
|
||||
}
|
||||
if (R_STR_ISEMPTY (head_flag)) {
|
||||
head_flag = r_str_append (head_flag, "unknown_flag");
|
||||
}
|
||||
return head_flag;
|
||||
}
|
||||
|
||||
// http://www.sco.com/developers/gabi/latest/ch4.eheader.html
|
||||
|
||||
char* Elf_(r_bin_elf_get_machine_name)(ELFOBJ *bin) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare2 - LGPL - Copyright 2009-2020 - pancake, nibble, dso */
|
||||
/* radare2 - LGPL - Copyright 2009-2022 - pancake, nibble, dso */
|
||||
|
||||
#include "bin_elf.inc"
|
||||
|
||||
|
@ -1168,24 +1168,18 @@ static RBinInfo* info(RBinFile *bf) {
|
||||
return NULL;
|
||||
}
|
||||
ret->machine = str;
|
||||
if (!(str = Elf_(r_bin_elf_get_head_flag) (obj))) {
|
||||
free (ret);
|
||||
return NULL;
|
||||
}
|
||||
ret->head_flag = str;
|
||||
if (!(str = Elf_(r_bin_elf_get_arch) (obj))) {
|
||||
free (ret);
|
||||
return NULL;
|
||||
}
|
||||
ret->arch = str;
|
||||
ret->cpu = Elf_(r_bin_elf_get_cpu) (obj);
|
||||
|
||||
if ((str = Elf_(r_bin_elf_get_cpu) (obj))) {
|
||||
ret->cpu = str;
|
||||
ut32 elf_flags = ((ELFOBJ *)obj)->ehdr.e_flags;
|
||||
if (elf_flags) {
|
||||
ret->flags = r_str_newf ("0x%x", elf_flags);
|
||||
}
|
||||
if ((str = Elf_(r_bin_elf_get_abi) (obj))) {
|
||||
ret->features = str;
|
||||
}
|
||||
|
||||
ret->abi = Elf_(r_bin_elf_get_abi) (obj);
|
||||
ret->rclass = strdup ("elf");
|
||||
ret->bits = Elf_(r_bin_elf_get_bits) (obj);
|
||||
if (!strcmp (ret->arch, "avr")) {
|
||||
|
@ -420,7 +420,6 @@ R_API RConfigNode* r_config_set(RConfig *cfg, const char *name, const char *valu
|
||||
ut64 oi;
|
||||
r_return_val_if_fail (cfg && cfg->ht, NULL);
|
||||
r_return_val_if_fail (!IS_NULLSTR (name), NULL);
|
||||
|
||||
RConfigNode *node = r_config_node_get (cfg, name);
|
||||
if (node) {
|
||||
if (r_config_node_is_ro (node)) {
|
||||
|
@ -872,14 +872,13 @@ static int bin_info(RCore *r, PJ *pj, int mode, ut64 laddr) {
|
||||
} else {
|
||||
r_config_set (r->config, "anal.cxxabi", "itanium");
|
||||
}
|
||||
if (R_STR_ISNOTEMPTY (info->abi)) {
|
||||
r_config_set (r->config, "asm.abi", info->abi);
|
||||
}
|
||||
// we can take the eabi from bin.features from arm (f.ex eabi4 eabi5)
|
||||
r_config_set (r->config, "asm.arch", info->arch);
|
||||
if (info->cpu && *info->cpu) {
|
||||
r_config_set (r->config, "asm.cpu", info->cpu);
|
||||
}
|
||||
if (info->features && *info->features) {
|
||||
r_config_set (r->config, "asm.features", info->features);
|
||||
}
|
||||
r_config_set (r->config, "anal.arch", info->arch);
|
||||
// r_config_set (r->config, "arch.decoder", info->arch);
|
||||
if (R_STR_ISNOTEMPTY (info->charset)) {
|
||||
r_config_set (r->config, "cfg.charset", info->charset);
|
||||
}
|
||||
@ -887,6 +886,9 @@ static int bin_info(RCore *r, PJ *pj, int mode, ut64 laddr) {
|
||||
r_config_set (r->config, "asm.bits", str);
|
||||
r_config_set (r->config, "asm.dwarf",
|
||||
(R_BIN_DBG_STRIPPED & info->dbg_info) ? "false" : "true");
|
||||
if (R_STR_ISNOTEMPTY (info->cpu)) {
|
||||
r_config_set (r->config, "asm.cpu", info->cpu);
|
||||
}
|
||||
}
|
||||
r_core_anal_type_init (r);
|
||||
r_core_anal_cc_init (r);
|
||||
@ -924,8 +926,7 @@ static int bin_info(RCore *r, PJ *pj, int mode, ut64 laddr) {
|
||||
r_cons_printf ("e cfg.charset=%s\n", info->charset);
|
||||
}
|
||||
if (R_STR_ISNOTEMPTY (info->rclass)) {
|
||||
r_cons_printf ("e file.type=%s\n",
|
||||
info->rclass);
|
||||
r_cons_printf ("e file.type=%s\n", info->rclass);
|
||||
}
|
||||
if (info->os) {
|
||||
r_cons_printf ("e asm.os=%s\n", info->os);
|
||||
@ -936,6 +937,9 @@ static int bin_info(RCore *r, PJ *pj, int mode, ut64 laddr) {
|
||||
if (R_STR_ISNOTEMPTY (info->cpu)) {
|
||||
r_cons_printf ("e asm.cpu=%s\n", info->cpu);
|
||||
}
|
||||
if (R_STR_ISNOTEMPTY (info->abi)) {
|
||||
r_cons_printf ("e asm.abi=%s\n", info->abi);
|
||||
}
|
||||
if (R_STR_ISNOTEMPTY (info->default_cc)) {
|
||||
r_cons_printf ("e anal.cc=%s", info->default_cc);
|
||||
}
|
||||
@ -968,6 +972,12 @@ static int bin_info(RCore *r, PJ *pj, int mode, ut64 laddr) {
|
||||
}
|
||||
pair_str (pj, "compiled", compiled);
|
||||
pair_str (pj, "compiler", info->compiler);
|
||||
if (R_STR_ISNOTEMPTY (info->flags)) {
|
||||
pair_str (pj, "flags", info->flags);
|
||||
}
|
||||
if (R_STR_ISNOTEMPTY (info->abi)) {
|
||||
pair_str (pj, "abi", info->abi);
|
||||
}
|
||||
pair_bool (pj, "crypto", info->has_crypto);
|
||||
pair_str (pj, "dbg_file", info->debug_file_name);
|
||||
pair_str (pj, "endian", info->big_endian ? "big" : "little");
|
||||
@ -1064,11 +1074,11 @@ static int bin_info(RCore *r, PJ *pj, int mode, ut64 laddr) {
|
||||
}
|
||||
}
|
||||
const char *dir_prefix = r_config_get (r->config, "dir.prefix");
|
||||
char spath[1024];
|
||||
snprintf (spath, sizeof (spath), "%s/"R2_SDB_FCNSIGN"/spec.sdb", dir_prefix);
|
||||
char *spath = r_str_newf ("%s/"R2_SDB_FCNSIGN"/spec.sdb", dir_prefix);
|
||||
if (r_file_exists (spath)) {
|
||||
sdb_concat_by_path (r->anal->sdb_fmts, spath);
|
||||
}
|
||||
free (spath);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -753,14 +753,16 @@ static bool cb_asmarch(void *user, void *data) {
|
||||
char *nac = strdup (new_asm_cpu);
|
||||
char *comma = strchr (nac, ',');
|
||||
if (comma) {
|
||||
if (!*asm_cpu || (*asm_cpu && !strstr(nac, asm_cpu))) {
|
||||
if (!*asm_cpu || (*asm_cpu && !strstr (nac, asm_cpu))) {
|
||||
*comma = 0;
|
||||
r_config_set (core->config, "asm.cpu", nac);
|
||||
}
|
||||
}
|
||||
free (nac);
|
||||
} else {
|
||||
r_config_set (core->config, "asm.cpu", "");
|
||||
// TODO: set to '' only if the new arch plugin doesnt handle
|
||||
// the given asm.cpu setup, but we can ignore for now
|
||||
// r_config_set (core->config, "asm.cpu", "");
|
||||
}
|
||||
bits = core->rasm->cur->bits;
|
||||
if (8 & bits) {
|
||||
@ -938,22 +940,6 @@ static bool cb_asmbits(void *user, void *data) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void update_asmfeatures_options(RCore *core, RConfigNode *node) {
|
||||
if (core && core->rasm && core->rasm->cur) {
|
||||
if (core->rasm->cur->features) {
|
||||
char *features = strdup (core->rasm->cur->features);
|
||||
int i, argc = r_str_split (features, ',');
|
||||
for (i = 0; i < argc; i++) {
|
||||
const char *feature = r_str_word_get0 (features, i);
|
||||
if (feature) {
|
||||
r_config_node_add_option (node, feature);
|
||||
}
|
||||
}
|
||||
free (features);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool cb_flag_realnames(void *user, void *data) {
|
||||
RCore *core = (RCore *) user;
|
||||
RConfigNode *node = (RConfigNode *) data;
|
||||
@ -961,21 +947,6 @@ static bool cb_flag_realnames(void *user, void *data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool cb_asmfeatures(void *user, void *data) {
|
||||
RCore *core = (RCore *) user;
|
||||
RConfigNode *node = (RConfigNode *) data;
|
||||
if (*node->value == '?') {
|
||||
update_asmfeatures_options (core, node);
|
||||
print_node_options (node);
|
||||
return 0;
|
||||
}
|
||||
R_FREE (core->rasm->config->features);
|
||||
if (node->value[0]) {
|
||||
core->rasm->config->features = strdup (node->value);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static bool cb_asmlineswidth(void *user, void *data) {
|
||||
RCore *core = (RCore *) user;
|
||||
RConfigNode *node = (RConfigNode *) data;
|
||||
@ -3134,6 +3105,14 @@ static bool cb_anal_bb_max_size(void *user, void *data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool cb_asmabi(void *user, void *data) {
|
||||
RCore *core = (RCore*) user;
|
||||
RConfigNode *node = (RConfigNode*) data;
|
||||
free (core->anal->config->abi);
|
||||
core->anal->config->abi = strdup (node->value);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool cb_anal_cxxabi(void *user, void *data) {
|
||||
RCore *core = (RCore*) user;
|
||||
RConfigNode *node = (RConfigNode*) data;
|
||||
@ -3437,6 +3416,7 @@ R_API int r_core_config_init(RCore *core) {
|
||||
n = NODECB ("anal.cxxabi", "itanium", &cb_anal_cxxabi);
|
||||
SETDESC (n, "select C++ RTTI ABI");
|
||||
SETOPTIONS (n, "itanium", "msvc", NULL);
|
||||
SETCB ("asm.abi", "", &cb_asmabi, "specify the abi taken from bin headeres or compiler details");
|
||||
|
||||
#if __linux__ && __GNU_LIBRARY__ && __GLIBC__ && __GLIBC_MINOR__
|
||||
n = NODECB ("dbg.malloc", "glibc", &cb_malloc);
|
||||
@ -3614,9 +3594,6 @@ R_API int r_core_config_init(RCore *core) {
|
||||
/* we need to have both asm.arch and asm.cpu defined before updating options */
|
||||
update_asmarch_options (core, asmarch);
|
||||
update_asmcpu_options (core, asmcpu);
|
||||
n = NODECB ("asm.features", "", &cb_asmfeatures);
|
||||
SETDESC (n, "specify supported features by the target CPU");
|
||||
update_asmfeatures_options (core, n);
|
||||
n = NODECB ("asm.parser", "x86.pseudo", &cb_asmparser);
|
||||
SETDESC (n, "set the asm parser to use");
|
||||
update_asmparser_options (core, n);
|
||||
|
@ -45,7 +45,7 @@ typedef struct r_arch_config_t {
|
||||
int seggrn;
|
||||
int invhex;
|
||||
int bitshift;
|
||||
char *features;
|
||||
char *abi;
|
||||
R_REF_TYPE;
|
||||
} RArchConfig;
|
||||
|
||||
|
@ -217,8 +217,8 @@ typedef struct r_bin_info_t {
|
||||
char *arch;
|
||||
char *cpu;
|
||||
char *machine;
|
||||
char *head_flag;
|
||||
char *features;
|
||||
char *flags; // elf.flags, which can ship info about cpu features or the abi used
|
||||
char *abi;
|
||||
char *os;
|
||||
char *subsystem;
|
||||
char *rpath;
|
||||
|
@ -376,8 +376,8 @@ iA
|
||||
iAj
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
0 0x00000000 266108 mips_32 mips1 o32
|
||||
{"bins":[{"arch":"mips","bits":32,"offset":0,"size":266108,"isa":"mips1","features":"o32","machine":"MIPS R3000"}]}
|
||||
0 0x00000000 266108 mips_32 cpu=mips1 abi=o32 machine=MIPS R3000
|
||||
{"bins":[{"arch":"mips","bits":32,"offset":0,"size":266108,"abi":"o32","isa":"mips1","flags":"0x1007","machine":"MIPS R3000"}]}
|
||||
EOF
|
||||
RUN
|
||||
|
||||
@ -388,8 +388,8 @@ iA
|
||||
iAj
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
0 0x00000000 1039368 mips_64 mips64r2 n64
|
||||
{"bins":[{"arch":"mips","bits":64,"offset":0,"size":1039368,"isa":"mips64r2","features":"n64","machine":"MIPS R3000"}]}
|
||||
0 0x00000000 1039368 mips_64 cpu=mips64r2 abi=n64 machine=MIPS R3000
|
||||
{"bins":[{"arch":"mips","bits":64,"offset":0,"size":1039368,"abi":"n64","isa":"mips64r2","flags":"0x80000007","machine":"MIPS R3000"}]}
|
||||
EOF
|
||||
RUN
|
||||
|
||||
@ -397,7 +397,7 @@ NAME=iA (file x86)
|
||||
FILE=bins/elf/analysis/x86-helloworld-gcc
|
||||
CMDS=iA
|
||||
EXPECT=<<EOF
|
||||
0 0x00000000 4899 x86_32
|
||||
0 0x00000000 4899 x86_32 machine=Intel 80386
|
||||
EOF
|
||||
RUN
|
||||
|
||||
@ -3212,7 +3212,7 @@ NAME=iA (file x86_64)
|
||||
FILE=bins/elf/analysis/hello-linux-x86_64
|
||||
CMDS=iA
|
||||
EXPECT=<<EOF
|
||||
0 0x00000000 6710 x86_64
|
||||
0 0x00000000 6710 x86_64 machine=AMD x86-64 architecture
|
||||
EOF
|
||||
RUN
|
||||
|
||||
|
@ -26,6 +26,7 @@ bits 32
|
||||
canary false
|
||||
class ELF32
|
||||
compiler GCC: (GNU) 9.3.0
|
||||
flags 0xf0100000
|
||||
crypto false
|
||||
endian little
|
||||
havecode true
|
||||
|
Loading…
Reference in New Issue
Block a user