mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-27 07:00:30 +00:00
Merge asm.msp430 into anal (#19639)
This commit is contained in:
parent
9db069f2b4
commit
5e92a476cb
1
dist/plugins-cfg/plugins.def.cfg
vendored
1
dist/plugins-cfg/plugins.def.cfg
vendored
@ -87,7 +87,6 @@ asm.malbolge
|
||||
asm.mcore
|
||||
asm.mips_cs
|
||||
asm.mips_gnu
|
||||
asm.msp430
|
||||
asm.nios2
|
||||
asm.or1k
|
||||
asm.ppc_as
|
||||
|
1
dist/plugins-cfg/plugins.mingw.cfg
vendored
1
dist/plugins-cfg/plugins.mingw.cfg
vendored
@ -81,7 +81,6 @@ asm.malbolge
|
||||
asm.mcore
|
||||
asm.mips_cs
|
||||
asm.mips_gnu
|
||||
asm.msp430
|
||||
asm.nios2
|
||||
asm.or1k
|
||||
asm.ppc_as
|
||||
|
1
dist/plugins-cfg/plugins.nocs.cfg
vendored
1
dist/plugins-cfg/plugins.nocs.cfg
vendored
@ -68,7 +68,6 @@ asm.xtensa
|
||||
asm.malbolge
|
||||
asm.mcore
|
||||
asm.mips_gnu
|
||||
asm.msp430
|
||||
asm.nios2
|
||||
asm.or1k
|
||||
asm.ppc_as
|
||||
|
1
dist/plugins-cfg/plugins.nogpl.cfg
vendored
1
dist/plugins-cfg/plugins.nogpl.cfg
vendored
@ -41,7 +41,6 @@ asm.java
|
||||
asm.m680x_cs
|
||||
asm.malbolge
|
||||
asm.mips_cs
|
||||
asm.msp430
|
||||
asm.ppc_cs
|
||||
asm.sparc_cs
|
||||
asm.s390_cs
|
||||
|
@ -111,6 +111,7 @@ r_anal_sources = [
|
||||
join_paths('arch','loongarch','gnu','loongarch-coder.c'),
|
||||
join_paths('arch','loongarch','gnu','loongarch-dis.c'),
|
||||
join_paths('arch','loongarch','gnu','loongarch-opc.c'),
|
||||
join_paths('arch','msp430','msp430_disas.c'),
|
||||
join_paths('..','asm','arch','amd29k','amd29k.c'),
|
||||
join_paths('..','asm','arch','v850','v850_disas.c'),
|
||||
join_paths('..','asm','arch','arm','winedbg','be_arm.c'),
|
||||
@ -120,7 +121,6 @@ r_anal_sources = [
|
||||
join_paths('..','asm','arch','cr16','cr16_disas.c'),
|
||||
join_paths('..','asm','arch','h8300','h8300_disas.c'),
|
||||
join_paths('..','asm','arch','mcore','mcore.c'),
|
||||
join_paths('..','asm','arch','msp430','msp430_disas.c'),
|
||||
join_paths('..','asm','arch','or1k','or1k_disas.c'),
|
||||
join_paths('..','asm','arch','pic','pic_midrange.c'),
|
||||
join_paths('..','asm','arch','ppc','libvle','vle.c'),
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* radare - LGPL - Copyright 2014-2022 - Fedor Sakharov, pancake */
|
||||
|
||||
#include <string.h>
|
||||
#include <r_types.h>
|
||||
#include <r_lib.h>
|
||||
@ -5,7 +7,7 @@
|
||||
#include <r_anal.h>
|
||||
#include <r_util.h>
|
||||
|
||||
#include <msp430_disas.h>
|
||||
#include "../arch/msp430/msp430_disas.h"
|
||||
|
||||
static int msp430_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len, RAnalOpMask mask) {
|
||||
int ret;
|
||||
@ -19,6 +21,24 @@ static int msp430_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int le
|
||||
op->family = R_ANAL_OP_FAMILY_CPU;
|
||||
|
||||
ret = op->size = msp430_decode_command (buf, len, &cmd);
|
||||
if (mask & R_ANAL_OP_MASK_DISASM) {
|
||||
if (ret < 1) {
|
||||
op->mnemonic = strdup ("invalid");
|
||||
} else if (ret > 0) {
|
||||
if (cmd.operands[0]) {
|
||||
op->mnemonic = r_str_newf ("%s %s",cmd.instr, cmd.operands);
|
||||
} else {
|
||||
op->mnemonic = strdup (cmd.instr);
|
||||
}
|
||||
}
|
||||
{ // if (a->syntax != R_ASM_SYNTAX_ATT)
|
||||
char *ba = op->mnemonic;
|
||||
r_str_replace_ch (ba, '#', 0, 1);
|
||||
// r_str_replace_ch (ba, "$", "$$", 1);
|
||||
r_str_replace_ch (ba, '&', 0, 1);
|
||||
r_str_replace_ch (ba, '%', 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
@ -79,8 +99,8 @@ static int msp430_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int le
|
||||
break;
|
||||
default:
|
||||
op->type = R_ANAL_OP_TYPE_UNK;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,11 @@
|
||||
OBJ_msp430=anal_msp430.o
|
||||
CFLAGS+=-I../asm/arch/msp430/
|
||||
OBJ_MSP430=anal_msp430.o
|
||||
|
||||
STATIC_OBJ+=${OBJ_msp430}
|
||||
OBJ_msp430+=../../asm/arch/msp430/msp430_disas.o
|
||||
TARGET_msp430=anal_msp430.${EXT_SO}
|
||||
STATIC_OBJ+=${OBJ_MSP430}
|
||||
OBJ_MSP430+=../arch/msp430/msp430_disas.o
|
||||
TARGET_MSP430=anal_msp430.${EXT_SO}
|
||||
|
||||
ALL_TARGETS+=${TARGET_msp430}
|
||||
ALL_TARGETS+=${TARGET_MSP430}
|
||||
|
||||
${TARGET_msp430}: ${OBJ_msp430} ${SHARED_OBJ}
|
||||
${TARGET_MSP430}: ${OBJ_MSP430} ${SHARED_OBJ}
|
||||
${CC} $(call libname,anal_msp430) ${CFLAGS} \
|
||||
-o ${TARGET_msp430} ${OBJ_msp430}
|
||||
-o ${TARGET_MSP430} ${OBJ_MSP430}
|
||||
|
@ -36,7 +36,6 @@ r_asm_sources = [
|
||||
join_paths('p','asm_mcs96.c'),
|
||||
join_paths('p','asm_mips_cs.c'),
|
||||
join_paths('p','asm_mips_gnu.c'),
|
||||
join_paths('p','asm_msp430.c'),
|
||||
join_paths('p','asm_nios2.c'),
|
||||
join_paths('p','asm_or1k.c'),
|
||||
join_paths('p','asm_pic.c'),
|
||||
@ -119,7 +118,6 @@ r_asm_sources = [
|
||||
join_paths('arch','mips','gnu','mips16-opc.c'),
|
||||
join_paths('arch','mips','gnu','micromips-opc.c'),
|
||||
join_paths('arch','mips','mipsasm.c'),
|
||||
join_paths('arch','msp430','msp430_disas.c'),
|
||||
join_paths('arch','nios','gnu','nios2-dis.c'),
|
||||
join_paths('arch','nios','gnu','nios2-opc.c'),
|
||||
join_paths('arch','or1k','or1k_disas.c'),
|
||||
@ -179,7 +177,6 @@ r_asm_inc = [
|
||||
join_paths('arch','include'),
|
||||
join_paths('arch'),
|
||||
join_paths('arch','h8300'),
|
||||
join_paths('arch','msp430'),
|
||||
join_paths('arch','rsp'),
|
||||
join_paths('arch','mcore'),
|
||||
join_paths('arch','v850'),
|
||||
|
@ -21,7 +21,7 @@ ARCHS=mips_gnu.mk x86_cs.mk sparc_cs.mk sparc_gnu.mk java.mk bf.mk arm_gnu.mk da
|
||||
ARCHS+=x86_as.mk x86_nz.mk cris_gnu.mk vax.mk arc.mk
|
||||
ARCHS+=ppc_gnu.mk ppc_as.mk ppc_cs.mk xap.mk x86_nasm.mk avr.mk
|
||||
ARCHS+=sh.mk arm_winedbg.mk tms320.mk gb.mk snes.mk ebc.mk malbolge.mk ws.mk
|
||||
ARCHS+=6502.mk h8300.mk cr16.mk v850.mk propeller.mk msp430.mk i4004.mk
|
||||
ARCHS+=6502.mk h8300.mk cr16.mk v850.mk propeller.mk i4004.mk
|
||||
ARCHS+=lh5801.mk v810.mk mcs96.mk lm32.mk jdh8.mk
|
||||
ARCHS+=riscv.mk rsp.mk mcore.mk s390_cs.mk s390_gnu.mk
|
||||
# ARCHS+=loongarch_gnu.mk
|
||||
|
@ -1,49 +0,0 @@
|
||||
/* radare - LGPL - Copyright 2014-2022 - fedor.sakharov */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <r_types.h>
|
||||
#include <r_lib.h>
|
||||
#include <r_asm.h>
|
||||
|
||||
#include <msp430_disas.h>
|
||||
|
||||
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
|
||||
struct msp430_cmd cmd;
|
||||
int ret = msp430_decode_command (buf, len, &cmd);
|
||||
if (ret > 0) {
|
||||
r_strf_buffer (128);
|
||||
if (cmd.operands[0]) {
|
||||
r_strbuf_set (&op->buf_asm, r_strf ("%s %s", cmd.instr, cmd.operands));
|
||||
} else {
|
||||
r_strbuf_set (&op->buf_asm, r_strf ("%s", cmd.instr));
|
||||
}
|
||||
}
|
||||
if (a->syntax != R_ASM_SYNTAX_ATT) {
|
||||
char *ba = (char *)r_strbuf_get (&op->buf_asm);
|
||||
r_str_replace_ch (ba, '#', 0, 1);
|
||||
// r_str_replace_ch (ba, "$", "$$", 1);
|
||||
r_str_replace_ch (ba, '&', 0, 1);
|
||||
r_str_replace_ch (ba, '%', 0, 1);
|
||||
}
|
||||
|
||||
return op->size = ret;
|
||||
}
|
||||
|
||||
RAsmPlugin r_asm_plugin_msp430 = {
|
||||
.name = "msp430",
|
||||
.license = "LGPL3",
|
||||
.desc = "msp430 disassembly plugin",
|
||||
.arch = "msp430",
|
||||
.bits = 16,
|
||||
.endian = R_SYS_ENDIAN_LITTLE,
|
||||
.disassemble = &disassemble,
|
||||
};
|
||||
|
||||
#ifndef R2_PLUGIN_INCORE
|
||||
R_API RLibStruct radare_plugin = {
|
||||
.type = R_LIB_TYPE_ASM,
|
||||
.data = &r_asm_plugin_msp430,
|
||||
.version = R2_VERSION
|
||||
};
|
||||
#endif
|
@ -1,13 +0,0 @@
|
||||
OBJ_MSP430=asm_msp430.o
|
||||
OBJ_MSP430+=$(LIBR)/asm/arch/msp430/msp430_disas.o
|
||||
CFLAGS+=-I$(LIBR)/asm/arch/msp430/
|
||||
|
||||
STATIC_OBJ+=${OBJ_MSP430}
|
||||
TARGET_MSP430=asm_msp430.${EXT_SO}
|
||||
|
||||
ifeq ($(WITHPIC),1)
|
||||
ALL_TARGETS+=${TARGET_MSP430}
|
||||
|
||||
${TARGET_MSP430}: ${OBJ_MSP430}
|
||||
${CC} ${LDFLAGS} ${CFLAGS} -o ${TARGET_MSP430} ${OBJ_MSP430}
|
||||
endif
|
@ -232,7 +232,6 @@ extern RAsmPlugin r_asm_plugin_mcore;
|
||||
extern RAsmPlugin r_asm_plugin_mcs96;
|
||||
extern RAsmPlugin r_asm_plugin_mips_cs;
|
||||
extern RAsmPlugin r_asm_plugin_mips_gnu;
|
||||
extern RAsmPlugin r_asm_plugin_msp430;
|
||||
extern RAsmPlugin r_asm_plugin_nios2;
|
||||
extern RAsmPlugin r_asm_plugin_or1k;
|
||||
extern RAsmPlugin r_asm_plugin_pic;
|
||||
|
@ -200,7 +200,6 @@ asm_plugins += [
|
||||
'mcore',
|
||||
'mcs96',
|
||||
'mips_cs',
|
||||
'msp430',
|
||||
'nios2',
|
||||
'or1k',
|
||||
'pic',
|
||||
|
Loading…
Reference in New Issue
Block a user