mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-25 14:19:51 +00:00
Show Anal and Esil bits in rasm2 -L and 'e asm.arch=?'
This commit is contained in:
parent
ba2a1e0edd
commit
0acdbd60fa
@ -5,17 +5,32 @@
|
||||
#include <getopt.c> /* getopt.h is not portable :D */
|
||||
#include <r_types.h>
|
||||
#include <r_asm.h>
|
||||
#include <r_anal.h>
|
||||
#include <r_util.h>
|
||||
#include <r_lib.h>
|
||||
#include "../blob/version.c"
|
||||
|
||||
static struct r_lib_t *l = NULL;
|
||||
static struct r_asm_t *a = NULL;
|
||||
static RLib *l = NULL;
|
||||
static RAsm *a = NULL;
|
||||
static RAnal *anal = NULL;
|
||||
static int coutput = R_FALSE;
|
||||
|
||||
static const char *has_esil(RAnal *a, const char *name) {
|
||||
RListIter *iter;
|
||||
RAnalPlugin *h;
|
||||
r_list_foreach (a->plugins, iter, h) {
|
||||
if (!strcmp (name, h->name)) {
|
||||
if (h->esil)
|
||||
return "Ae";
|
||||
return "A_";
|
||||
}
|
||||
}
|
||||
return "__";
|
||||
}
|
||||
static void rasm2_list(RAsm *a, const char *arch) {
|
||||
int i;
|
||||
char bits[32];
|
||||
const char *feat2, *feat;
|
||||
RAsmPlugin *h;
|
||||
RListIter *iter;
|
||||
r_list_foreach (a->plugins, iter, h) {
|
||||
@ -34,12 +49,13 @@ static void rasm2_list(RAsm *a, const char *arch) {
|
||||
if (h->bits&16) strcat (bits, "16 ");
|
||||
if (h->bits&32) strcat (bits, "32 ");
|
||||
if (h->bits&64) strcat (bits, "64 ");
|
||||
const char *feat = "--";
|
||||
feat = "__";
|
||||
if (h->assemble && h->disassemble) feat = "ad";
|
||||
if (h->assemble && !h->disassemble) feat = "a_";
|
||||
if (!h->assemble && h->disassemble) feat = "_d";
|
||||
printf ("%s %-9s %-11s %-7s %s\n", feat, bits,
|
||||
h->name,
|
||||
feat2 = has_esil (anal, h->name);
|
||||
printf ("%s%s %-9s %-11s %-7s %s\n",
|
||||
feat, feat2, bits, h->name,
|
||||
h->license?h->license:"unknown", h->desc);
|
||||
}
|
||||
}
|
||||
@ -192,6 +208,7 @@ int main(int argc, char *argv[]) {
|
||||
return rasm_show_help (0);
|
||||
|
||||
a = r_asm_new ();
|
||||
anal = r_anal_new ();
|
||||
l = r_lib_new ("radare_plugin");
|
||||
r_lib_add_handler (l, R_LIB_TYPE_ASM, "(dis)assembly plugins",
|
||||
&__lib_asm_cb, &__lib_asm_dt, NULL);
|
||||
|
@ -7,9 +7,25 @@
|
||||
#define SETPREF(x,y,z) r_config_node_desc(r_config_set(cfg,x,y), z);
|
||||
#define SETCB(w,x,y,z) r_config_node_desc(r_config_set_cb(cfg,w,x,y), z);
|
||||
|
||||
static const char *has_esil(RCore *core, const char *name) {
|
||||
RListIter *iter;
|
||||
RAnalPlugin *h;
|
||||
RAnal *a = core->anal;
|
||||
r_list_foreach (a->plugins, iter, h) {
|
||||
if (!strcmp (name, h->name)) {
|
||||
if (h->esil)
|
||||
return "Ae";
|
||||
return "A_";
|
||||
}
|
||||
}
|
||||
return "__";
|
||||
}
|
||||
|
||||
// copypasta from binr/rasm2/rasm2.c
|
||||
static void rasm2_list(RAsm *a, const char *arch) {
|
||||
static void rasm2_list(RCore *core, const char *arch) {
|
||||
int i;
|
||||
const char *feat2, *feat;
|
||||
RAsm *a = core->assembler;
|
||||
char bits[32];
|
||||
RAsmPlugin *h;
|
||||
RListIter *iter;
|
||||
@ -25,18 +41,19 @@ static void rasm2_list(RAsm *a, const char *arch) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
const char *feat = "--";
|
||||
bits[0] = 0;
|
||||
if (h->bits&8) strcat (bits, "_8");
|
||||
if (h->bits&16) strcat (bits, "_16");
|
||||
if (h->bits&32) strcat (bits, "_32");
|
||||
if (h->bits&64) strcat (bits, "_64");
|
||||
if (!*bits) strcat (bits, "_0");
|
||||
feat = "__";
|
||||
if (h->assemble && h->disassemble) feat = "ad";
|
||||
if (h->assemble && !h->disassemble) feat = "a_";
|
||||
if (!h->assemble && h->disassemble) feat = "_d";
|
||||
r_cons_printf ("%s %-9s %-11s %-7s %s\n", feat, bits,
|
||||
h->name,
|
||||
feat2 = has_esil (core, h->name);
|
||||
r_cons_printf ("%s%s %-9s %-11s %-7s %s\n",
|
||||
feat, feat2, bits, h->name,
|
||||
h->license?h->license:"unknown", h->desc);
|
||||
}
|
||||
}
|
||||
@ -87,7 +104,7 @@ static int cb_asmarch(void *user, void *data) {
|
||||
const char *asmos = r_config_get (core->config, "asm.os");
|
||||
|
||||
if (*node->value=='?') {
|
||||
rasm2_list (core->assembler, NULL);
|
||||
rasm2_list (core, NULL);
|
||||
return 0;
|
||||
}
|
||||
r_egg_setup (core->egg, node->value, core->anal->bits, 0, R_SYS_OS);
|
||||
@ -175,8 +192,7 @@ static int cb_asmcpu(void *user, void *data) {
|
||||
RCore *core = (RCore *) user;
|
||||
RConfigNode *node = (RConfigNode *) data;
|
||||
if (*node->value=='?') {
|
||||
rasm2_list (core->assembler,
|
||||
r_config_get (core->config, "asm.arch"));
|
||||
rasm2_list (core, r_config_get (core->config, "asm.arch"));
|
||||
return 0;
|
||||
}
|
||||
r_asm_set_cpu (core->assembler, node->value);
|
||||
|
Loading…
Reference in New Issue
Block a user