Add RAsmPlugins->cpus and handle it in rasm2 -L <arch>
This commit is contained in:
parent
0121ad2da2
commit
9a099e9e9e
|
@ -1,4 +1,4 @@
|
|||
/* radare - LGPL - Copyright 2009-2013 - nibble, pancake */
|
||||
/* radare - LGPL - Copyright 2009-2014 - nibble, pancake */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -306,14 +306,14 @@ int main(int argc, char **argv) {
|
|||
bin = core.bin;
|
||||
l = r_lib_new ("radare_plugin");
|
||||
r_lib_add_handler (l, R_LIB_TYPE_BIN, "bin plugins",
|
||||
&__lib_bin_cb, &__lib_bin_dt, NULL);
|
||||
&__lib_bin_cb, &__lib_bin_dt, NULL);
|
||||
r_lib_add_handler (l, R_LIB_TYPE_BIN_XTR, "bin xtr plugins",
|
||||
&__lib_bin_xtr_cb, &__lib_bin_xtr_dt, NULL);
|
||||
&__lib_bin_xtr_cb, &__lib_bin_xtr_dt, NULL);
|
||||
|
||||
/* load plugins everywhere */
|
||||
r_lib_opendir (l, getenv ("LIBR_PLUGINS"));
|
||||
r_lib_opendir (l, homeplugindir);
|
||||
r_lib_opendir (l, LIBDIR"/radare2/");
|
||||
r_lib_opendir (l, LIBDIR"/radare2/"R2_VERSION);
|
||||
|
||||
#define is_active(x) (action&x)
|
||||
#define set_action(x) actions++; action |=x
|
||||
|
|
|
@ -13,16 +13,28 @@ static struct r_lib_t *l;
|
|||
static struct r_asm_t *a;
|
||||
static int coutput = R_FALSE;
|
||||
|
||||
static void r_asm_list(RAsm *a) {
|
||||
static void rasm2_list(RAsm *a, const char *arch) {
|
||||
int i;
|
||||
RAsmPlugin *h;
|
||||
RListIter *iter;
|
||||
r_list_foreach (a->plugins, iter, h) {
|
||||
const char *feat = "--";
|
||||
if (h->assemble && h->disassemble) feat = "ad";
|
||||
if (h->assemble && !h->disassemble) feat = "a_";
|
||||
if (!h->assemble && h->disassemble) feat = "_d";
|
||||
printf ("%s %-11s %s (%s)\n", feat, h->name,
|
||||
h->desc, h->license?h->license:"unknown");
|
||||
if (arch) {
|
||||
if (h->cpus && !strcmp (arch, h->name)) {
|
||||
char *c = strdup (h->cpus);
|
||||
int n = r_str_split (c, ',');
|
||||
for (i=0;i<n;i++)
|
||||
printf ("%s\n", r_str_word_get0(c, i));
|
||||
free (c);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
const char *feat = "--";
|
||||
if (h->assemble && h->disassemble) feat = "ad";
|
||||
if (h->assemble && !h->disassemble) feat = "a_";
|
||||
if (!h->assemble && h->disassemble) feat = "_d";
|
||||
printf ("%s %-11s %s (%s)\n", feat, h->name,
|
||||
h->desc, h->license?h->license:"unknown");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,7 +187,7 @@ int main(int argc, char *argv[]) {
|
|||
&__lib_asm_cb, &__lib_asm_dt, NULL);
|
||||
path = r_sys_getenv ("LIBR_PLUGINS");
|
||||
if (!path || !*path)
|
||||
path = R2_PREFIX"/lib/radare2/last";
|
||||
path = R2_PREFIX"/lib/radare2/"R2_VERSION;
|
||||
r_lib_opendir (l, path);
|
||||
|
||||
if (argc<2)
|
||||
|
@ -235,7 +247,7 @@ int main(int argc, char *argv[]) {
|
|||
len = r_num_math (NULL, optarg);
|
||||
break;
|
||||
case 'L':
|
||||
r_asm_list (a);
|
||||
rasm2_list (a, argv[optind]);
|
||||
exit (1);
|
||||
case 'e':
|
||||
r_asm_set_big_endian (a, !!!a->big_endian);
|
||||
|
|
|
@ -211,3 +211,4 @@ Can you stand on your head?
|
|||
I hope you segfault in hell
|
||||
May the segfault be with you
|
||||
I script in C, because fuck you
|
||||
EXPLICIT CONTENT
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* radare - LGPL - Copyright 2009-2013 - pancake, nibble */
|
||||
/* radare - LGPL - Copyright 2009-2014 - pancake, nibble */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <r_types.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* radare - LGPL - Copyright 2009-2013 - pancake */
|
||||
/* radare - LGPL - Copyright 2009-2014 - pancake */
|
||||
|
||||
#include "r_core.h"
|
||||
|
||||
|
@ -53,7 +53,7 @@ R_API int r_core_loadlibs(struct r_core_t *core) {
|
|||
r_lib_opendir (core->lib, getenv (R_LIB_ENV));
|
||||
// !!!! // r_lib_opendir (core->lib, ".");
|
||||
r_lib_opendir (core->lib, homeplugindir);
|
||||
r_lib_opendir (core->lib, R2_LIBDIR"/radare2/last");
|
||||
r_lib_opendir (core->lib, R2_LIBDIR"/radare2/"R2_VERSION);
|
||||
free (homeplugindir);
|
||||
return R_TRUE;
|
||||
}
|
||||
|
|
|
@ -105,6 +105,7 @@ typedef int (*RAsmModifyCallback)(RAsm *a, ut8 *buf, int field, ut64 val);
|
|||
typedef struct r_asm_plugin_t {
|
||||
char *name;
|
||||
char *arch;
|
||||
char *cpus;
|
||||
char *desc;
|
||||
char *license;
|
||||
int bits;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* radare - LGPL - Copyright 2008-2013 - pancake */
|
||||
/* radare - LGPL - Copyright 2008-2014 - pancake */
|
||||
|
||||
#include "r_types.h"
|
||||
#include "r_util.h"
|
||||
|
|
Loading…
Reference in New Issue