mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-24 05:40:10 +00:00
Migrate arc ##arch
This commit is contained in:
parent
648f28f7e2
commit
be83c2cee9
2
dist/plugins-cfg/plugins.bin.cfg
vendored
2
dist/plugins-cfg/plugins.bin.cfg
vendored
@ -19,7 +19,7 @@ bin_xtr.xtr_sep64
|
||||
"
|
||||
SHARED="
|
||||
anal.8051
|
||||
anal.arc
|
||||
arch.arc
|
||||
anal.arm_cs
|
||||
anal.avr
|
||||
anal.bf
|
||||
|
2
dist/plugins-cfg/plugins.def.cfg
vendored
2
dist/plugins-cfg/plugins.def.cfg
vendored
@ -3,7 +3,7 @@ arch.6502
|
||||
anal.6502_cs
|
||||
anal.8051
|
||||
arch.alpha
|
||||
anal.arc
|
||||
arch.arc
|
||||
anal.arm_cs
|
||||
anal.arm_gnu
|
||||
arch.arm_v35
|
||||
|
2
dist/plugins-cfg/plugins.emscripten.cfg
vendored
2
dist/plugins-cfg/plugins.emscripten.cfg
vendored
@ -65,7 +65,7 @@ anal.ppc
|
||||
anal.sparc
|
||||
anal.8051
|
||||
anal.i8080
|
||||
anal.arc
|
||||
arch.arc
|
||||
anal.bf
|
||||
arch.z80
|
||||
arch.xap
|
||||
|
2
dist/plugins-cfg/plugins.mingw.cfg
vendored
2
dist/plugins-cfg/plugins.mingw.cfg
vendored
@ -1,7 +1,7 @@
|
||||
STATIC="anal.8051
|
||||
arch.alpha
|
||||
arch.xtensa
|
||||
anal.arc
|
||||
arch.arc
|
||||
anal.arm_cs
|
||||
anal.arm_gnu
|
||||
anal.avr
|
||||
|
2
dist/plugins-cfg/plugins.nocs.cfg
vendored
2
dist/plugins-cfg/plugins.nocs.cfg
vendored
@ -1,5 +1,5 @@
|
||||
STATIC="anal.8051
|
||||
anal.arc
|
||||
arch.arc
|
||||
anal.arm_gnu
|
||||
arch.arm_v35
|
||||
anal.avr
|
||||
|
2
dist/plugins-cfg/plugins.nogpl.cfg
vendored
2
dist/plugins-cfg/plugins.nogpl.cfg
vendored
@ -1,5 +1,5 @@
|
||||
STATIC="anal.8051
|
||||
anal.arc
|
||||
arch.arc
|
||||
anal.arm_cs
|
||||
anal.bf
|
||||
arch.cr16
|
||||
|
2
dist/plugins-cfg/plugins.static.cfg
vendored
2
dist/plugins-cfg/plugins.static.cfg
vendored
@ -1,7 +1,7 @@
|
||||
# same as default, but removing some plugins to avoid dupped symbols (use diff)
|
||||
# this file should be removed as soon as those 2 plugins get built properly
|
||||
STATIC="anal.8051
|
||||
anal.arc
|
||||
arch.arc
|
||||
anal.arm_cs
|
||||
anal.arm_gnu
|
||||
anal.bf
|
||||
|
2
dist/plugins-cfg/plugins.static.nogpl.cfg
vendored
2
dist/plugins-cfg/plugins.static.nogpl.cfg
vendored
@ -1,5 +1,5 @@
|
||||
STATIC="anal.8051
|
||||
anal.arc
|
||||
arch.arc
|
||||
anal.arm_cs
|
||||
anal.bf
|
||||
anal.chip8
|
||||
|
@ -42,7 +42,7 @@ r_anal_sources = [
|
||||
'p/anal_6502_cs.c',
|
||||
'p/anal_8051.c',
|
||||
|
||||
# 'p/anal_arc.c',
|
||||
# 'arch/p/arc/plugin.c',
|
||||
# 'arch/arc/gnu/arc-dis.c',
|
||||
# 'arch/arc/gnu/arc-opc.c',
|
||||
# 'arch/arc/gnu/arc-ext.c',
|
||||
|
@ -1,13 +0,0 @@
|
||||
OBJ_ARC=anal_arc.o
|
||||
OBJ_ARC+=../arch/arc/gnu/arc-dis.o
|
||||
OBJ_ARC+=../arch/arc/gnu/arc-ext.o
|
||||
OBJ_ARC+=../arch/arc/gnu/arc-opc.o
|
||||
OBJ_ARC+=../arch/arc/gnu/arcompact-dis.o
|
||||
|
||||
STATIC_OBJ+=${OBJ_ARC}
|
||||
TARGET_ARC=anal_arc.${EXT_SO}
|
||||
|
||||
ALL_TARGETS+=${TARGET_ARC}
|
||||
|
||||
${TARGET_ARC}: ${OBJ_ARC}
|
||||
${CC} $(call libname,anal_arc) ${LDFLAGS} ${CFLAGS} -o anal_arc.${EXT_SO} ${OBJ_ARC}
|
13
libr/arch/p/arc.mk
Normal file
13
libr/arch/p/arc.mk
Normal file
@ -0,0 +1,13 @@
|
||||
OBJ_ARC=p/arc/plugin.o
|
||||
OBJ_ARC+=p/arc/gnu/arc-dis.o
|
||||
OBJ_ARC+=p/arc/gnu/arc-ext.o
|
||||
OBJ_ARC+=p/arc/gnu/arc-opc.o
|
||||
OBJ_ARC+=p/arc/gnu/arcompact-dis.o
|
||||
|
||||
STATIC_OBJ+=${OBJ_ARC}
|
||||
TARGET_ARC=arc.${EXT_SO}
|
||||
|
||||
ALL_TARGETS+=${TARGET_ARC}
|
||||
|
||||
${TARGET_ARC}: ${OBJ_ARC}
|
||||
${CC} $(call libname,arc) ${LDFLAGS} ${CFLAGS} -o arc.${EXT_SO} ${OBJ_ARC}
|
@ -40,7 +40,7 @@ static void memory_error_func(int status, bfd_vma memaddr, struct disassemble_in
|
||||
DECLARE_GENERIC_PRINT_ADDRESS_FUNC_NOGLOBALS()
|
||||
DECLARE_GENERIC_FPRINTF_FUNC_NOGLOBALS()
|
||||
|
||||
static int disassemble(RAnal *a, RAnalOp *op, const ut8 *buf, int len) {
|
||||
static int disassemble(RArchSession *as, RAnalOp *op, const ut8 *buf, int len) {
|
||||
ut8 bytes[BUFSZ] = {0};
|
||||
struct disassemble_info disasm_obj = {0};
|
||||
if (len < 2) {
|
||||
@ -59,11 +59,11 @@ static int disassemble(RAnal *a, RAnalOp *op, const ut8 *buf, int len) {
|
||||
disasm_obj.symbol_at_address_func = &symbol_at_address;
|
||||
disasm_obj.memory_error_func = &memory_error_func;
|
||||
disasm_obj.print_address_func = &generic_print_address_func;
|
||||
disasm_obj.endian = !R_ARCH_CONFIG_IS_BIG_ENDIAN (a->config);
|
||||
disasm_obj.endian = !R_ARCH_CONFIG_IS_BIG_ENDIAN (as->config);
|
||||
disasm_obj.fprintf_func = &generic_fprintf_func;
|
||||
disasm_obj.stream = sb;
|
||||
disasm_obj.mach = 0;
|
||||
if (a->config->bits == 16) {
|
||||
if (as->config->bits == 16) {
|
||||
op->size = ARCompact_decodeInstr ((bfd_vma)op->addr, &disasm_obj);
|
||||
} else {
|
||||
ARCTangent_decodeInstr ((bfd_vma)op->addr, &disasm_obj);
|
||||
@ -517,7 +517,7 @@ static int arcompact_genops(RAnalOp *op, ut64 addr, ut32 words[2]) {
|
||||
return op->size;
|
||||
}
|
||||
|
||||
static int arcompact_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len) {
|
||||
static int arcompact_op(RArchSession *as, RAnalOp *op, ut64 addr, const ut8 *data, int len) {
|
||||
ut32 words[2]; /* storage for the de-swizled opcode data */
|
||||
arc_fields fields;
|
||||
|
||||
@ -543,7 +543,7 @@ static int arcompact_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, in
|
||||
op->refptr = 0;
|
||||
op->delay = 0;
|
||||
|
||||
if (R_ARCH_CONFIG_IS_BIG_ENDIAN (anal->config)) {
|
||||
if (R_ARCH_CONFIG_IS_BIG_ENDIAN (as->config)) {
|
||||
words[0] = r_read_be32 (&data[0]);
|
||||
words[1] = r_read_be32 (&data[4]);
|
||||
} else {
|
||||
@ -1086,17 +1086,24 @@ static int arcompact_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, in
|
||||
return op->size;
|
||||
}
|
||||
|
||||
static int arc_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len, RAnalOpMask mask) {
|
||||
static bool decode(RArchSession *as, RAnalOp *op, RAnalOpMask mask) {
|
||||
const int len = op->size;
|
||||
const ut8 *data = op->bytes;
|
||||
const ut64 addr = op->addr;
|
||||
if (len < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const ut8 *b = (ut8 *)data;
|
||||
|
||||
op->addr = addr;
|
||||
op->size = len;
|
||||
if (mask & R_ARCH_OP_MASK_DISASM) {
|
||||
disassemble (anal, op, data, len);
|
||||
disassemble (as, op, data, len);
|
||||
//op->size = disassemble (anal, op, data, len);
|
||||
}
|
||||
if (anal->config->bits == 16) {
|
||||
(void)arcompact_op (anal, op, addr, data, len);
|
||||
if (as->config->bits == 16) {
|
||||
(void)arcompact_op (as, op, addr, data, len);
|
||||
// eprintf ("%d %d\n", r, op->size);
|
||||
return op->size;
|
||||
}
|
||||
@ -1146,8 +1153,8 @@ static int arc_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len,
|
||||
return op->size;
|
||||
}
|
||||
|
||||
static int archinfo(RAnal *anal, int query) {
|
||||
if (anal->config->bits != 16) {
|
||||
static int archinfo(RArchSession *as, ut32 query) {
|
||||
if (as->config->bits != 16) {
|
||||
return -1;
|
||||
}
|
||||
switch (query) {
|
||||
@ -1163,9 +1170,9 @@ static int archinfo(RAnal *anal, int query) {
|
||||
}
|
||||
}
|
||||
|
||||
static bool set_reg_profile(RAnal *anal) {
|
||||
if (anal->config->bits != 16) {
|
||||
return false;
|
||||
static char* regs(RArchSession *as) {
|
||||
if (as->config->bits != 16) {
|
||||
return NULL;
|
||||
}
|
||||
const char *p16 =
|
||||
"=PC pcl\n"
|
||||
@ -1215,25 +1222,25 @@ static bool set_reg_profile(RAnal *anal) {
|
||||
/* TODO: */
|
||||
/* Should I add the Auxiliary Register Set? */
|
||||
/* it contains the flag bits, amongst other things */
|
||||
return r_reg_set_profile_string (anal->reg, p16);
|
||||
return strdup (p16);
|
||||
}
|
||||
|
||||
RAnalPlugin r_anal_plugin_arc = {
|
||||
RArchPlugin r_arch_plugin_arc = {
|
||||
.name = "arc",
|
||||
.arch = "arc",
|
||||
.author = "pancake",
|
||||
.license = "LGPL3",
|
||||
.bits = 16 | 32,
|
||||
.desc = "ARC code analysis plugin",
|
||||
.op = &arc_op,
|
||||
.archinfo = archinfo,
|
||||
.set_reg_profile = set_reg_profile,
|
||||
.decode = decode,
|
||||
.info = archinfo,
|
||||
.regs = regs
|
||||
};
|
||||
|
||||
#ifndef R2_PLUGIN_INCORE
|
||||
R_API RLibStruct radare_plugin = {
|
||||
.type = R_LIB_TYPE_ANAL,
|
||||
.data = &r_anal_plugin_arc,
|
||||
.type = R_LIB_TYPE_ARCH,
|
||||
.data = &r_arch_plugin_arc,
|
||||
.version = R2_VERSION,
|
||||
};
|
||||
#endif
|
@ -1564,7 +1564,6 @@ R_API bool r_anal_tid_select(RAnal *anal, int tid);
|
||||
extern RAnalPlugin r_anal_plugin_null;
|
||||
extern RAnalPlugin r_anal_plugin_6502_cs;
|
||||
extern RAnalPlugin r_anal_plugin_8051;
|
||||
extern RAnalPlugin r_anal_plugin_arc;
|
||||
extern RAnalPlugin r_anal_plugin_arm_cs;
|
||||
extern RAnalPlugin r_anal_plugin_arm_gnu;
|
||||
extern RAnalPlugin r_anal_plugin_avr;
|
||||
|
@ -317,6 +317,7 @@ extern RArchPlugin r_arch_plugin_pic;
|
||||
extern RArchPlugin r_arch_plugin_arm_v35;
|
||||
extern RArchPlugin r_arch_plugin_cris;
|
||||
extern RArchPlugin r_arch_plugin_cr16;
|
||||
extern RArchPlugin r_arch_plugin_arc;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -6,6 +6,7 @@ esil_plugins = [ 'dummy' ]
|
||||
asm_plugins = [ 'null' ]
|
||||
anal_plugins = [ 'null' ]
|
||||
arch_plugins = [ 'null',
|
||||
# 'arc',
|
||||
'sh',
|
||||
'x86_nz',
|
||||
'alpha',
|
||||
@ -152,7 +153,6 @@ if no_user_plugins
|
||||
anal_plugins += [
|
||||
'6502_cs',
|
||||
'8051',
|
||||
# 'arc',
|
||||
'arm_cs',
|
||||
'avr',
|
||||
'bf',
|
||||
|
@ -37,7 +37,7 @@ libr/anal/cycles.c
|
||||
libr/anal/esil.c
|
||||
libr/anal/data.c
|
||||
libr/anal/flirt.c
|
||||
libr/anal/p/anal_arc.c
|
||||
libr/arch/p/arc/plugin.c
|
||||
libr/anal/p/anal_bf.c
|
||||
|
||||
libr/config/config.c
|
||||
|
Loading…
Reference in New Issue
Block a user