mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-17 04:39:36 +00:00
Move anal.rsp to the new home ##arch
This commit is contained in:
parent
9e95cc9444
commit
be9c20ce76
2
dist/plugins-cfg/plugins.def.cfg
vendored
2
dist/plugins-cfg/plugins.def.cfg
vendored
@ -46,7 +46,6 @@ anal.propeller
|
||||
anal.pyc
|
||||
anal.riscv
|
||||
anal.riscv_cs
|
||||
anal.rsp
|
||||
anal.s390_cs
|
||||
anal.s390_gnu
|
||||
anal.snes
|
||||
@ -67,6 +66,7 @@ arch.amd29k
|
||||
arch.i4004
|
||||
arch.jdh8
|
||||
arch.null
|
||||
arch.rsp
|
||||
arch.pickle
|
||||
arch.sh
|
||||
arch.v810
|
||||
|
1
dist/plugins-cfg/plugins.mingw.cfg
vendored
1
dist/plugins-cfg/plugins.mingw.cfg
vendored
@ -54,7 +54,6 @@ anal.snes
|
||||
anal.riscv
|
||||
anal.riscv_cs
|
||||
anal.pic
|
||||
anal.rsp
|
||||
anal.wasm
|
||||
anal.pyc
|
||||
anal.propeller
|
||||
|
2
dist/plugins-cfg/plugins.nocs.cfg
vendored
2
dist/plugins-cfg/plugins.nocs.cfg
vendored
@ -41,12 +41,12 @@ anal.6502
|
||||
anal.snes
|
||||
anal.riscv
|
||||
anal.pic
|
||||
anal.rsp
|
||||
anal.wasm
|
||||
anal.pyc
|
||||
anal.propeller
|
||||
arch.null
|
||||
arch.i4004
|
||||
arch.rsp
|
||||
arch.amd29k
|
||||
arch.pickle
|
||||
esil.dummy
|
||||
|
4
dist/plugins-cfg/plugins.termux.cfg
vendored
4
dist/plugins-cfg/plugins.termux.cfg
vendored
@ -22,7 +22,6 @@ anal.v850
|
||||
anal.x86_cs
|
||||
anal.xcore_cs
|
||||
anal.z80
|
||||
arch.v810
|
||||
anal.mcore
|
||||
anal.vax
|
||||
anal.6502
|
||||
@ -31,11 +30,12 @@ anal.snes
|
||||
anal.riscv
|
||||
anal.riscv_cs
|
||||
anal.pic
|
||||
anal.rsp
|
||||
anal.wasm
|
||||
anal.pyc
|
||||
arch.null
|
||||
arch.rsp
|
||||
arch.i4004
|
||||
arch.v810
|
||||
esil.dummy
|
||||
asm.arm
|
||||
asm.null
|
||||
|
@ -106,7 +106,6 @@ r_anal_sources = [
|
||||
'p/anal_pyc.c',
|
||||
'p/anal_riscv.c',
|
||||
'p/anal_riscv_cs.c',
|
||||
'p/anal_rsp.c',
|
||||
'p/anal_s390_cs.c',
|
||||
'p/anal_s390_gnu.c',
|
||||
'../asm/arch/s390/gnu/s390-dis.c',
|
||||
@ -167,7 +166,6 @@ r_anal_sources = [
|
||||
'../asm/arch/ppc/gnu/ppc-opc.c',
|
||||
# join_paths('arch','ppc','libvle','vle.c'),
|
||||
# join_paths('arch','ppc','libps','libps.c'),
|
||||
'arch/rsp/rsp_idec.c',
|
||||
'../asm/arch/tms320/tms320_dasm.c',
|
||||
'../asm/arch/tms320/c55x_plus/ins.c',
|
||||
'../asm/arch/tms320/c55x_plus/c55plus.c',
|
||||
|
@ -1,12 +0,0 @@
|
||||
OBJ_RSP=anal_rsp.o
|
||||
#RSP_ROOT=$(LIBR)/asm/arch/rsp
|
||||
CFLAGS+=-Iarch
|
||||
|
||||
STATIC_OBJ+=${OBJ_RSP}
|
||||
OBJ_RSP+=../arch/rsp/rsp_idec.o
|
||||
TARGET_RSP=anal_rsp.${EXT_SO}
|
||||
|
||||
ALL_TARGETS+=${TARGET_RSP}
|
||||
|
||||
${TARGET_RSP}: ${OBJ_RSP}
|
||||
${CC} $(call libname,anal_rsp) ${LDFLAGS} ${CFLAGS} -o ${TARGET_RSP} ${OBJ_RSP}
|
@ -11,6 +11,8 @@ r_arch_sources = [
|
||||
'p/arch_amd29k.c',
|
||||
'p/arch_jdh8.c',
|
||||
'p/arch_pickle.c',
|
||||
'p/arch_rsp.c',
|
||||
'p/rsp/rsp_idec.c',
|
||||
'p/arch_sh.c',
|
||||
'p/sh/gnu/sh-dis.c',
|
||||
'p/arch_v810.c',
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <r_types.h>
|
||||
#include <r_lib.h>
|
||||
#include <r_anal.h>
|
||||
#include <rsp/rsp_idec.h>
|
||||
#include "rsp/rsp_idec.h"
|
||||
|
||||
static RStrBuf *disassemble(RStrBuf *buf_asm, rsp_instruction *r_instr) {
|
||||
int i;
|
||||
@ -76,13 +76,18 @@ static RStrBuf *disassemble(RStrBuf *buf_asm, rsp_instruction *r_instr) {
|
||||
return buf_asm;
|
||||
}
|
||||
|
||||
static int rsp_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len, RAnalOpMask mask) {
|
||||
// static int rsp_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len, RAnalOpMask mask) {
|
||||
static bool rsp_op(RArchSession *s, RAnalOp *op, RArchDecodeMask mask) {
|
||||
const ut8* b = op->bytes;
|
||||
const int len = op->size;
|
||||
const ut64 addr = op->addr;
|
||||
if (len < 4) {
|
||||
op->type = R_ANAL_OP_TYPE_ILL;
|
||||
if (mask & R_ARCH_OP_MASK_DISASM) {
|
||||
op->mnemonic = strdup ("invalid");
|
||||
}
|
||||
return op->size = 0;
|
||||
op->size = 4;
|
||||
return false;
|
||||
}
|
||||
int i;
|
||||
typedef struct {
|
||||
@ -100,7 +105,7 @@ static int rsp_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len, RA
|
||||
op->addr = addr;
|
||||
r_strbuf_set (&op->esil, "TODO");
|
||||
|
||||
ut32 iw = r_read_ble32 (b, R_ARCH_CONFIG_IS_BIG_ENDIAN (anal->config));
|
||||
ut32 iw = r_read_ble32 (b, R_ARCH_CONFIG_IS_BIG_ENDIAN (s->config));
|
||||
r_instr = rsp_instruction_decode (addr, iw);
|
||||
|
||||
if (mask & R_ARCH_OP_MASK_DISASM) {
|
||||
@ -112,13 +117,17 @@ static int rsp_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len, RA
|
||||
|
||||
/* parse operands */
|
||||
for (i = 0; i < r_instr.noperands; i++) {
|
||||
parsed_operands[i].value = r_anal_value_new ();
|
||||
parsed_operands[i].value = r_arch_value_new ();
|
||||
parsed_operands[i].esil[0] = '\0';
|
||||
|
||||
switch (r_instr.operands[i].type) {
|
||||
case RSP_OPND_GP_REG:
|
||||
snprintf (parsed_operands[i].esil, sizeof (parsed_operands[i].esil), "%s", rsp_gp_reg_soft_names[r_instr.operands[i].u]);
|
||||
parsed_operands[i].value->reg = r_reg_get (anal->reg, rsp_gp_reg_soft_names[r_instr.operands[i].u], R_REG_TYPE_GPR);
|
||||
#if USE_REG_NAMES
|
||||
parsed_operands[i].value->reg = rsp_gp_reg_soft_names[r_instr.operands[i].u];
|
||||
#else
|
||||
// parsed_operands[i].value->reg = r_reg_get (anal->reg, rsp_gp_reg_soft_names[r_instr.operands[i].u], R_REG_TYPE_GPR);
|
||||
#endif
|
||||
break;
|
||||
case RSP_OPND_ZIMM:
|
||||
case RSP_OPND_SHIFT_AMOUNT:
|
||||
@ -132,7 +141,11 @@ static int rsp_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len, RA
|
||||
case RSP_OPND_BASE_OFFSET:
|
||||
snprintf (parsed_operands[i].esil, sizeof (parsed_operands[i].esil),
|
||||
"%"PFMT64d",%s,+", r_instr.operands[i].s, rsp_gp_reg_soft_names[r_instr.operands[i].u]);
|
||||
parsed_operands[i].value->reg = r_reg_get (anal->reg, rsp_gp_reg_soft_names[r_instr.operands[i].u], R_REG_TYPE_GPR);
|
||||
#if USE_REG_NAMES
|
||||
parsed_operands[i].value->reg = rsp_gp_reg_soft_names[r_instr.operands[i].u];
|
||||
#else
|
||||
// parsed_operands[i].value->reg = r_reg_get (anal->reg, rsp_gp_reg_soft_names[r_instr.operands[i].u], R_REG_TYPE_GPR);
|
||||
#endif
|
||||
parsed_operands[i].value->imm = r_instr.operands[i].s;
|
||||
break;
|
||||
case RSP_OPND_OFFSET:
|
||||
@ -147,7 +160,7 @@ static int rsp_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len, RA
|
||||
break;
|
||||
case RSP_OPND_C0_REG:
|
||||
snprintf (parsed_operands[i].esil, sizeof (parsed_operands[i].esil), "%s", rsp_c0_reg_names[r_instr.operands[i].u]);
|
||||
parsed_operands[i].value->reg = r_reg_get (anal->reg, rsp_c0_reg_names[r_instr.operands[i].u], R_REG_TYPE_GPR);
|
||||
// parsed_operands[i].value->reg = r_reg_get (anal->reg, rsp_c0_reg_names[r_instr.operands[i].u], R_REG_TYPE_GPR);
|
||||
break;
|
||||
case RSP_OPND_C2_CREG:
|
||||
case RSP_OPND_C2_ACCU:
|
||||
@ -265,14 +278,14 @@ static int rsp_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len, RA
|
||||
case RSP_OP_J:
|
||||
op->type = R_ANAL_OP_TYPE_JMP;
|
||||
tmpval = r_vector_push (&op->dsts, NULL);
|
||||
tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
// tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
r_vector_push (&op->srcs, parsed_operands[0].value);
|
||||
r_strbuf_setf (&op->esil, "%s,PC,=", parsed_operands[0].esil);
|
||||
break;
|
||||
case RSP_OP_JAL:
|
||||
op->type = R_ANAL_OP_TYPE_CALL;
|
||||
tmpval = r_vector_push (&op->dsts, NULL);
|
||||
tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
// tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
r_vector_push (&op->srcs, parsed_operands[0].value);
|
||||
r_strbuf_setf (&op->esil, "%s,PC,=,0x%08" PFMT64x ",RA,=", parsed_operands[0].esil, op->fail);
|
||||
break;
|
||||
@ -285,7 +298,7 @@ static int rsp_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len, RA
|
||||
op->eob = 1;
|
||||
op->fail = rsp_mem_addr (addr + 8, RSP_IMEM_OFFSET);
|
||||
tmpval = r_vector_push (&op->dsts, NULL);
|
||||
tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
// tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
r_vector_push (&op->srcs, parsed_operands[0].value);
|
||||
r_strbuf_setf (&op->esil, "%s,PC,=", parsed_operands[0].esil);
|
||||
break;
|
||||
@ -293,7 +306,7 @@ static int rsp_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len, RA
|
||||
op->type = R_ANAL_OP_TYPE_CJMP;
|
||||
op->cond = R_ANAL_COND_EQ;
|
||||
tmpval = r_vector_push (&op->dsts, NULL);
|
||||
tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
// tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
r_vector_push (&op->srcs, parsed_operands[0].value);
|
||||
r_vector_push (&op->srcs, parsed_operands[1].value);
|
||||
r_strbuf_setf (&op->esil, "%s,%s,==,$z,?{,%s,PC,=,}", parsed_operands[0].esil, parsed_operands[1].esil, parsed_operands[2].esil);
|
||||
@ -302,7 +315,7 @@ static int rsp_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len, RA
|
||||
op->type = R_ANAL_OP_TYPE_CJMP;
|
||||
op->cond = R_ANAL_COND_NE;
|
||||
tmpval = r_vector_push (&op->dsts, NULL);
|
||||
tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
// tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
r_vector_push (&op->srcs, parsed_operands[0].value);
|
||||
r_vector_push (&op->srcs, parsed_operands[1].value);
|
||||
r_strbuf_setf (&op->esil, "%s,%s,==,$z,!,?{,%s,PC,=,}", parsed_operands[0].esil, parsed_operands[1].esil, parsed_operands[2].esil);
|
||||
@ -311,7 +324,7 @@ static int rsp_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len, RA
|
||||
op->type = R_ANAL_OP_TYPE_CJMP;
|
||||
op->cond = R_ANAL_COND_LE;
|
||||
tmpval = r_vector_push (&op->dsts, NULL);
|
||||
tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
// tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
r_vector_push (&op->srcs, parsed_operands[0].value);
|
||||
r_vector_push (&op->srcs, parsed_operands[1].value);
|
||||
r_strbuf_setf (&op->esil, "%s,!,%s,0x80000000,&,!,!,|,?{,%s,PC,=,}", parsed_operands[0].esil, parsed_operands[0].esil, parsed_operands[1].esil);
|
||||
@ -321,7 +334,7 @@ static int rsp_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len, RA
|
||||
op->type = R_ANAL_OP_TYPE_CJMP;
|
||||
op->cond = R_ANAL_COND_GT;
|
||||
tmpval = r_vector_push (&op->dsts, NULL);
|
||||
tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
// tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
r_vector_push (&op->srcs, parsed_operands[0].value);
|
||||
r_vector_push (&op->srcs, parsed_operands[1].value);
|
||||
r_strbuf_setf (&op->esil, "%s,0x80000000,&,!,%s,!,!,&,?{,%s,PC,=,}", parsed_operands[0].esil, parsed_operands[0].esil, parsed_operands[1].esil);
|
||||
@ -331,7 +344,7 @@ static int rsp_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len, RA
|
||||
op->type = R_ANAL_OP_TYPE_CJMP;
|
||||
op->cond = R_ANAL_COND_LT;
|
||||
tmpval = r_vector_push (&op->dsts, NULL);
|
||||
tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
// tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
r_vector_push (&op->srcs, parsed_operands[0].value);
|
||||
r_vector_push (&op->srcs, parsed_operands[1].value);
|
||||
r_strbuf_setf (&op->esil, "%s,0x80000000,&,!,!,?{,%s,PC,=,}", parsed_operands[0].esil, parsed_operands[1].esil);
|
||||
@ -341,7 +354,7 @@ static int rsp_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len, RA
|
||||
op->type = R_ANAL_OP_TYPE_CJMP;
|
||||
op->cond = R_ANAL_COND_GE;
|
||||
tmpval = r_vector_push (&op->dsts, NULL);
|
||||
tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
// tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
r_vector_push (&op->srcs, parsed_operands[0].value);
|
||||
r_vector_push (&op->srcs, parsed_operands[1].value);
|
||||
r_strbuf_setf (&op->esil, "%s,0x80000000,&,!,?{,%s,PC,=,}", parsed_operands[0].esil, parsed_operands[1].esil);
|
||||
@ -351,7 +364,7 @@ static int rsp_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len, RA
|
||||
op->type = R_ANAL_OP_TYPE_CCALL;
|
||||
op->cond = R_ANAL_COND_LT;
|
||||
tmpval = r_vector_push (&op->dsts, NULL);
|
||||
tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
// tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
r_vector_push (&op->srcs, parsed_operands[0].value);
|
||||
r_vector_push (&op->srcs, parsed_operands[1].value);
|
||||
// TODO
|
||||
@ -360,7 +373,7 @@ static int rsp_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len, RA
|
||||
op->type = R_ANAL_OP_TYPE_CCALL;
|
||||
op->cond = R_ANAL_COND_GE;
|
||||
tmpval = r_vector_push (&op->dsts, NULL);
|
||||
tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
// tmpval->reg = r_reg_get (anal->reg, "PC", R_REG_TYPE_GPR);
|
||||
r_vector_push (&op->srcs, parsed_operands[0].value);
|
||||
r_vector_push (&op->srcs, parsed_operands[1].value);
|
||||
// TODO
|
||||
@ -654,12 +667,11 @@ static int rsp_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len, RA
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return op->size;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static char *get_reg_profile(RAnal *anal) {
|
||||
static char *get_reg_profile(RArchSession *s) {
|
||||
static const char *p =
|
||||
"=PC pc\n"
|
||||
"=SP sp\n"
|
||||
@ -763,26 +775,26 @@ static char *get_reg_profile(RAnal *anal) {
|
||||
return strdup (p);
|
||||
}
|
||||
|
||||
static int archinfo(RAnal *anal, int q) {
|
||||
static int archinfo(RArchSession *s, ut32 q) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
RAnalPlugin r_anal_plugin_rsp = {
|
||||
RArchPlugin r_arch_plugin_rsp = {
|
||||
.name = "rsp",
|
||||
.desc = "RSP code analysis plugin",
|
||||
.license = "LGPL3",
|
||||
.arch = "rsp",
|
||||
.esil = true,
|
||||
.bits = 32,
|
||||
.op = &rsp_op,
|
||||
.archinfo = &archinfo,
|
||||
.get_reg_profile = &get_reg_profile,
|
||||
.decode = &rsp_op,
|
||||
.info = &archinfo,
|
||||
.regs = &get_reg_profile,
|
||||
};
|
||||
|
||||
#ifndef R2_PLUGIN_INCORE
|
||||
R_API RLibStruct radare_plugin = {
|
||||
.type = R_LIB_TYPE_ANAL,
|
||||
.data = &r_anal_plugin_rsp,
|
||||
.type = R_LIB_TYPE_ARCH,
|
||||
.data = &r_arch_plugin_rsp,
|
||||
.version = R2_VERSION
|
||||
};
|
||||
#endif
|
12
libr/arch/p/rsp.mk
Normal file
12
libr/arch/p/rsp.mk
Normal file
@ -0,0 +1,12 @@
|
||||
OBJ_RSP=arch_rsp.o
|
||||
#RSP_ROOT=$(LIBR)/asm/arch/rsp
|
||||
CFLAGS+=-Iarch
|
||||
|
||||
STATIC_OBJ+=${OBJ_RSP}
|
||||
OBJ_RSP+=p/rsp/rsp_idec.o
|
||||
TARGET_RSP=arch_rsp.${EXT_SO}
|
||||
|
||||
ALL_TARGETS+=${TARGET_RSP}
|
||||
|
||||
${TARGET_RSP}: ${OBJ_RSP}
|
||||
${CC} $(call libname,arch_rsp) ${LDFLAGS} ${CFLAGS} -o ${TARGET_RSP} ${OBJ_RSP}
|
@ -1690,7 +1690,6 @@ extern RAnalPlugin r_anal_plugin_ppc_gnu;
|
||||
extern RAnalPlugin r_anal_plugin_propeller;
|
||||
extern RAnalPlugin r_anal_plugin_riscv;
|
||||
extern RAnalPlugin r_anal_plugin_riscv_cs;
|
||||
extern RAnalPlugin r_anal_plugin_rsp;
|
||||
extern RAnalPlugin r_anal_plugin_sh;
|
||||
extern RAnalPlugin r_anal_plugin_snes;
|
||||
extern RAnalPlugin r_anal_plugin_sparc_cs;
|
||||
|
@ -248,6 +248,7 @@ extern RArchPlugin r_arch_plugin_jdh8;
|
||||
extern RArchPlugin r_arch_plugin_pickle;
|
||||
extern RArchPlugin r_arch_plugin_sh;
|
||||
extern RArchPlugin r_arch_plugin_v810;
|
||||
extern RArchPlugin r_arch_plugin_rsp;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ arch_plugins = [ 'null',
|
||||
'sh',
|
||||
'jdh8',
|
||||
'i4004',
|
||||
'rsp',
|
||||
'amd29k',
|
||||
]
|
||||
bin_plugins = [ 'any' ]
|
||||
@ -172,7 +173,6 @@ anal_plugins += [
|
||||
'propeller',
|
||||
'riscv',
|
||||
'riscv_cs',
|
||||
'rsp',
|
||||
'snes',
|
||||
'sparc_cs',
|
||||
's390_cs',
|
||||
|
Loading…
x
Reference in New Issue
Block a user