mirror of
https://github.com/capstone-engine/capstone.git
synced 2024-11-23 05:29:53 +00:00
add Ethereum VM architecture
This commit is contained in:
parent
3c8e828b14
commit
9c7a094b58
1
.gitignore
vendored
1
.gitignore
vendored
@ -67,6 +67,7 @@ tests/test_customized_mnem
|
||||
tests/test_m68k
|
||||
tests/test_tms320c64x
|
||||
tests/test_m680x
|
||||
tests/test_evm
|
||||
|
||||
# vim tmp file
|
||||
*.swp
|
||||
|
@ -27,8 +27,8 @@ option(CAPSTONE_BUILD_DIET "Build diet library" OFF)
|
||||
option(CAPSTONE_BUILD_TESTS "Build tests" ON)
|
||||
option(CAPSTONE_USE_DEFAULT_ALLOC "Use default memory allocation functions" ON)
|
||||
|
||||
set(SUPPORTED_ARCHITECTURES ARM ARM64 M68K MIPS PPC SPARC SYSZ XCORE X86 TMS320C64X M680X)
|
||||
set(SUPPORTED_ARCHITECTURE_LABELS ARM ARM64 M68K MIPS PowerPC Sparc SystemZ XCore x86 TMS320C64x M680x)
|
||||
set(SUPPORTED_ARCHITECTURES ARM ARM64 M68K MIPS PPC SPARC SYSZ XCORE X86 TMS320C64X M680X EVM)
|
||||
set(SUPPORTED_ARCHITECTURE_LABELS ARM ARM64 M68K MIPS PowerPC Sparc SystemZ XCore x86 TMS320C64x M680x EVM)
|
||||
|
||||
list(LENGTH SUPPORTED_ARCHITECTURES count)
|
||||
math(EXPR count "${count}-1")
|
||||
@ -364,6 +364,23 @@ if (CAPSTONE_M680X_SUPPORT)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_m680x.c)
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_EVM_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_EVM)
|
||||
set(SOURCES_EVM
|
||||
arch/EVM/EVMDisassembler.c
|
||||
arch/EVM/EVMInstPrinter.c
|
||||
arch/EVM/EVMMapping.c
|
||||
arch/EVM/EVMModule.c
|
||||
)
|
||||
set(HEADERS_EVM
|
||||
arch/EVM/EVMDisassembler.h
|
||||
arch/EVM/EVMInstPrinter.h
|
||||
arch/EVM/EVMMapping.h
|
||||
arch/EVM/EVMMappingInsn.inc
|
||||
)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_evm.c)
|
||||
endif ()
|
||||
|
||||
if (CAPSTONE_OSXKERNEL_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_OSXKERNEL)
|
||||
endif ()
|
||||
@ -381,6 +398,7 @@ set(ALL_SOURCES
|
||||
${SOURCES_M68K}
|
||||
${SOURCES_TMS320C64X}
|
||||
${SOURCES_M680X}
|
||||
${SOURCES_EVM}
|
||||
)
|
||||
|
||||
set(ALL_HEADERS
|
||||
@ -397,6 +415,7 @@ set(ALL_HEADERS
|
||||
${HEADERS_M68K}
|
||||
${HEADERS_TMS320C64X}
|
||||
${HEADERS_M680X}
|
||||
${HEADERS_EVM}
|
||||
)
|
||||
|
||||
include_directories("${PROJECT_SOURCE_DIR}/include")
|
||||
@ -473,6 +492,7 @@ source_group("Source\\XCore" FILES ${SOURCES_XCORE})
|
||||
source_group("Source\\M68K" FILES ${SOURCES_M68K})
|
||||
source_group("Source\\TMS320C64x" FILES ${SOURCES_TMS320C64X})
|
||||
source_group("Source\\M680X" FILES ${SOURCES_M680X})
|
||||
source_group("Source\\EVM" FILES ${SOURCES_EVM})
|
||||
|
||||
source_group("Include\\Common" FILES ${HEADERS_COMMON})
|
||||
source_group("Include\\Engine" FILES ${HEADERS_ENGINE})
|
||||
@ -487,6 +507,7 @@ source_group("Include\\XCore" FILES ${HEADERS_XCORE})
|
||||
source_group("Include\\M68K" FILES ${HEADERS_M68K})
|
||||
source_group("Include\\TMS320C64x" FILES ${HEADERS_TMS320C64X})
|
||||
source_group("Include\\M680X" FILES ${HEADERS_MC680X})
|
||||
source_group("Include\\EVM" FILES ${HEADERS_EVM})
|
||||
|
||||
### test library 64bit routine:
|
||||
get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
|
||||
|
13
COMPILE.TXT
13
COMPILE.TXT
@ -17,12 +17,12 @@ Capstone requires no prerequisite packages, so it is easy to compile & install.
|
||||
|
||||
(0) Tailor Capstone to your need.
|
||||
|
||||
Out of 9 archtitectures supported by Capstone (Arm, Arm64, M68K, Mips, PPC,
|
||||
Sparc, SystemZ, XCore & X86), if you just need several selected archs, choose
|
||||
which ones you want to compile in by editing "config.mk" before going to
|
||||
next steps.
|
||||
Out of 12 archtitectures supported by Capstone (Arm, Arm64, M68K, Mips, PPC,
|
||||
Sparc, SystemZ, XCore, X86, M680X, TMS320C64x & EVM), if you just need several
|
||||
selected archs, choose the ones you want to compile in by editing "config.mk"
|
||||
before going to next steps.
|
||||
|
||||
By default, all 9 architectures are compiled.
|
||||
By default, all 12 architectures are compiled.
|
||||
|
||||
The other way of customize Capstone without having to edit config.mk is to
|
||||
pass the desired options on the commandline to ./make.sh. Currently,
|
||||
@ -87,11 +87,14 @@ Capstone requires no prerequisite packages, so it is easy to compile & install.
|
||||
/usr/include/capstone/x86.h
|
||||
/usr/include/capstone/arm.h
|
||||
/usr/include/capstone/arm64.h
|
||||
/usr/include/capstone/evm.h
|
||||
/usr/include/capstone/m68k.h
|
||||
/usr/include/capstone/m680x.h
|
||||
/usr/include/capstone/mips.h
|
||||
/usr/include/capstone/ppc.h
|
||||
/usr/include/capstone/sparc.h
|
||||
/usr/include/capstone/systemz.h
|
||||
/usr/include/capstone/tms320c64x.h
|
||||
/usr/include/capstone/xcore.h
|
||||
/usr/include/capstone/platform.h
|
||||
/usr/lib/libcapstone.so (for Linux/*nix), or /usr/lib/libcapstone.dylib (OSX)
|
||||
|
@ -16,8 +16,8 @@ Get CMake for free from http://www.cmake.org.
|
||||
|
||||
(0) Tailor Capstone to your need.
|
||||
|
||||
Out of 9 archtitectures supported by Capstone (Arm, Arm64, M68K, Mips, PPC,
|
||||
Sparc, SystemZ, X86 & XCore), if you just need several selected archs,
|
||||
Out of 12 archtitectures supported by Capstone (Arm, Arm64, M68K, Mips, PPC,
|
||||
Sparc, SystemZ, X86, XCore, M680X, TMS320C64x & EVM), if you just need several selected archs,
|
||||
run "cmake" with the unwanted archs disabled (set to 0) as followings.
|
||||
|
||||
- CAPSTONE_ARM_SUPPORT: support ARM. Run cmake with -DCAPSTONE_ARM_SUPPORT=0 to remove ARM.
|
||||
@ -30,6 +30,9 @@ Get CMake for free from http://www.cmake.org.
|
||||
- CAPSTONE_SYSZ_SUPPORT: support SystemZ. Run cmake with -DCAPSTONE_SYSZ_SUPPORT=0 to remove SystemZ.
|
||||
- CAPSTONE_XCORE_SUPPORT: support XCore. Run cmake with -DCAPSTONE_XCORE_SUPPORT=0 to remove XCore.
|
||||
- CAPSTONE_X86_SUPPORT: support X86. Run cmake with -DCAPSTONE_X86_SUPPORT=0 to remove X86.
|
||||
- CAPSTONE_X86_TMS320C64X: support TMS320C64X. Run cmake with -DCAPSTONE_TMS320C64X_SUPPORT=0 to remove TMS320C64X.
|
||||
- CAPSTONE_X86_M680X: support M680X. Run cmake with -DCAPSTONE_M680X_SUPPORT=0 to remove M680X.
|
||||
- CAPSTONE_X86_EVM: support EVM. Run cmake with -DCAPSTONE_EVM_SUPPORT=0 to remove EVM.
|
||||
|
||||
By default, all 10 architectures are compiled in.
|
||||
|
||||
|
1
MCInst.h
1
MCInst.h
@ -109,6 +109,7 @@ struct MCInst {
|
||||
uint8_t ac_idx;
|
||||
uint8_t popcode_adjust; // Pseudo X86 instruction adjust
|
||||
char assembly[8]; // for special instruction, so that we dont need printer
|
||||
unsigned char evm_data[32]; // for EVM PUSH operand
|
||||
};
|
||||
|
||||
void MCInst_Init(MCInst *inst);
|
||||
|
15
Makefile
15
Makefile
@ -235,9 +235,21 @@ ifneq (,$(findstring m680x,$(CAPSTONE_ARCHS)))
|
||||
LIBOBJ_M680X += $(LIBSRC_M680X:%.c=$(OBJDIR)/%.o)
|
||||
endif
|
||||
|
||||
|
||||
DEP_EVM =
|
||||
DEP_EVM += $(wildcard arch/EVM/EVM*.inc)
|
||||
|
||||
LIBOBJ_EVM =
|
||||
ifneq (,$(findstring evm,$(CAPSTONE_ARCHS)))
|
||||
CFLAGS += -DCAPSTONE_HAS_EVM
|
||||
LIBSRC_EVM += $(wildcard arch/EVM/EVM*.c)
|
||||
LIBOBJ_EVM += $(LIBSRC_EVM:%.c=$(OBJDIR)/%.o)
|
||||
endif
|
||||
|
||||
|
||||
LIBOBJ =
|
||||
LIBOBJ += $(OBJDIR)/cs.o $(OBJDIR)/utils.o $(OBJDIR)/SStream.o $(OBJDIR)/MCInstrDesc.o $(OBJDIR)/MCRegisterInfo.o
|
||||
LIBOBJ += $(LIBOBJ_ARM) $(LIBOBJ_ARM64) $(LIBOBJ_M68K) $(LIBOBJ_MIPS) $(LIBOBJ_PPC) $(LIBOBJ_SPARC) $(LIBOBJ_SYSZ) $(LIBOBJ_X86) $(LIBOBJ_XCORE) $(LIBOBJ_TMS320C64X) $(LIBOBJ_M680X)
|
||||
LIBOBJ += $(LIBOBJ_ARM) $(LIBOBJ_ARM64) $(LIBOBJ_M68K) $(LIBOBJ_MIPS) $(LIBOBJ_PPC) $(LIBOBJ_SPARC) $(LIBOBJ_SYSZ) $(LIBOBJ_X86) $(LIBOBJ_XCORE) $(LIBOBJ_TMS320C64X) $(LIBOBJ_M680X) $(LIBOBJ_EVM)
|
||||
LIBOBJ += $(OBJDIR)/MCInst.o
|
||||
|
||||
|
||||
@ -363,6 +375,7 @@ $(LIBOBJ_X86): $(DEP_X86)
|
||||
$(LIBOBJ_XCORE): $(DEP_XCORE)
|
||||
$(LIBOBJ_TMS320C64X): $(DEP_TMS320C64X)
|
||||
$(LIBOBJ_M680X): $(DEP_M680X)
|
||||
$(LIBOBJ_EVM): $(DEP_EVM)
|
||||
|
||||
ifeq ($(CAPSTONE_STATIC),yes)
|
||||
$(ARCHIVE): $(LIBOBJ)
|
||||
|
@ -10,8 +10,8 @@ disasm engine for binary analysis and reversing in the security community.
|
||||
Created by Nguyen Anh Quynh, then developed and maintained by a small community,
|
||||
Capstone offers some unparalleled features:
|
||||
|
||||
- Support multiple hardware architectures: ARM, ARM64 (ARMv8), M68K, Mips, PPC,
|
||||
Sparc, SystemZ, TMS320C64X, M680X, XCore and X86 (including X86_64).
|
||||
- Support multiple hardware architectures: ARM, ARM64 (ARMv8), Ethereum VM, M68K,
|
||||
Mips, PPC, Sparc, SystemZ, TMS320C64X, M680X, XCore and X86 (including X86_64).
|
||||
|
||||
- Having clean/simple/lightweight/intuitive architecture-neutral API.
|
||||
|
||||
|
@ -5,7 +5,7 @@ import sys, re
|
||||
|
||||
INCL_DIR = '../include/capstone/'
|
||||
|
||||
include = [ 'arm.h', 'arm64.h', 'm68k.h', 'mips.h', 'x86.h', 'ppc.h', 'sparc.h', 'systemz.h', 'xcore.h', 'tms320c64x.h', 'm680x.h' ]
|
||||
include = [ 'arm.h', 'arm64.h', 'm68k.h', 'mips.h', 'x86.h', 'ppc.h', 'sparc.h', 'systemz.h', 'xcore.h', 'tms320c64x.h', 'm680x.h', 'evm.h' ]
|
||||
|
||||
template = {
|
||||
'java': {
|
||||
@ -25,6 +25,7 @@ template = {
|
||||
'xcore.h': 'Xcore',
|
||||
'tms320c64x.h': 'TMS320C64x',
|
||||
'm680x.h': 'M680x',
|
||||
'evm.h': 'Evm',
|
||||
'comment_open': '\t//',
|
||||
'comment_close': '',
|
||||
},
|
||||
@ -45,6 +46,7 @@ template = {
|
||||
'xcore.h': 'xcore',
|
||||
'tms320c64x.h': 'tms320c64x',
|
||||
'm680x.h': 'm680x',
|
||||
'evm.h': 'evm',
|
||||
'comment_open': '#',
|
||||
'comment_close': '',
|
||||
},
|
||||
@ -65,6 +67,7 @@ template = {
|
||||
'xcore.h': 'xcore',
|
||||
'tms320c64x.h': 'tms320c64x',
|
||||
'm680x.h': 'm680x',
|
||||
'evm.h': 'evm',
|
||||
'comment_open': '(*',
|
||||
'comment_close': ' *)',
|
||||
},
|
||||
|
@ -34,6 +34,7 @@ __all__ = [
|
||||
'CS_ARCH_M68K',
|
||||
'CS_ARCH_TMS320C64X',
|
||||
'CS_ARCH_M680X',
|
||||
'CS_ARCH_EVM',
|
||||
'CS_ARCH_ALL',
|
||||
|
||||
'CS_MODE_LITTLE_ENDIAN',
|
||||
@ -149,7 +150,8 @@ CS_ARCH_XCORE = 7
|
||||
CS_ARCH_M68K = 8
|
||||
CS_ARCH_TMS320C64X = 9
|
||||
CS_ARCH_M680X = 10
|
||||
CS_ARCH_MAX = 11
|
||||
CS_ARCH_EVM = 11
|
||||
CS_ARCH_MAX = 12
|
||||
CS_ARCH_ALL = 0xFFFF
|
||||
|
||||
# disasm mode
|
||||
@ -327,7 +329,7 @@ def copy_ctypes_list(src):
|
||||
return [copy_ctypes(n) for n in src]
|
||||
|
||||
# Weird import placement because these modules are needed by the below code but need the above functions
|
||||
from . import arm, arm64, m68k, mips, ppc, sparc, systemz, x86, xcore, tms320c64x, m680x
|
||||
from . import arm, arm64, m68k, mips, ppc, sparc, systemz, x86, xcore, tms320c64x, m680x, evm
|
||||
|
||||
class _cs_arch(ctypes.Union):
|
||||
_fields_ = (
|
||||
@ -342,6 +344,7 @@ class _cs_arch(ctypes.Union):
|
||||
('xcore', xcore.CsXcore),
|
||||
('tms320c64x', tms320c64x.CsTMS320C64x),
|
||||
('m680x', m680x.CsM680x),
|
||||
('evm', evm.CsEvm),
|
||||
)
|
||||
|
||||
class _cs_detail(ctypes.Structure):
|
||||
@ -648,6 +651,8 @@ class CsInsn(object):
|
||||
(self.condition, self.funit, self.parallel, self.operands) = tms320c64x.get_arch_info(self._raw.detail.contents.arch.tms320c64x)
|
||||
elif arch == CS_ARCH_M680X:
|
||||
(self.flags, self.operands) = m680x.get_arch_info(self._raw.detail.contents.arch.m680x)
|
||||
elif arch == CS_ARCH_EVM:
|
||||
(self.pop, self.push, self.fee) = evm.get_arch_info(self._raw.detail.contents.arch.evm)
|
||||
|
||||
|
||||
def __getattr__(self, name):
|
||||
@ -1072,7 +1077,7 @@ def debug():
|
||||
archs = { "arm": CS_ARCH_ARM, "arm64": CS_ARCH_ARM64, "m68k": CS_ARCH_M68K, \
|
||||
"mips": CS_ARCH_MIPS, "ppc": CS_ARCH_PPC, "sparc": CS_ARCH_SPARC, \
|
||||
"sysz": CS_ARCH_SYSZ, 'xcore': CS_ARCH_XCORE, "tms320c64x": CS_ARCH_TMS320C64X, \
|
||||
"m680x": CS_ARCH_M680X }
|
||||
"m680x": CS_ARCH_M680X, 'evm': CS_ARCH_EVM }
|
||||
|
||||
all_archs = ""
|
||||
keys = archs.keys()
|
||||
|
@ -40,7 +40,7 @@ else:
|
||||
compile_args = ['-O3', '-fomit-frame-pointer', '-I' + HEADERS_DIR]
|
||||
link_args = ['-L' + LIBS_DIR]
|
||||
|
||||
ext_module_names = ['arm', 'arm_const', 'arm64', 'arm64_const', 'm68k', 'm68k_const', 'm680x', 'm680x_const', 'mips', 'mips_const', 'ppc', 'ppc_const', 'x86', 'x86_const', 'sparc', 'sparc_const', 'systemz', 'sysz_const', 'xcore', 'xcore_const', 'tms320c64x', 'tms320c64x_const']
|
||||
ext_module_names = ['arm', 'arm_const', 'arm64', 'arm64_const', 'm68k', 'm68k_const', 'm680x', 'm680x_const', 'mips', 'mips_const', 'ppc', 'ppc_const', 'x86', 'x86_const', 'sparc', 'sparc_const', 'systemz', 'sysz_const', 'xcore', 'xcore_const', 'tms320c64x', 'tms320c64x_const', 'evm', 'evm_const' ]
|
||||
|
||||
ext_modules = [Extension("capstone.ccapstone",
|
||||
["pyx/ccapstone.pyx"],
|
||||
|
@ -4,7 +4,7 @@
|
||||
################################################################################
|
||||
# Specify which archs you want to compile in. By default, we build all archs.
|
||||
|
||||
CAPSTONE_ARCHS ?= arm aarch64 m68k mips powerpc sparc systemz x86 xcore tms320c64x m680x
|
||||
CAPSTONE_ARCHS ?= arm aarch64 m68k mips powerpc sparc systemz x86 xcore tms320c64x m680x evm
|
||||
|
||||
|
||||
################################################################################
|
||||
|
26
cs.c
26
cs.c
@ -66,6 +66,7 @@ extern void Sparc_enable(void);
|
||||
extern void SystemZ_enable(void);
|
||||
extern void XCore_enable(void);
|
||||
extern void TMS320C64x_enable(void);
|
||||
extern void EVM_enable(void);
|
||||
|
||||
static void archs_enable(void)
|
||||
{
|
||||
@ -107,6 +108,9 @@ static void archs_enable(void)
|
||||
#ifdef CAPSTONE_HAS_TMS320C64X
|
||||
TMS320C64x_enable();
|
||||
#endif
|
||||
#ifdef CAPSTONE_HAS_EVM
|
||||
EVM_enable();
|
||||
#endif
|
||||
|
||||
|
||||
initialized = true;
|
||||
@ -187,7 +191,7 @@ bool CAPSTONE_API cs_support(int query)
|
||||
(1 << CS_ARCH_PPC) | (1 << CS_ARCH_SPARC) |
|
||||
(1 << CS_ARCH_SYSZ) | (1 << CS_ARCH_XCORE) |
|
||||
(1 << CS_ARCH_M68K) | (1 << CS_ARCH_TMS320C64X) |
|
||||
(1 << CS_ARCH_M680X));
|
||||
(1 << CS_ARCH_M680X) | (1 << CS_ARCH_EVM));
|
||||
|
||||
if ((unsigned int)query < CS_ARCH_MAX)
|
||||
return all_arch & (1 << query);
|
||||
@ -447,6 +451,9 @@ static uint8_t skipdata_size(cs_struct *handle)
|
||||
case CS_ARCH_M680X:
|
||||
// M680X alignment is 1.
|
||||
return 1;
|
||||
case CS_ARCH_EVM:
|
||||
// EVM alignment is 1.
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1153,6 +1160,13 @@ int CAPSTONE_API cs_op_count(csh ud, const cs_insn *insn, unsigned int op_type)
|
||||
if (insn->detail->m680x.operands[i].type == (m680x_op_type)op_type)
|
||||
count++;
|
||||
break;
|
||||
case CS_ARCH_EVM:
|
||||
#if 0
|
||||
for (i = 0; i < insn->detail->evm.op_count; i++)
|
||||
if (insn->detail->evm.operands[i].type == (evm_op_type)op_type)
|
||||
count++;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
return count;
|
||||
@ -1278,6 +1292,16 @@ int CAPSTONE_API cs_op_index(csh ud, const cs_insn *insn, unsigned int op_type,
|
||||
return i;
|
||||
}
|
||||
break;
|
||||
case CS_ARCH_EVM:
|
||||
#if 0
|
||||
for (i = 0; i < insn->detail->evm.op_count; i++) {
|
||||
if (insn->detail->evm.operands[i].type == (evm_op_type)op_type)
|
||||
count++;
|
||||
if (count == post)
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
@ -55,6 +55,7 @@ static struct {
|
||||
{ "hd6301", CS_ARCH_M680X, CS_MODE_M680X_6301 },
|
||||
{ "hd6309", CS_ARCH_M680X, CS_MODE_M680X_6309 },
|
||||
{ "hcs08", CS_ARCH_M680X, CS_MODE_M680X_HCS08 },
|
||||
{ "evm", CS_ARCH_EVM, 0 },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@ -69,6 +70,8 @@ void print_insn_detail_xcore(csh handle, cs_insn *ins);
|
||||
void print_insn_detail_m68k(csh handle, cs_insn *ins);
|
||||
void print_insn_detail_tms320c64x(csh handle, cs_insn *ins);
|
||||
void print_insn_detail_m680x(csh handle, cs_insn *ins);
|
||||
void print_insn_detail_evm(csh handle, cs_insn *ins);
|
||||
|
||||
static void print_details(csh handle, cs_arch arch, cs_mode md, cs_insn *ins);
|
||||
|
||||
void print_string_hex(char *comment, unsigned char *str, size_t len)
|
||||
@ -178,7 +181,7 @@ static void usage(char *prog)
|
||||
if (cs_support(CS_ARCH_XCORE)) {
|
||||
printf(" xcore: xcore\n");
|
||||
}
|
||||
|
||||
|
||||
if (cs_support(CS_ARCH_M68K)) {
|
||||
printf(" m68k: m68k + big endian\n");
|
||||
printf(" m68k40: m68k_040\n");
|
||||
@ -188,18 +191,22 @@ static void usage(char *prog)
|
||||
printf(" tms320c64x:TMS320C64x\n");
|
||||
}
|
||||
|
||||
if (cs_support(CS_ARCH_M680X)) {
|
||||
printf(" m6800: M6800/2\n");
|
||||
printf(" m6801: M6801/3\n");
|
||||
printf(" m6805: M6805\n");
|
||||
printf(" m6808: M68HC08\n");
|
||||
printf(" m6809: M6809\n");
|
||||
printf(" m6811: M68HC11\n");
|
||||
printf(" cpu12: M68HC12/HCS12\n");
|
||||
printf(" hd6301: HD6301/3\n");
|
||||
printf(" hd6309: HD6309\n");
|
||||
printf(" hcs08: HCS08\n");
|
||||
}
|
||||
if (cs_support(CS_ARCH_M680X)) {
|
||||
printf(" m6800: M6800/2\n");
|
||||
printf(" m6801: M6801/3\n");
|
||||
printf(" m6805: M6805\n");
|
||||
printf(" m6808: M68HC08\n");
|
||||
printf(" m6809: M6809\n");
|
||||
printf(" m6811: M68HC11\n");
|
||||
printf(" cpu12: M68HC12/HCS12\n");
|
||||
printf(" hd6301: HD6301/3\n");
|
||||
printf(" hd6309: HD6309\n");
|
||||
printf(" hcs08: HCS08\n");
|
||||
}
|
||||
|
||||
if (cs_support(CS_ARCH_EVM)) {
|
||||
printf(" evm: Ethereum Virtual Machine\n");
|
||||
}
|
||||
|
||||
printf("\nExtra options:\n");
|
||||
printf(" -d show detailed information of the instructions\n");
|
||||
@ -239,8 +246,11 @@ static void print_details(csh handle, cs_arch arch, cs_mode md, cs_insn *ins)
|
||||
case CS_ARCH_TMS320C64X:
|
||||
print_insn_detail_tms320c64x(handle, ins);
|
||||
break;
|
||||
case CS_ARCH_M680X:
|
||||
print_insn_detail_m680x(handle, ins);
|
||||
case CS_ARCH_M680X:
|
||||
print_insn_detail_m680x(handle, ins);
|
||||
break;
|
||||
case CS_ARCH_EVM:
|
||||
print_insn_detail_evm(handle, ins);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
@ -276,21 +286,21 @@ int main(int argc, char **argv)
|
||||
|
||||
while ((c = getopt (argc, argv, "udhv")) != -1) {
|
||||
switch (c) {
|
||||
case 'u':
|
||||
unsigned_flag = true;
|
||||
break;
|
||||
case 'd':
|
||||
detail_flag = true;
|
||||
break;
|
||||
case 'v':
|
||||
printf("%u.%u.%u\n", CS_VERSION_MAJOR, CS_VERSION_MINOR, CS_VERSION_EXTRA);
|
||||
return 0;
|
||||
case 'h':
|
||||
usage(argv[0]);
|
||||
return 0;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
return -1;
|
||||
case 'u':
|
||||
unsigned_flag = true;
|
||||
break;
|
||||
case 'd':
|
||||
detail_flag = true;
|
||||
break;
|
||||
case 'v':
|
||||
printf("%u.%u.%u\n", CS_VERSION_MAJOR, CS_VERSION_MINOR, CS_VERSION_EXTRA);
|
||||
return 0;
|
||||
case 'h':
|
||||
usage(argv[0]);
|
||||
return 0;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,7 @@ typedef enum cs_arch {
|
||||
CS_ARCH_M68K, // 68K architecture
|
||||
CS_ARCH_TMS320C64X, // TMS320C64x architecture
|
||||
CS_ARCH_M680X, // 680X architecture
|
||||
CS_ARCH_EVM, // Ethereum architecture
|
||||
CS_ARCH_MAX,
|
||||
CS_ARCH_ALL = 0xFFFF, // All architectures - for cs_support()
|
||||
} cs_arch;
|
||||
@ -255,6 +256,7 @@ typedef struct cs_opt_skipdata {
|
||||
// SystemZ: 2 bytes.
|
||||
// X86: 1 bytes.
|
||||
// XCore: 2 bytes.
|
||||
// EVM: 1 bytes.
|
||||
cs_skipdata_cb_t callback; // default value is NULL
|
||||
|
||||
// User-defined data to be passed to @callback function pointer.
|
||||
@ -273,6 +275,7 @@ typedef struct cs_opt_skipdata {
|
||||
#include "xcore.h"
|
||||
#include "tms320c64x.h"
|
||||
#include "m680x.h"
|
||||
#include "evm.h"
|
||||
|
||||
// NOTE: All information in cs_detail is only available when CS_OPT_DETAIL = CS_OPT_ON
|
||||
typedef struct cs_detail {
|
||||
@ -287,17 +290,18 @@ typedef struct cs_detail {
|
||||
|
||||
// Architecture-specific instruction info
|
||||
union {
|
||||
cs_x86 x86; // X86 architecture, including 16-bit, 32-bit & 64-bit mode
|
||||
cs_arm64 arm64; // ARM64 architecture (aka AArch64)
|
||||
cs_arm arm; // ARM architecture (including Thumb/Thumb2)
|
||||
cs_m68k m68k; // M68K architecture
|
||||
cs_mips mips; // MIPS architecture
|
||||
cs_ppc ppc; // PowerPC architecture
|
||||
cs_sparc sparc; // Sparc architecture
|
||||
cs_sysz sysz; // SystemZ architecture
|
||||
cs_xcore xcore; // XCore architecture
|
||||
cs_tms320c64x tms320c64x; // TMS320C64x architecture
|
||||
cs_m680x m680x; // M680X architecture
|
||||
cs_x86 x86; // X86 architecture, including 16-bit, 32-bit & 64-bit mode
|
||||
cs_arm64 arm64; // ARM64 architecture (aka AArch64)
|
||||
cs_arm arm; // ARM architecture (including Thumb/Thumb2)
|
||||
cs_m68k m68k; // M68K architecture
|
||||
cs_mips mips; // MIPS architecture
|
||||
cs_ppc ppc; // PowerPC architecture
|
||||
cs_sparc sparc; // Sparc architecture
|
||||
cs_sysz sysz; // SystemZ architecture
|
||||
cs_xcore xcore; // XCore architecture
|
||||
cs_tms320c64x tms320c64x; // TMS320C64x architecture
|
||||
cs_m680x m680x; // M680X architecture
|
||||
cs_evm evm; // Ethereum architecture
|
||||
};
|
||||
} cs_detail;
|
||||
|
||||
|
@ -109,6 +109,10 @@ ifneq (,$(findstring m680x,$(CAPSTONE_ARCHS)))
|
||||
CFLAGS += -DCAPSTONE_HAS_M680X
|
||||
SOURCES += test_m680x.c
|
||||
endif
|
||||
ifneq (,$(findstring evm,$(CAPSTONE_ARCHS)))
|
||||
CFLAGS += -DCAPSTONE_HAS_EVM
|
||||
SOURCES += test_evm.c
|
||||
endif
|
||||
|
||||
OBJS = $(addprefix $(OBJDIR)/,$(SOURCES:.c=.o))
|
||||
BINARY = $(addprefix $(TESTDIR)/,$(SOURCES:.c=$(BIN_EXT)))
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Capstone Disassembler Engine */
|
||||
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013> */
|
||||
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013 */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Capstone Disassembler Engine */
|
||||
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013> */
|
||||
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013 */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Capstone Disassembler Engine */
|
||||
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013> */
|
||||
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013 */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -80,6 +80,9 @@ static void test()
|
||||
#endif
|
||||
#ifdef CAPSTONE_HAS_M680X
|
||||
#define M680X_CODE "\x06\x10\x19\x1a\x55\x1e\x01\x23\xe9\x31\x06\x34\x55\xa6\x81\xa7\x89\x7f\xff\xa6\x9d\x10\x00\xa7\x91\xa6\x9f\x10\x00\x11\xac\x99\x10\x00\x39"
|
||||
#endif
|
||||
#ifdef CAPSTONE_HAS_EVM
|
||||
#define EVM_CODE "\x60\x61"
|
||||
#endif
|
||||
|
||||
|
||||
@ -302,6 +305,15 @@ static void test()
|
||||
sizeof(M680X_CODE) - 1,
|
||||
"M680X_M6809",
|
||||
},
|
||||
#endif
|
||||
#ifdef CAPSTONE_HAS_EVM
|
||||
{
|
||||
CS_ARCH_EVM,
|
||||
0,
|
||||
(unsigned char*)EVM_CODE,
|
||||
sizeof(EVM_CODE) - 1,
|
||||
"EVM",
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Capstone Disassembler Engine */
|
||||
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013> */
|
||||
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013 */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Capstone Disassembler Engine */
|
||||
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013> */
|
||||
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013 */
|
||||
|
||||
// This sample code demonstrates the APIs cs_malloc() & cs_disasm_iter().
|
||||
#include <stdio.h>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Capstone Disassembler Engine */
|
||||
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013> */
|
||||
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013 */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Capstone Disassembler Engine */
|
||||
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013> */
|
||||
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013 */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Capstone Disassembler Engine */
|
||||
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013> */
|
||||
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013 */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Capstone Disassembler Engine */
|
||||
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013> */
|
||||
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013 */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
Loading…
Reference in New Issue
Block a user