Move anal.propeller ##arch

This commit is contained in:
pancake 2023-01-16 09:43:17 +01:00 committed by GitHub
parent 4ac061a046
commit 7e4fd94201
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 33 additions and 28 deletions

View File

@ -42,7 +42,7 @@ anal.pdp11_gnu
anal.pic
anal.ppc_cs
anal.ppc_gnu
anal.propeller
arch.propeller
anal.pyc
anal.riscv_cs
anal.s390_cs

View File

@ -56,7 +56,7 @@ anal.riscv_cs
anal.pic
anal.wasm
anal.pyc
anal.propeller
arch.propeller
arch.null
arch.i4004
arch.amd29k

View File

@ -43,7 +43,7 @@ arch.riscv
anal.pic
anal.wasm
anal.pyc
anal.propeller
arch.propeller
esil.dummy
asm.null
anal.m68k_gnu

View File

@ -38,7 +38,7 @@ anal.vax
arch.6502
arch.snes
arch.riscv
anal.propeller
arch.propeller
arch.null
arch.i4004
esil.dummy

View File

@ -24,7 +24,7 @@ anal.lh5801
arch.6502
arch.snes
arch.riscv
anal.propeller
arch.propeller
arch.null
arch.i4004
esil.dummy

View File

@ -100,7 +100,6 @@ r_anal_sources = [
'p/anal_pic.c',
'p/anal_ppc_cs.c',
'p/anal_ppc_gnu.c',
'p/anal_propeller.c',
'p/anal_pyc.c',
'p/anal_riscv_cs.c',
'p/anal_s390_cs.c',
@ -132,7 +131,6 @@ r_anal_sources = [
'arch/loongarch/gnu/loongarch-dis.c',
'arch/loongarch/gnu/loongarch-opc.c',
'arch/msp430/msp430_disas.c',
'arch/propeller/propeller_disas.c',
'../asm/arch/amd29k/amd29k.c',
'../arch/p/arm/winedbg/be_arm.c',
'../arch/p/arm/gnu/floatformat.c',

View File

@ -7,6 +7,8 @@ r_arch_sources = [
'arch_cond.c',
'arch_value.c',
'p/null/plugin.c',
'p/propeller/plugin.c',
'p/propeller/propeller_disas.c',
'p/arm/plugin.c',
'p/arm/armass.c',
'p/arm/armass64.c',

View File

@ -1,12 +1,12 @@
OBJ_propeller=anal_propeller.o
OBJ_propeller=p/propeller/plugin.o
CFLAGS+=-Iarch
STATIC_OBJ+=${OBJ_propeller}
OBJ_propeller+=../arch/propeller/propeller_disas.o
TARGET_propeller=anal_propeller.${EXT_SO}
OBJ_propeller+=p/propeller/propeller_disas.o
TARGET_propeller=arch_propeller.${EXT_SO}
ALL_TARGETS+=${TARGET_propeller}
${TARGET_propeller}: ${OBJ_propeller} ${SHARED_OBJ}
${CC} $(call libname,anal_propeller) ${CFLAGS} \
${CC} $(call libname,arch_propeller) ${CFLAGS} \
-o ${TARGET_propeller} ${OBJ_propeller}

View File

@ -1,5 +1,5 @@
/* radare - LGPL - Copyright 2012-2013 - pancake
2014 - Fedor Sakharov <fedor.sakharov@gmail.com> */
/* radare - LGPL - Copyright 2012-2023 - pancake */
/* 2014 - Fedor Sakharov <fedor.sakharov@gmail.com> */
#include <string.h>
#include <r_types.h>
@ -7,15 +7,18 @@
#include <r_anal.h>
#include <r_util.h>
#include "propeller/propeller_disas.h"
#include "./propeller_disas.h"
static int propeller_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len, RAnalOpMask mask) {
// static int propeller_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len, RAnalOpMask mask) {
static bool propeller_op(RArchSession *as, RAnalOp *op, RArchDecodeMask mask) {
const ut8 *buf = op->bytes;
const int len = op->size;
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;
return false;
}
int ret;
struct propeller_cmd cmd;
@ -29,11 +32,10 @@ static int propeller_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int
if (mask & R_ARCH_OP_MASK_DISASM) {
op->mnemonic = strdup ("invalid");
}
return op->size = ret;
op->size = ret;
return true;
}
op->addr = addr;
if (mask & R_ARCH_OP_MASK_DISASM) {
if (cmd.prefix[0] && cmd.operands[0]) {
op->mnemonic = r_str_newf ("%s %s %s", cmd.prefix, cmd.instr, cmd.operands);
@ -45,6 +47,9 @@ static int propeller_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int
}
switch (cmd.opcode) {
case PROP_NOP:
op->type = R_ANAL_OP_TYPE_NOP;
break;
case PROP_TEST:
case PROP_TESTN:
case PROP_TJNZ:
@ -82,7 +87,7 @@ static int propeller_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int
case PROP_MIN:
case PROP_MAX:
case PROP_MAXS:
case PROP_RDBYTE:
// case PROP_RDBYTE:
case PROP_RDLONG:
case PROP_RDWORD:
case PROP_MOV:
@ -105,25 +110,25 @@ static int propeller_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int
if (cmd.immed == 0) {
op->type = R_ANAL_OP_TYPE_CJMP;
op->jump = 0x20 + cmd.src;
op->fail = addr + 2;
op->fail = op->addr + 2;
} else {
op->type = R_ANAL_OP_TYPE_UJMP;
op->fail = addr + 2;
op->fail = op->addr + 2;
}
break;
default:
op->type = R_ANAL_OP_TYPE_UNK;
break;
}
return ret;
op->size = ret;
return true;
}
RAnalPlugin r_anal_plugin_propeller = {
RArchPlugin r_arch_plugin_propeller = {
.name = "propeller",
.desc = "Parallax propeller code analysis plugin",
.license = "LGPL3",
.arch = "propeller",
.bits = 32,
.op = propeller_op,
.decode = propeller_op,
};

View File

@ -1691,7 +1691,6 @@ extern RAnalPlugin r_anal_plugin_pic;
extern RAnalPlugin r_anal_plugin_pdp11_gnu;
extern RAnalPlugin r_anal_plugin_ppc_cs;
extern RAnalPlugin r_anal_plugin_ppc_gnu;
extern RAnalPlugin r_anal_plugin_propeller;
extern RAnalPlugin r_anal_plugin_riscv_cs;
extern RAnalPlugin r_anal_plugin_sh;
extern RAnalPlugin r_anal_plugin_sparc_cs;

View File

@ -265,6 +265,7 @@ extern RArchPlugin r_arch_plugin_snes;
extern RArchPlugin r_arch_plugin_6502;
extern RArchPlugin r_arch_plugin_xap;
extern RArchPlugin r_arch_plugin_v850;
extern RArchPlugin r_arch_plugin_propeller;
extern RArchPlugin r_arch_plugin_nios2;
#ifdef __cplusplus

View File

@ -19,6 +19,7 @@ arch_plugins = [ 'null',
'riscv',
'i4004',
'rsp',
'propeller',
'amd29k',
]
bin_plugins = [ 'any' ]
@ -163,7 +164,6 @@ anal_plugins += [
'or1k',
'pic',
'ppc_cs',
'propeller',
'riscv_cs',
'sparc_cs',
's390_cs',