forked from radareorg/radare2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade capstone-next to get tms320c64x support and more fixes for SFC
- Loading branch information
Showing
11 changed files
with
101 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* radare2 - LGPL - Copyright 2017 - pancake */ | ||
|
||
#include <r_asm.h> | ||
#include <r_lib.h> | ||
#include <capstone/capstone.h> | ||
static csh cd = 0; | ||
#include "cs_mnemonics.c" | ||
|
||
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) { | ||
cs_insn* insn; | ||
int n = -1, ret = -1; | ||
int mode = CS_MODE_BIG_ENDIAN; | ||
if (op) { | ||
memset (op, 0, sizeof (RAsmOp)); | ||
op->size = 4; | ||
} | ||
if (cd != 0) { | ||
cs_close (&cd); | ||
} | ||
ret = cs_open (CS_ARCH_TMS320C64X, mode, &cd); | ||
if (ret) { | ||
goto fin; | ||
} | ||
cs_option (cd, CS_OPT_DETAIL, CS_OPT_OFF); | ||
if (!op) { | ||
return 0; | ||
} | ||
if (a->big_endian) { | ||
n = cs_disasm (cd, buf, len, a->pc, 1, &insn); | ||
} | ||
if (n < 1) { | ||
strcpy (op->buf_asm, "invalid"); | ||
op->size = 4; | ||
ret = -1; | ||
goto beach; | ||
} else { | ||
ret = 4; | ||
} | ||
if (insn->size < 1) { | ||
goto beach; | ||
} | ||
op->size = insn->size; | ||
snprintf (op->buf_asm, R_ASM_BUFSIZE, "%s%s%s", | ||
insn->mnemonic, insn->op_str[0]? " ": "", | ||
insn->op_str); | ||
r_str_replace_char (op->buf_asm, '%', 0); | ||
// TODO: remove the '$'<registername> in the string | ||
cs_free (insn, n); | ||
beach: | ||
// cs_close (&cd); | ||
fin: | ||
return ret; | ||
} | ||
|
||
RAsmPlugin r_asm_plugin_tms320c64x = { | ||
.name = "tms320c64x", | ||
.desc = "Capstone TMS320c64x disassembler", | ||
.license = "BSD", | ||
.arch = "tms320c64x", | ||
.bits = 32, | ||
.endian = R_SYS_ENDIAN_BIG | R_SYS_ENDIAN_LITTLE, | ||
.disassemble = &disassemble, | ||
.mnemonics = mnemonics | ||
}; | ||
|
||
#ifndef CORELIB | ||
RLibStruct radare_plugin = { | ||
.type = R_LIB_TYPE_ASM, | ||
.data = &r_asm_plugin_tms320c64x, | ||
.version = R2_VERSION | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
OBJ_TMS320C64X_CS=asm_tms320c64x.o | ||
|
||
include ${CURDIR}capstone.mk | ||
|
||
STATIC_OBJ+=${OBJ_TMS320C64X_CS} | ||
SHARED_OBJ+=${SHARED_TMS320C64X_CS} | ||
TARGET_TMS320C64X_CS=asm_tms320c64x.${EXT_SO} | ||
|
||
ifeq ($(WITHPIC),1) | ||
ALL_TARGETS+=${TARGET_TMS320C64X_CS} | ||
|
||
${TARGET_TMS320C64X_CS}: ${OBJ_TMS320C64X_CS} | ||
${CC} -o ${TARGET_TMS320C64X_CS} ${OBJ_TMS320C64X_CS} \ | ||
$(call libname,asm_tms320c64x) ${LDFLAGS} ${CFLAGS} $(CS_LDFLAGS)\ | ||
${SHARED2_TMS320C64X_CS} | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,7 @@ asm.sparc_gnu | |
asm.spc700 | ||
asm.sysz | ||
asm.tms320 | ||
asm.tms320c64x | ||
asm.v850 | ||
asm.ws | ||
asm.xap | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters