mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-23 13:19:54 +00:00
Move anal.esil into the new esil ##esil
This commit is contained in:
parent
22bbdf9eb7
commit
cded4df114
@ -1,15 +1,7 @@
|
||||
executable('rabin2', 'rabin2.c',
|
||||
include_directories: [platform_inc],
|
||||
dependencies: [
|
||||
r_util_dep,
|
||||
r_cons_dep,
|
||||
r_main_dep,
|
||||
r_config_dep,
|
||||
r_io_dep,
|
||||
r_crypto_dep,
|
||||
r_core_dep,
|
||||
r_magic_dep,
|
||||
r_bin_dep
|
||||
],
|
||||
install: true,
|
||||
install_rpath: rpath_exe,
|
||||
|
@ -1,7 +1,7 @@
|
||||
BIN=radare2
|
||||
BINDEPS=r_core r_parse r_search r_cons r_config
|
||||
BINDEPS+=r_bin r_debug r_anal r_reg r_bp r_io r_fs
|
||||
BINDEPS+=r_lang r_asm r_syscall r_main r_util
|
||||
BINDEPS+=r_lang r_asm r_syscall r_main r_util r_esil
|
||||
BINDEPS+=r_magic r_socket r_flag r_egg r_crypto
|
||||
|
||||
include ../../config-user.mk
|
||||
|
@ -9,6 +9,7 @@ radare2_exe = executable('radare2', 'radare2.c',
|
||||
r_fs_dep,
|
||||
r_bin_dep,
|
||||
r_flag_dep,
|
||||
r_esil_dep,
|
||||
r_cons_dep,
|
||||
r_asm_dep,
|
||||
r_debug_dep,
|
||||
|
@ -4,7 +4,7 @@ EXTRA_TARGETS+=do
|
||||
EXTRA_CLEAN=doclean
|
||||
|
||||
NAME=r_anal
|
||||
R2DEPS=r_util r_reg r_syscall r_search r_cons r_flag r_crypto r_parse r_arch
|
||||
R2DEPS=r_util r_reg r_syscall r_search r_cons r_flag r_crypto r_parse r_arch r_esil
|
||||
CFLAGS:=-I.. -I$(LTOP)/asm/arch/include -DR2_PLUGIN_INCORE -Iarch -I$(TOP)/shlr $(CFLAGS)
|
||||
|
||||
LDFLAGS+=${BN_LIBS}
|
||||
@ -26,14 +26,13 @@ plugins: ${LIBSO} ${LIBAR}
|
||||
@$(MAKE) -C p all
|
||||
|
||||
include ${STATIC_ANAL_PLUGINS}
|
||||
include ${STATIC_ESIL_PLUGINS}
|
||||
|
||||
STATIC_OBJS=$(addprefix $(LTOP)/anal/p/,$(STATIC_OBJ))
|
||||
OBJLIBS=meta.o reflines.o op.o fcn.o bb.o var.o block.o
|
||||
OBJLIBS+=cond.o value.o cc.o class.o diff.o type.o type_pdb.o dwarf_process.o
|
||||
OBJLIBS+=hint.o anal.o data.o xrefs.o esil.o sign.o esil_plugin.o
|
||||
OBJLIBS+=esil_handler.o switch.o cycles.o esil_dfg.o esil_cfg.o
|
||||
OBJLIBS+=esil_stats.o esil_trace.o flirt.o labels.o
|
||||
OBJLIBS+=hint.o anal.o data.o xrefs.o sign.o
|
||||
OBJLIBS+=switch.o cycles.o esil_dfg.o esil_cfg.o
|
||||
OBJLIBS+=flirt.o labels.o
|
||||
OBJLIBS+=pin.o vtable.o rtti.o codemeta.o anplugs.o global.o
|
||||
OBJLIBS+=rtti_msvc.o rtti_itanium.o jmptbl.o function.o
|
||||
|
||||
|
@ -14,11 +14,6 @@ r_anal_sources = [
|
||||
'cycles.c',
|
||||
'data.c',
|
||||
'diff.c',
|
||||
'esil.c',
|
||||
'esil_stats.c',
|
||||
'esil_trace.c',
|
||||
'esil_plugin.c',
|
||||
'esil_handler.c',
|
||||
'esil_cfg.c',
|
||||
'esil_dfg.c',
|
||||
'fcn.c',
|
||||
@ -86,7 +81,6 @@ r_anal_sources = [
|
||||
'p/anal_m68k_gnu.c',
|
||||
'../asm/arch/m68k/gnu/m68k-dis.c',
|
||||
'../asm/arch/m68k/gnu/m68k-opc.c',
|
||||
'p/anal_malbolge.c',
|
||||
'p/anal_mcore.c',
|
||||
'p/anal_mips_cs.c',
|
||||
'../asm/arch/mips/mipsasm.c',
|
||||
@ -137,7 +131,6 @@ r_anal_sources = [
|
||||
'p/anal_xcore_cs.c',
|
||||
'p/anal_xtensa.c',
|
||||
'p/anal_z80.c',
|
||||
'p/esil_dummy.c',
|
||||
#join_paths('arch','gb','meta_gb_cmt.c'),
|
||||
'arch/ebc/ebc_disas.c',
|
||||
'arch/wasm/wasm.c',
|
||||
@ -239,6 +232,7 @@ r_anal = library('r_anal', r_anal_sources,
|
||||
r_reg_dep,
|
||||
r_asm_dep,
|
||||
r_arch_dep,
|
||||
r_esil_dep,
|
||||
r_crypto_dep,
|
||||
r_search_dep,
|
||||
r_cons_dep,
|
||||
@ -262,18 +256,19 @@ r_anal_static = static_library('r_anal_static', r_anal_sources,
|
||||
include_directories: r_anal_inc,
|
||||
c_args: library_cflags,
|
||||
dependencies: [
|
||||
r_util_static_dep,
|
||||
r_reg_static_dep,
|
||||
r_asm_static_dep,
|
||||
r_crypto_static_dep,
|
||||
r_search_static_dep,
|
||||
r_arch_static_dep,
|
||||
r_cons_static_dep,
|
||||
r_parse_static_dep,
|
||||
r_syscall_static_dep,
|
||||
r_flag_static_dep,
|
||||
capstone_dep,
|
||||
java_static_dep,
|
||||
capstone_dep
|
||||
r_arch_static_dep,
|
||||
r_asm_static_dep,
|
||||
r_cons_static_dep,
|
||||
r_crypto_static_dep,
|
||||
r_esil_static_dep,
|
||||
r_flag_static_dep,
|
||||
r_parse_static_dep,
|
||||
r_reg_static_dep,
|
||||
r_search_static_dep,
|
||||
r_syscall_static_dep,
|
||||
r_util_static_dep,
|
||||
],
|
||||
install: true,
|
||||
implicit_include_directories: false,
|
||||
|
@ -12,8 +12,8 @@ all: ${ALL_TARGETS}
|
||||
|
||||
ALL_TARGETS=
|
||||
# TODO: rename to enabled plugins
|
||||
ARCHS=null.mk arc.mk ppc_gnu.mk ppc_cs.mk arm_gnu.mk avr.mk xap.mk bpf.mk dalvik.mk sh.mk ebc.mk gb.mk lh5801.mk malbolge.mk ws.mk h8300.mk cr16.mk v850.mk msp430.mk sparc_gnu.mk sparc_cs.mk x86_cs.mk cris.mk 6502.mk snes.mk riscv.mk vax.mk xtensa.mk rsp.mk mcore.mk tricore.mk s390_cs.mk pickle.mk
|
||||
include $(ARCHS)
|
||||
ANAL_PLUGINS=null.mk arc.mk ppc_gnu.mk ppc_cs.mk arm_gnu.mk avr.mk xap.mk bpf.mk dalvik.mk sh.mk ebc.mk gb.mk lh5801.mk ws.mk h8300.mk cr16.mk v850.mk msp430.mk sparc_gnu.mk sparc_cs.mk x86_cs.mk cris.mk 6502.mk snes.mk riscv.mk vax.mk xtensa.mk rsp.mk mcore.mk tricore.mk s390_cs.mk pickle.mk
|
||||
include $(ANAL_PLUGINS)
|
||||
|
||||
clean:
|
||||
-rm -f *.${EXT_SO} *.o ${STATIC_OBJ}
|
||||
|
@ -1,80 +0,0 @@
|
||||
/* radare - LGPL - Copyright 2015-2022 - condret */
|
||||
|
||||
#include <r_anal.h>
|
||||
#include <r_types.h>
|
||||
#include <r_lib.h>
|
||||
|
||||
static int mal_anal(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len, RAnalOpMask mask) {
|
||||
if (len) {
|
||||
switch ((data[0] + addr) % 94) {
|
||||
case 4:
|
||||
op->type = R_ANAL_OP_TYPE_UJMP;
|
||||
if (mask & R_ARCH_OP_MASK_DISASM) {
|
||||
op->mnemonic = strdup ("jmp [d]");
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
op->type = R_ANAL_OP_TYPE_IO;
|
||||
if (mask & R_ARCH_OP_MASK_DISASM) {
|
||||
op->mnemonic = strdup ("out a");
|
||||
}
|
||||
break;
|
||||
case 23:
|
||||
op->type = R_ANAL_OP_TYPE_IO;
|
||||
if (mask & R_ARCH_OP_MASK_DISASM) {
|
||||
op->mnemonic = strdup ("in a");
|
||||
}
|
||||
break;
|
||||
case 39:
|
||||
op->type = R_ANAL_OP_TYPE_ROR;
|
||||
op->type2 = R_ANAL_OP_TYPE_LOAD;
|
||||
if (mask & R_ARCH_OP_MASK_DISASM) {
|
||||
op->mnemonic = strdup ("rotr [d], mov a, [d]");
|
||||
}
|
||||
break;
|
||||
case 40:
|
||||
op->type = R_ANAL_OP_TYPE_LOAD;
|
||||
if (mask & R_ARCH_OP_MASK_DISASM) {
|
||||
op->mnemonic = strdup ("mov d, [d]");
|
||||
}
|
||||
break;
|
||||
case 62:
|
||||
op->type = R_ANAL_OP_TYPE_XOR;
|
||||
op->type2 = R_ANAL_OP_TYPE_LOAD;
|
||||
if (mask & R_ARCH_OP_MASK_DISASM) {
|
||||
op->mnemonic = strdup ("crz [d], a, mov a, [d]");
|
||||
}
|
||||
break;
|
||||
case 81:
|
||||
op->type = R_ANAL_OP_TYPE_TRAP;
|
||||
if (mask & R_ARCH_OP_MASK_DISASM) {
|
||||
op->mnemonic = strdup ("end");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
op->type = R_ANAL_OP_TYPE_NOP;
|
||||
if (mask & R_ARCH_OP_MASK_DISASM) {
|
||||
op->mnemonic = strdup ("nop");
|
||||
}
|
||||
}
|
||||
return op->size = 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
RAnalPlugin r_anal_plugin_malbolge = {
|
||||
.name = "malbolge",
|
||||
.desc = "Malbolge analysis plugin",
|
||||
.arch = "malbolge",
|
||||
.license = "LGPL3",
|
||||
.bits = 32,
|
||||
.op = &mal_anal,
|
||||
};
|
||||
|
||||
#ifndef R2_PLUGIN_INCORE
|
||||
R_API RLibStruct radare_plugin = {
|
||||
.type = R_LIB_TYPE_ANAL,
|
||||
.data = &r_anal_plugin_malbolge,
|
||||
.version = R2_VERSION
|
||||
};
|
||||
#endif
|
@ -1,9 +0,0 @@
|
||||
OBJ_MALBOLGE=anal_malbolge.o
|
||||
|
||||
STATIC_OBJ+=${OBJ_MALBOLGE}
|
||||
TARGET_MALBOLGE=anal_malbolge.${EXT_SO}
|
||||
|
||||
ALL_TARGETS+=${TARGET_MALBOLGE}
|
||||
|
||||
${TARGET_MALBOLGE}: ${OBJ_MALBOLGE}
|
||||
${CC} $(call libname,anal_malbolge) ${LDFLAGS} ${CFLAGS} -o anal_malbolge.${EXT_SO} ${OBJ_MALBOLGE}
|
@ -5,6 +5,9 @@
|
||||
#define NAME_BUF_SIZE 64
|
||||
#define BASE_CLASSES_MAX 32
|
||||
|
||||
RecoveryTypeDescriptor *recovery_anal_type_descriptor(RRTTIMSVCAnalContext *context, ut64 addr, RecoveryCompleteObjectLocator *col);
|
||||
static const char *recovery_apply_complete_object_locator(RRTTIMSVCAnalContext *context, RecoveryCompleteObjectLocator *col);
|
||||
static const char *recovery_apply_type_descriptor(RRTTIMSVCAnalContext *context, RecoveryTypeDescriptor *td);
|
||||
|
||||
typedef struct rtti_complete_object_locator_t {
|
||||
ut32 signature;
|
||||
@ -15,7 +18,6 @@ typedef struct rtti_complete_object_locator_t {
|
||||
ut32 object_base; // only for 64bit, see rtti_msvc_read_complete_object_locator()
|
||||
} rtti_complete_object_locator;
|
||||
|
||||
|
||||
typedef struct rtti_class_hierarchy_descriptor_t {
|
||||
ut32 signature;
|
||||
ut32 attributes; // bit 0 set = multiple inheritance, bit 1 set = virtual inheritance
|
||||
@ -704,8 +706,6 @@ typedef struct rtti_msvc_anal_context_t {
|
||||
} RRTTIMSVCAnalContext;
|
||||
|
||||
|
||||
RecoveryTypeDescriptor *recovery_anal_type_descriptor(RRTTIMSVCAnalContext *context, ut64 addr, RecoveryCompleteObjectLocator *col);
|
||||
|
||||
RecoveryCompleteObjectLocator *recovery_anal_complete_object_locator(RRTTIMSVCAnalContext *context, ut64 addr, RVTableInfo *vtable) {
|
||||
RecoveryCompleteObjectLocator *col = ht_up_find (context->addr_col, addr, NULL);
|
||||
if (col) {
|
||||
@ -848,9 +848,6 @@ static void recovery_apply_vtable(RAnal *anal, const char *class_name, RVTableIn
|
||||
}
|
||||
}
|
||||
|
||||
static const char *recovery_apply_complete_object_locator(RRTTIMSVCAnalContext *context, RecoveryCompleteObjectLocator *col);
|
||||
static const char *recovery_apply_type_descriptor(RRTTIMSVCAnalContext *context, RecoveryTypeDescriptor *td);
|
||||
|
||||
static void recovery_apply_bases(RRTTIMSVCAnalContext *context, const char *class_name, RVector *base_descs) {
|
||||
RecoveryBaseDescriptor *base_desc;
|
||||
r_vector_foreach (base_descs, base_desc) {
|
||||
@ -886,7 +883,6 @@ static void recovery_apply_bases(RRTTIMSVCAnalContext *context, const char *clas
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const char *recovery_apply_complete_object_locator(RRTTIMSVCAnalContext *context, RecoveryCompleteObjectLocator *col) {
|
||||
if (!col->valid) {
|
||||
return NULL;
|
||||
@ -933,8 +929,6 @@ static const char *recovery_apply_complete_object_locator(RRTTIMSVCAnalContext *
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const char *recovery_apply_type_descriptor(RRTTIMSVCAnalContext *context, RecoveryTypeDescriptor *td) {
|
||||
if (!td->valid) {
|
||||
return NULL;
|
||||
@ -971,9 +965,10 @@ static const char *recovery_apply_type_descriptor(RRTTIMSVCAnalContext *context,
|
||||
return name;
|
||||
}
|
||||
|
||||
static void str_value_free(HtUPKv *kv) {
|
||||
static inline void str_value_free(HtUPKv *kv) {
|
||||
if (kv) {
|
||||
free (kv->value);
|
||||
R_FREE (kv->value);
|
||||
// free (kv); ???
|
||||
}
|
||||
}
|
||||
|
||||
@ -1018,7 +1013,6 @@ R_API void r_anal_rtti_msvc_recover_all(RVTableContext *vt_context, RList *vtabl
|
||||
recovery_apply_complete_object_locator (&context, col);
|
||||
}
|
||||
#endif
|
||||
|
||||
r_pvector_clear (&context.vtables);
|
||||
r_pvector_clear (&context.complete_object_locators);
|
||||
ht_up_free (context.addr_col);
|
||||
@ -1026,4 +1020,3 @@ R_API void r_anal_rtti_msvc_recover_all(RVTableContext *vt_context, RList *vtabl
|
||||
ht_up_free (context.addr_td);
|
||||
ht_up_free (context.col_td_classes);
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ r_arch_sources = [
|
||||
'p/arch_i4004.c',
|
||||
'p/arch_amd29k.c',
|
||||
'p/arch_jdh8.c',
|
||||
'p/arch_malbolge.c',
|
||||
'p/arch_sh.c',
|
||||
'p/sh/gnu/sh-dis.c',
|
||||
]
|
||||
|
81
libr/arch/p/arch_malbolge.c
Normal file
81
libr/arch/p/arch_malbolge.c
Normal file
@ -0,0 +1,81 @@
|
||||
/* radare - LGPL - Copyright 2015-2022 - condret */
|
||||
|
||||
#include <r_anal.h>
|
||||
#include <r_lib.h>
|
||||
|
||||
static bool mal_decode(RArchSession *s, RAnalOp *op, RArchEncodeMask mask) {
|
||||
if (op->size < 1 || !op->bytes) {
|
||||
return false;
|
||||
}
|
||||
const ut8 *data = op->bytes;
|
||||
switch ((data[0] + op->addr) % 94) {
|
||||
case 4:
|
||||
op->type = R_ANAL_OP_TYPE_UJMP;
|
||||
if (mask & R_ARCH_OP_MASK_DISASM) {
|
||||
op->mnemonic = strdup ("jmp [d]");
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
op->type = R_ANAL_OP_TYPE_IO;
|
||||
if (mask & R_ARCH_OP_MASK_DISASM) {
|
||||
op->mnemonic = strdup ("out a");
|
||||
}
|
||||
break;
|
||||
case 23:
|
||||
op->type = R_ANAL_OP_TYPE_IO;
|
||||
if (mask & R_ARCH_OP_MASK_DISASM) {
|
||||
op->mnemonic = strdup ("in a");
|
||||
}
|
||||
break;
|
||||
case 39:
|
||||
op->type = R_ANAL_OP_TYPE_ROR;
|
||||
op->type2 = R_ANAL_OP_TYPE_LOAD;
|
||||
if (mask & R_ARCH_OP_MASK_DISASM) {
|
||||
op->mnemonic = strdup ("rotr [d], mov a, [d]");
|
||||
}
|
||||
break;
|
||||
case 40:
|
||||
op->type = R_ANAL_OP_TYPE_LOAD;
|
||||
if (mask & R_ARCH_OP_MASK_DISASM) {
|
||||
op->mnemonic = strdup ("mov d, [d]");
|
||||
}
|
||||
break;
|
||||
case 62:
|
||||
op->type = R_ANAL_OP_TYPE_XOR;
|
||||
op->type2 = R_ANAL_OP_TYPE_LOAD;
|
||||
if (mask & R_ARCH_OP_MASK_DISASM) {
|
||||
op->mnemonic = strdup ("crz [d], a, mov a, [d]");
|
||||
}
|
||||
break;
|
||||
case 81:
|
||||
op->type = R_ANAL_OP_TYPE_TRAP;
|
||||
if (mask & R_ARCH_OP_MASK_DISASM) {
|
||||
op->mnemonic = strdup ("end");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
op->type = R_ANAL_OP_TYPE_NOP;
|
||||
if (mask & R_ARCH_OP_MASK_DISASM) {
|
||||
op->mnemonic = strdup ("nop");
|
||||
}
|
||||
}
|
||||
op->size = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
RArchPlugin r_arch_plugin_malbolge = {
|
||||
.name = "malbolge",
|
||||
.desc = "Malbolge analysis plugin",
|
||||
.arch = "malbolge",
|
||||
.license = "LGPL3",
|
||||
.bits = 32,
|
||||
.decode = &mal_decode,
|
||||
};
|
||||
|
||||
#ifndef R2_PLUGIN_INCORE
|
||||
R_API RLibStruct radare_plugin = {
|
||||
.type = R_LIB_TYPE_ANAL,
|
||||
.data = &r_arch_plugin_malbolge,
|
||||
.version = R2_VERSION
|
||||
};
|
||||
#endif
|
9
libr/arch/p/malbolge.mk
Normal file
9
libr/arch/p/malbolge.mk
Normal file
@ -0,0 +1,9 @@
|
||||
OBJ_MALBOLGE=arch_malbolge.o
|
||||
|
||||
STATIC_OBJ+=${OBJ_MALBOLGE}
|
||||
TARGET_MALBOLGE=arch_malbolge.${EXT_SO}
|
||||
|
||||
ALL_TARGETS+=${TARGET_MALBOLGE}
|
||||
|
||||
${TARGET_MALBOLGE}: ${OBJ_MALBOLGE}
|
||||
${CC} $(call libname,arch_malbolge) ${LDFLAGS} ${CFLAGS} -o arch_malbolge.${EXT_SO} ${OBJ_MALBOLGE}
|
@ -2,7 +2,7 @@ include ../config.mk
|
||||
|
||||
NAME=r_core
|
||||
|
||||
R2DEPS=r_config r_cons r_io r_util r_flag r_asm r_arch
|
||||
R2DEPS=r_config r_cons r_io r_util r_flag r_asm r_arch r_esil
|
||||
R2DEPS+=r_debug r_bin r_lang r_io r_anal r_parse r_bp r_egg
|
||||
R2DEPS+=r_reg r_search r_syscall r_socket r_fs r_magic r_crypto
|
||||
|
||||
|
@ -79,6 +79,7 @@ r_core_deps = [
|
||||
r_syscall_dep,
|
||||
r_search_dep,
|
||||
r_arch_dep,
|
||||
r_esil_dep,
|
||||
r_cons_dep,
|
||||
r_anal_dep,
|
||||
r_socket_dep,
|
||||
@ -120,31 +121,32 @@ r_core_dep = declare_dependency(link_with: r_core, include_directories: r_core_i
|
||||
if get_option('blob')
|
||||
|
||||
r_core_static_deps = [
|
||||
r_util_static_dep,
|
||||
r_reg_static_dep,
|
||||
r_syscall_static_dep,
|
||||
r_search_static_dep,
|
||||
r_arch_static_dep,
|
||||
r_cons_static_dep,
|
||||
r_anal_static_dep,
|
||||
r_socket_static_dep,
|
||||
r_io_static_dep,
|
||||
r_fs_static_dep,
|
||||
r_lang_static_dep,
|
||||
r_magic_static_dep,
|
||||
r_flag_static_dep,
|
||||
r_parse_static_dep,
|
||||
r_egg_static_dep,
|
||||
r_debug_static_dep,
|
||||
r_crypto_static_dep,
|
||||
r_config_static_dep,
|
||||
r_bin_static_dep,
|
||||
r_asm_static_dep,
|
||||
r_bp_static_dep,
|
||||
platform_deps,
|
||||
gdb_static_dep,
|
||||
java_static_dep,
|
||||
lrt
|
||||
lrt,
|
||||
platform_deps,
|
||||
r_anal_static_dep,
|
||||
r_arch_static_dep,
|
||||
r_asm_static_dep,
|
||||
r_bin_static_dep,
|
||||
r_bp_static_dep,
|
||||
r_config_static_dep,
|
||||
r_cons_static_dep,
|
||||
r_crypto_static_dep,
|
||||
r_debug_static_dep,
|
||||
r_egg_static_dep,
|
||||
r_esil_static_dep,
|
||||
r_flag_static_dep,
|
||||
r_fs_static_dep,
|
||||
r_io_static_dep,
|
||||
r_lang_static_dep,
|
||||
r_magic_static_dep,
|
||||
r_parse_static_dep,
|
||||
r_reg_static_dep,
|
||||
r_search_static_dep,
|
||||
r_socket_static_dep,
|
||||
r_syscall_static_dep,
|
||||
r_util_static_dep,
|
||||
]
|
||||
r_core_static = static_library('r_core_static', r_core_sources,
|
||||
include_directories: r_core_inc,
|
||||
@ -165,26 +167,27 @@ pkgconfig_mod.generate(
|
||||
filebase: 'r_core',
|
||||
libraries: pkgcfg_sanitize_libs,
|
||||
requires: pkgconfig_magic_requires + [
|
||||
'r_util',
|
||||
'r_reg',
|
||||
'r_syscall',
|
||||
'r_search',
|
||||
'r_arch',
|
||||
'r_cons',
|
||||
'r_anal',
|
||||
'r_socket',
|
||||
'r_io',
|
||||
'r_fs',
|
||||
'r_lang',
|
||||
'r_flag',
|
||||
'r_parse',
|
||||
'r_egg',
|
||||
'r_debug',
|
||||
'r_crypto',
|
||||
'r_config',
|
||||
'r_bin',
|
||||
'r_arch',
|
||||
'r_asm',
|
||||
'r_bp'
|
||||
'r_bin',
|
||||
'r_bp',
|
||||
'r_config',
|
||||
'r_cons',
|
||||
'r_crypto',
|
||||
'r_debug',
|
||||
'r_egg',
|
||||
'r_esil',
|
||||
'r_flag',
|
||||
'r_fs',
|
||||
'r_io',
|
||||
'r_lang',
|
||||
'r_parse',
|
||||
'r_reg',
|
||||
'r_search',
|
||||
'r_socket',
|
||||
'r_syscall',
|
||||
'r_util',
|
||||
],
|
||||
description: 'radare foundation libraries'
|
||||
)
|
||||
|
18
libr/esil/Makefile
Normal file
18
libr/esil/Makefile
Normal file
@ -0,0 +1,18 @@
|
||||
include ../config.mk
|
||||
|
||||
NAME=r_esil
|
||||
R2DEPS+=r_util r_reg
|
||||
|
||||
CFLAGS+=-DR2_PLUGIN_INCORE
|
||||
CFLAGS:=-I.. -I$(LTOP)/asm/esil/include -DR2_PLUGIN_INCORE -Iesil -I$(TOP)/shlr $(CFLAGS)
|
||||
|
||||
.PHONY: pre
|
||||
pre: libr_esil.$(EXT_SO) libr_esil.$(EXT_AR)
|
||||
$(MAKE) -C p
|
||||
|
||||
include $(STATIC_ESIL_PLUGINS)
|
||||
STATIC_OBJS=$(subst ..,p/..,$(subst esil_,p/esil_,$(STATIC_OBJ)))
|
||||
OBJS=esil.o esil_plugin.o esil_handler.o esil_stats.o esil_trace.o
|
||||
OBJS+=${STATIC_OBJS}
|
||||
|
||||
include ../rules.mk
|
@ -1,6 +1,6 @@
|
||||
/* radare - LGPL - Copyright 2014-2022 - pancake, condret */
|
||||
|
||||
#define R_LOG_ORIGIN "anal.esil"
|
||||
#define R_LOG_ORIGIN "esil"
|
||||
|
||||
#include <r_anal.h>
|
||||
|
||||
@ -238,8 +238,8 @@ static ut8 esil_internal_sizeof_reg(RAnalEsil *esil, const char *r) {
|
||||
}
|
||||
|
||||
static bool alignCheck(RAnalEsil *esil, ut64 addr) {
|
||||
int dataAlign = r_anal_archinfo (esil->anal, R_ANAL_ARCHINFO_DATA_ALIGN);
|
||||
return !(dataAlign > 0 && addr % dataAlign);
|
||||
const int da = esil->data_align; // r_anal_archinfo (esil->anal, R_ANAL_ARCHINFO_DATA_ALIGN);
|
||||
return !(da > 0 && addr % da);
|
||||
}
|
||||
|
||||
static bool internal_esil_mem_read(RAnalEsil *esil, ut64 addr, ut8 *buf, int len) {
|
51
libr/esil/meson.build
Normal file
51
libr/esil/meson.build
Normal file
@ -0,0 +1,51 @@
|
||||
r_esil_sources = [
|
||||
'esil.c',
|
||||
'esil_handler.c',
|
||||
'esil_plugin.c',
|
||||
'esil_stats.c',
|
||||
'esil_trace.c',
|
||||
]
|
||||
|
||||
extra_includes = include_directories('../asm/esil/include')
|
||||
|
||||
r_esil = library('r_esil', r_esil_sources,
|
||||
include_directories: [platform_inc, extra_includes],
|
||||
c_args: library_cflags,
|
||||
dependencies: [
|
||||
r_util_dep,
|
||||
r_reg_dep
|
||||
],
|
||||
install: true,
|
||||
implicit_include_directories: false,
|
||||
install_rpath: rpath_lib,
|
||||
soversion: r2_libversion
|
||||
)
|
||||
|
||||
r_esil_dep = declare_dependency(link_with: r_esil,
|
||||
include_directories: [platform_inc])
|
||||
|
||||
if get_option('blob')
|
||||
r_esil_static = static_library('r_esil_static', r_esil_sources,
|
||||
include_directories: [platform_inc, extra_includes],
|
||||
c_args: library_cflags,
|
||||
dependencies: [r_util_static_dep],
|
||||
install: true,
|
||||
implicit_include_directories: false,
|
||||
)
|
||||
|
||||
r_esil_static_dep = declare_dependency(link_with: r_esil_static,
|
||||
include_directories: [platform_inc])
|
||||
endif
|
||||
|
||||
pkgconfig_mod.generate(r_esil,
|
||||
subdirs: 'libr',
|
||||
version: r2_version,
|
||||
name: 'r_esil',
|
||||
filebase: 'r_esil',
|
||||
libraries: pkgcfg_sanitize_libs,
|
||||
requires: [
|
||||
'r_util',
|
||||
'r_reg',
|
||||
],
|
||||
description: 'radare foundation libraries'
|
||||
)
|
25
libr/esil/p/Makefile
Normal file
25
libr/esil/p/Makefile
Normal file
@ -0,0 +1,25 @@
|
||||
include ../../config.mk
|
||||
include ../../../mk/platform.mk
|
||||
|
||||
ifeq ($(WITHPIC),1)
|
||||
CFLAGS+=-I../../include -I../arch/ -I../arch/include -Wall ${PIC_CFLAGS} ${LDFLAGS_LIB}
|
||||
CFLAGS+=-D__UNIX__
|
||||
|
||||
all: ${ALL_TARGETS}
|
||||
|
||||
ALL_TARGETS=
|
||||
ESIL_PLUGINS=dummy.mk
|
||||
include $(ESIL_PLUGINS)
|
||||
|
||||
clean:
|
||||
-rm -f *.so *.o ${STATIC_OBJ}
|
||||
|
||||
mrproper: clean
|
||||
-rm -f *.d
|
||||
|
||||
.PHONY: all clean mrproper
|
||||
else
|
||||
all clean mrproper:
|
||||
|
||||
.PHONY: all clean mrproper
|
||||
endif
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <r_types.h>
|
||||
#include <r_io.h>
|
||||
#include <r_esil.h>
|
||||
#include <r_arch.h>
|
||||
#include <r_list.h>
|
||||
#include <r_util/r_print.h>
|
||||
@ -61,9 +62,6 @@ typedef struct r_anal_range_t {
|
||||
RBNode rb;
|
||||
} RAnalRange;
|
||||
|
||||
|
||||
#define esilprintf(op, fmt, ...) r_strbuf_setf (&op->esil, fmt, ##__VA_ARGS__)
|
||||
|
||||
enum {
|
||||
R_ANAL_DATA_TYPE_NULL = 0,
|
||||
R_ANAL_DATA_TYPE_UNKNOWN = 1,
|
||||
@ -660,15 +658,6 @@ typedef struct r_anal_esil_word_t {
|
||||
const char *str;
|
||||
} RAnalEsilWord;
|
||||
|
||||
// only flags that affect control flow
|
||||
enum {
|
||||
R_ANAL_ESIL_FLAG_ZERO = 1,
|
||||
R_ANAL_ESIL_FLAG_CARRY = 2,
|
||||
R_ANAL_ESIL_FLAG_OVERFLOW = 4,
|
||||
R_ANAL_ESIL_FLAG_PARITY = 8,
|
||||
R_ANAL_ESIL_FLAG_SIGN = 16,
|
||||
// ...
|
||||
};
|
||||
|
||||
enum {
|
||||
R_ANAL_TRAP_NONE = 0,
|
||||
@ -684,196 +673,6 @@ enum {
|
||||
R_ANAL_TRAP_HALT = 10,
|
||||
};
|
||||
|
||||
enum {
|
||||
R_ANAL_ESIL_PARM_INVALID = 0,
|
||||
R_ANAL_ESIL_PARM_REG,
|
||||
R_ANAL_ESIL_PARM_NUM,
|
||||
};
|
||||
|
||||
/* Constructs to convert from ESIL to REIL */
|
||||
#define FOREACHOP(GENERATE) \
|
||||
/* No Operation */ GENERATE(NOP) \
|
||||
/* Unknown/Undefined */ GENERATE(UNK) \
|
||||
/* Conditional Jump */ GENERATE(JCC) \
|
||||
/* Store Value to register */ GENERATE(STR) \
|
||||
/* Store value to memory */ GENERATE(STM) \
|
||||
/* Load value from memory */ GENERATE(LDM) \
|
||||
/* Addition */ GENERATE(ADD) \
|
||||
/* Subtraction */ GENERATE(SUB) \
|
||||
/* Negation */ GENERATE(NEG) \
|
||||
/* Multiplication */ GENERATE(MUL) \
|
||||
/* Division */ GENERATE(DIV) \
|
||||
/* Modulo */ GENERATE(MOD) \
|
||||
/* Signed Multiplication */ GENERATE(SMUL) \
|
||||
/* Sugned Division */ GENERATE(SDIV) \
|
||||
/* Signed Modulus */ GENERATE(SMOD) \
|
||||
/* Shift Left */ GENERATE(SHL) \
|
||||
/* Shift Right */ GENERATE(SHR) \
|
||||
/* Binary and */ GENERATE(AND) \
|
||||
/* Binary or */ GENERATE(OR) \
|
||||
/* Binary xor */ GENERATE(XOR) \
|
||||
/* Binary not */ GENERATE(NOT) \
|
||||
/* Equation */ GENERATE(EQ) \
|
||||
/* Less Than */ GENERATE(LT)
|
||||
|
||||
#define MAKE_ENUM(OP) REIL_##OP,
|
||||
#define REIL_OP_STRING(STRING) #STRING,
|
||||
|
||||
typedef enum {
|
||||
FOREACHOP(MAKE_ENUM)
|
||||
} RAnalReilOpcode;
|
||||
|
||||
typedef enum {
|
||||
ARG_REG, // CPU Register
|
||||
ARG_TEMP, // Temporary register used by REIL
|
||||
ARG_CONST, // Constant value
|
||||
ARG_ESIL_INTERNAL, // Used to resolve ESIL internal flags
|
||||
ARG_NONE // Operand not used by the instruction
|
||||
} RAnalReilArgType;
|
||||
|
||||
// Arguments to a REIL instruction.
|
||||
typedef struct r_anal_reil_arg {
|
||||
RAnalReilArgType type; // Type of the argument
|
||||
ut8 size; // Size of the argument in bytes
|
||||
char name[32]; // Name of the argument
|
||||
} RAnalReilArg;
|
||||
|
||||
typedef struct r_anal_ref_char {
|
||||
char *str;
|
||||
char *cols;
|
||||
} RAnalRefStr;
|
||||
|
||||
// Instruction arg1, arg2, arg3
|
||||
typedef struct r_anal_reil_inst {
|
||||
RAnalReilOpcode opcode;
|
||||
RAnalReilArg *arg[3];
|
||||
} RAnalReilInst;
|
||||
|
||||
typedef struct r_anal_reil {
|
||||
char old[32]; // Used to compute flags.
|
||||
char cur[32];
|
||||
ut8 lastsz;
|
||||
ut64 reilNextTemp; // Used to store the index of the next REIL temp register to be used.
|
||||
ut64 addr; // Used for instruction sequencing. Check esil2reil.c for details.
|
||||
ut8 seq_num; // Incremented and used when noInc is set to 1.
|
||||
int skip;
|
||||
int cmd_count;
|
||||
char if_buf[64];
|
||||
char pc[8];
|
||||
} RAnalReil;
|
||||
|
||||
// must be a char
|
||||
#define ESIL_INTERNAL_PREFIX '$'
|
||||
#define ESIL_STACK_NAME "esil.ram"
|
||||
#define ESIL struct r_anal_esil_t
|
||||
|
||||
typedef bool (*RAnalEsilHandlerCB)(ESIL *esil, ut32 h, void *user);
|
||||
|
||||
typedef struct r_anal_esil_handler_t {
|
||||
RAnalEsilHandlerCB cb;
|
||||
void *user;
|
||||
} RAnalEsilHandler;
|
||||
|
||||
typedef struct r_anal_esil_change_reg_t {
|
||||
int idx;
|
||||
ut64 data;
|
||||
} RAnalEsilRegChange;
|
||||
|
||||
typedef struct r_anal_esil_change_mem_t {
|
||||
int idx;
|
||||
ut8 data;
|
||||
} RAnalEsilMemChange;
|
||||
|
||||
typedef struct r_anal_esil_trace_t {
|
||||
int idx;
|
||||
int end_idx;
|
||||
HtUP *registers;
|
||||
HtUP *memory;
|
||||
RRegArena *arena[R_REG_TYPE_LAST];
|
||||
ut64 stack_addr;
|
||||
ut64 stack_size;
|
||||
ut8 *stack_data;
|
||||
//TODO remove `db` and reuse info above
|
||||
Sdb *db;
|
||||
} RAnalEsilTrace;
|
||||
|
||||
typedef bool (*RAnalEsilHookRegWriteCB)(ESIL *esil, const char *name, ut64 *val);
|
||||
|
||||
typedef struct r_anal_esil_callbacks_t {
|
||||
void *user;
|
||||
/* callbacks */
|
||||
bool (*hook_flag_read)(ESIL *esil, const char *flag, ut64 *num);
|
||||
bool (*hook_command)(ESIL *esil, const char *op);
|
||||
bool (*hook_mem_read)(ESIL *esil, ut64 addr, ut8 *buf, int len);
|
||||
bool (*mem_read)(ESIL *esil, ut64 addr, ut8 *buf, int len);
|
||||
bool (*hook_mem_write)(ESIL *esil, ut64 addr, const ut8 *buf, int len);
|
||||
bool (*mem_write)(ESIL *esil, ut64 addr, const ut8 *buf, int len);
|
||||
bool (*hook_reg_read)(ESIL *esil, const char *name, ut64 *res, int *size);
|
||||
bool (*reg_read)(ESIL *esil, const char *name, ut64 *res, int *size);
|
||||
RAnalEsilHookRegWriteCB hook_reg_write;
|
||||
bool (*reg_write)(ESIL *esil, const char *name, ut64 val);
|
||||
} RAnalEsilCallbacks;
|
||||
|
||||
typedef struct r_anal_esil_t {
|
||||
RAnal *anal;
|
||||
char **stack;
|
||||
ut64 addrmask;
|
||||
int stacksize;
|
||||
int stackptr;
|
||||
ut32 skip;
|
||||
int nowrite;
|
||||
int iotrap;
|
||||
int exectrap;
|
||||
int parse_stop;
|
||||
int parse_goto;
|
||||
int parse_goto_count;
|
||||
int verbose;
|
||||
ut64 flags;
|
||||
ut64 address;
|
||||
ut64 stack_addr;
|
||||
ut32 stack_size;
|
||||
int delay; // mapped to $ds in ESIL
|
||||
ut64 jump_target; // mapped to $jt in ESIL
|
||||
int jump_target_set; // mapped to $js in ESIL
|
||||
int trap;
|
||||
ut32 trap_code; // extend into a struct to store more exception info?
|
||||
// parity flag? done with cur
|
||||
ut64 old; //used for carry-flagging and borrow-flagging
|
||||
ut64 cur; //used for carry-flagging and borrow-flagging
|
||||
ut8 lastsz; //in bits //used for signature-flag
|
||||
/* native ops and custom ops */
|
||||
HtPP *ops;
|
||||
char *current_opstr;
|
||||
SdbMini *interrupts;
|
||||
SdbMini *syscalls;
|
||||
//this is a disgusting workaround, because we have no ht-like storage without magic keys, that you cannot use, with int-keys
|
||||
RAnalEsilHandler *intr0;
|
||||
RAnalEsilHandler *sysc0;
|
||||
RList *plugins;
|
||||
RList *active_plugins;
|
||||
/* deep esil parsing fills this */
|
||||
Sdb *stats;
|
||||
RAnalEsilTrace *trace;
|
||||
RAnalEsilCallbacks cb;
|
||||
RAnalReil *Reil;
|
||||
char *pending; // pending op computed as a macro
|
||||
// this is so cursed, can we please remove external commands from esil internals.
|
||||
// Function pointers are fine, but not commands
|
||||
char *cmd_step; // r2 (external) command to run before a step is performed
|
||||
char *cmd_step_out; // r2 (external) command to run after a step is performed
|
||||
char *cmd_intr; // r2 (external) command to run when an interrupt occurs
|
||||
char *cmd_trap; // r2 (external) command to run when a trap occurs
|
||||
char *cmd_mdev; // r2 (external) command to run when an memory mapped device address is used
|
||||
char *cmd_todo; // r2 (external) command to run when esil expr contains TODO
|
||||
char *cmd_ioer; // r2 (external) command to run when esil fails to IO
|
||||
char *mdev_range; // string containing the r_str_range to match for read/write accesses
|
||||
bool (*cmd)(ESIL *esil, const char *name, ut64 a0, ut64 a1);
|
||||
void *user;
|
||||
int stack_fd; // ahem, let's not do this
|
||||
bool in_cmd_step;
|
||||
} RAnalEsil;
|
||||
|
||||
#undef ESIL
|
||||
|
||||
enum {
|
||||
R_ANAL_ESIL_OP_TYPE_UNKNOWN = 0x1,
|
||||
|
219
libr/include/r_esil.h
Normal file
219
libr/include/r_esil.h
Normal file
@ -0,0 +1,219 @@
|
||||
/* radare2 - LGPL - Copyright 2022 - pancake */
|
||||
|
||||
#ifndef R_ESIL_H
|
||||
#define R_ESIL_H
|
||||
|
||||
#include <r_reg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define esilprintf(op, fmt, ...) r_strbuf_setf (&op->esil, fmt, ##__VA_ARGS__)
|
||||
// only flags that affect control flow
|
||||
enum {
|
||||
R_ANAL_ESIL_FLAG_ZERO = 1,
|
||||
R_ANAL_ESIL_FLAG_CARRY = 2,
|
||||
R_ANAL_ESIL_FLAG_OVERFLOW = 4,
|
||||
R_ANAL_ESIL_FLAG_PARITY = 8,
|
||||
R_ANAL_ESIL_FLAG_SIGN = 16,
|
||||
// ...
|
||||
};
|
||||
|
||||
#define ESIL_INTERNAL_PREFIX '$'
|
||||
#define ESIL_STACK_NAME "esil.ram"
|
||||
|
||||
typedef struct r_anal_esil_t ESIL;
|
||||
|
||||
typedef bool (*RAnalEsilHandlerCB)(ESIL *esil, ut32 h, void *user);
|
||||
|
||||
typedef struct r_anal_esil_handler_t {
|
||||
RAnalEsilHandlerCB cb;
|
||||
void *user;
|
||||
} RAnalEsilHandler;
|
||||
|
||||
typedef struct r_anal_esil_change_reg_t {
|
||||
int idx;
|
||||
ut64 data;
|
||||
} RAnalEsilRegChange;
|
||||
|
||||
typedef struct r_anal_esil_change_mem_t {
|
||||
int idx;
|
||||
ut8 data;
|
||||
} RAnalEsilMemChange;
|
||||
|
||||
typedef struct r_anal_esil_trace_t {
|
||||
int idx;
|
||||
int end_idx;
|
||||
HtUP *registers;
|
||||
HtUP *memory;
|
||||
RRegArena *arena[R_REG_TYPE_LAST];
|
||||
ut64 stack_addr;
|
||||
ut64 stack_size;
|
||||
ut8 *stack_data;
|
||||
//TODO remove `db` and reuse info above
|
||||
Sdb *db;
|
||||
} RAnalEsilTrace;
|
||||
|
||||
typedef bool (*RAnalEsilHookRegWriteCB)(ESIL *esil, const char *name, ut64 *val);
|
||||
|
||||
typedef struct r_anal_esil_callbacks_t {
|
||||
void *user;
|
||||
/* callbacks */
|
||||
bool (*hook_flag_read)(ESIL *esil, const char *flag, ut64 *num);
|
||||
bool (*hook_command)(ESIL *esil, const char *op);
|
||||
bool (*hook_mem_read)(ESIL *esil, ut64 addr, ut8 *buf, int len);
|
||||
bool (*mem_read)(ESIL *esil, ut64 addr, ut8 *buf, int len);
|
||||
bool (*hook_mem_write)(ESIL *esil, ut64 addr, const ut8 *buf, int len);
|
||||
bool (*mem_write)(ESIL *esil, ut64 addr, const ut8 *buf, int len);
|
||||
bool (*hook_reg_read)(ESIL *esil, const char *name, ut64 *res, int *size);
|
||||
bool (*reg_read)(ESIL *esil, const char *name, ut64 *res, int *size);
|
||||
RAnalEsilHookRegWriteCB hook_reg_write;
|
||||
bool (*reg_write)(ESIL *esil, const char *name, ut64 val);
|
||||
} RAnalEsilCallbacks;
|
||||
|
||||
typedef struct r_anal_esil_t {
|
||||
struct r_anal_t *anal; // XXX maybe just use arch?
|
||||
char **stack;
|
||||
ut64 addrmask;
|
||||
int stacksize;
|
||||
int stackptr;
|
||||
ut32 skip;
|
||||
int nowrite;
|
||||
int iotrap;
|
||||
int exectrap;
|
||||
int parse_stop;
|
||||
int parse_goto;
|
||||
int parse_goto_count;
|
||||
int verbose;
|
||||
ut64 flags;
|
||||
ut64 address;
|
||||
ut64 stack_addr;
|
||||
ut32 stack_size;
|
||||
int delay; // mapped to $ds in ESIL
|
||||
ut64 jump_target; // mapped to $jt in ESIL
|
||||
int jump_target_set; // mapped to $js in ESIL
|
||||
int trap;
|
||||
int data_align;
|
||||
ut32 trap_code; // extend into a struct to store more exception info?
|
||||
// parity flag? done with cur
|
||||
ut64 old; //used for carry-flagging and borrow-flagging
|
||||
ut64 cur; //used for carry-flagging and borrow-flagging
|
||||
ut8 lastsz; //in bits //used for signature-flag
|
||||
/* native ops and custom ops */
|
||||
HtPP *ops;
|
||||
char *current_opstr;
|
||||
SdbMini *interrupts;
|
||||
SdbMini *syscalls;
|
||||
//this is a disgusting workaround, because we have no ht-like storage without magic keys, that you cannot use, with int-keys
|
||||
RAnalEsilHandler *intr0;
|
||||
RAnalEsilHandler *sysc0;
|
||||
RList *plugins;
|
||||
RList *active_plugins;
|
||||
/* deep esil parsing fills this */
|
||||
Sdb *stats;
|
||||
RAnalEsilTrace *trace;
|
||||
RAnalEsilCallbacks cb;
|
||||
struct r_anal_reil_t *Reil;
|
||||
char *pending; // pending op computed as a macro
|
||||
// this is so cursed, can we please remove external commands from esil internals.
|
||||
// Function pointers are fine, but not commands
|
||||
char *cmd_step; // r2 (external) command to run before a step is performed
|
||||
char *cmd_step_out; // r2 (external) command to run after a step is performed
|
||||
char *cmd_intr; // r2 (external) command to run when an interrupt occurs
|
||||
char *cmd_trap; // r2 (external) command to run when a trap occurs
|
||||
char *cmd_mdev; // r2 (external) command to run when an memory mapped device address is used
|
||||
char *cmd_todo; // r2 (external) command to run when esil expr contains TODO
|
||||
char *cmd_ioer; // r2 (external) command to run when esil fails to IO
|
||||
char *mdev_range; // string containing the r_str_range to match for read/write accesses
|
||||
bool (*cmd)(ESIL *esil, const char *name, ut64 a0, ut64 a1);
|
||||
void *user;
|
||||
int stack_fd; // ahem, let's not do this
|
||||
bool in_cmd_step;
|
||||
} RAnalEsil;
|
||||
|
||||
|
||||
/* reil -- must be deprecated */
|
||||
/* Constructs to convert from ESIL to REIL */
|
||||
#define FOREACHOP(GENERATE) \
|
||||
/* No Operation */ GENERATE(NOP) \
|
||||
/* Unknown/Undefined */ GENERATE(UNK) \
|
||||
/* Conditional Jump */ GENERATE(JCC) \
|
||||
/* Store Value to register */ GENERATE(STR) \
|
||||
/* Store value to memory */ GENERATE(STM) \
|
||||
/* Load value from memory */ GENERATE(LDM) \
|
||||
/* Addition */ GENERATE(ADD) \
|
||||
/* Subtraction */ GENERATE(SUB) \
|
||||
/* Negation */ GENERATE(NEG) \
|
||||
/* Multiplication */ GENERATE(MUL) \
|
||||
/* Division */ GENERATE(DIV) \
|
||||
/* Modulo */ GENERATE(MOD) \
|
||||
/* Signed Multiplication */ GENERATE(SMUL) \
|
||||
/* Sugned Division */ GENERATE(SDIV) \
|
||||
/* Signed Modulus */ GENERATE(SMOD) \
|
||||
/* Shift Left */ GENERATE(SHL) \
|
||||
/* Shift Right */ GENERATE(SHR) \
|
||||
/* Binary and */ GENERATE(AND) \
|
||||
/* Binary or */ GENERATE(OR) \
|
||||
/* Binary xor */ GENERATE(XOR) \
|
||||
/* Binary not */ GENERATE(NOT) \
|
||||
/* Equation */ GENERATE(EQ) \
|
||||
/* Less Than */ GENERATE(LT)
|
||||
|
||||
#define MAKE_ENUM(OP) REIL_##OP,
|
||||
#define REIL_OP_STRING(STRING) #STRING,
|
||||
|
||||
typedef enum {
|
||||
FOREACHOP(MAKE_ENUM)
|
||||
} RAnalReilOpcode;
|
||||
|
||||
typedef enum {
|
||||
ARG_REG, // CPU Register
|
||||
ARG_TEMP, // Temporary register used by REIL
|
||||
ARG_CONST, // Constant value
|
||||
ARG_ESIL_INTERNAL, // Used to resolve ESIL internal flags
|
||||
ARG_NONE // Operand not used by the instruction
|
||||
} RAnalReilArgType;
|
||||
|
||||
// Arguments to a REIL instruction.
|
||||
typedef struct r_anal_reil_arg {
|
||||
RAnalReilArgType type; // Type of the argument
|
||||
ut8 size; // Size of the argument in bytes
|
||||
char name[32]; // Name of the argument
|
||||
} RAnalReilArg;
|
||||
|
||||
enum {
|
||||
R_ANAL_ESIL_PARM_INVALID = 0,
|
||||
R_ANAL_ESIL_PARM_REG,
|
||||
R_ANAL_ESIL_PARM_NUM,
|
||||
};
|
||||
|
||||
typedef struct r_anal_ref_char_t {
|
||||
char *str;
|
||||
char *cols;
|
||||
} RAnalRefStr;
|
||||
|
||||
// Instruction arg1, arg2, arg3
|
||||
typedef struct r_anal_reil_inst_t {
|
||||
RAnalReilOpcode opcode;
|
||||
RAnalReilArg *arg[3];
|
||||
} RAnalReilInst;
|
||||
|
||||
typedef struct r_anal_reil_t {
|
||||
char old[32]; // Used to compute flags.
|
||||
char cur[32];
|
||||
ut8 lastsz;
|
||||
ut64 reilNextTemp; // Used to store the index of the next REIL temp register to be used.
|
||||
ut64 addr; // Used for instruction sequencing. Check esil2reil.c for details.
|
||||
ut8 seq_num; // Incremented and used when noInc is set to 1.
|
||||
int skip;
|
||||
int cmd_count;
|
||||
char if_buf[64];
|
||||
char pc[8];
|
||||
} RAnalReil;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -4,7 +4,7 @@ ifeq ($(LIBS0),)
|
||||
LIBS0=util
|
||||
LIBS1=socket reg cons magic bp config
|
||||
LIBS2=syscall lang crypto flag arch
|
||||
LIBS3=parse io search
|
||||
LIBS3=parse io search esil
|
||||
LIBS4=asm fs
|
||||
LIBS5=anal egg bin
|
||||
LIBS6=debug
|
||||
|
@ -438,6 +438,7 @@ include_files = [
|
||||
'include/r_agraph.h',
|
||||
'include/r_anal.h',
|
||||
'include/r_arch.h',
|
||||
'include/r_esil.h',
|
||||
'include/r_asm.h',
|
||||
'include/r_bin.h',
|
||||
'include/r_bin_dwarf.h',
|
||||
@ -562,6 +563,11 @@ r_anal_files = [
|
||||
]
|
||||
install_headers(r_anal_files, install_dir: join_paths(r2_incdir, 'r_anal'))
|
||||
|
||||
r_esil_files = [
|
||||
'include/r_esil.h',
|
||||
]
|
||||
install_headers(r_esil_files, install_dir: join_paths(r2_incdir, 'r_esil'))
|
||||
|
||||
sflib_common_files = [
|
||||
join_paths('include/sflib/common/sftypes.h'),
|
||||
join_paths('include/sflib/common/sfsocketcall.h')
|
||||
|
Loading…
Reference in New Issue
Block a user