From eb93cee2a22cde812ccd6b9bd418d36185c058f5 Mon Sep 17 00:00:00 2001 From: comex Date: Sun, 8 Feb 2015 23:45:24 -0500 Subject: Refactor disassembly so x86 works, and add x86 transform-dis. This patch is a monolithic mess, because I was too lazy to do the refactor first (that would require some stash fun, since I wasn't actually sure before doing x86 transform-dis what would be needed). Anyway, the resulting code should be cleaner - less duplication. This breaks ARM/ARM64. --- lib/dis.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'lib/dis.h') diff --git a/lib/dis.h b/lib/dis.h index 6b189e0..7455749 100644 --- a/lib/dis.h +++ b/lib/dis.h @@ -111,6 +111,11 @@ static const unsigned null_op = -0x100; #error "no disassembler for the target architecture yet" #endif +static inline void op64(void **codep, uint64_t op) { + *(uint64_t *) *codep = op; + *codep += 8; +} + static inline void op32(void **codep, uint32_t op) { *(uint32_t *) *codep = op; *codep += 4; @@ -121,5 +126,26 @@ static inline void op16(void **codep, uint16_t op) { *codep += 2; } +static inline void op8(void **codep, uint8_t op) { + *(uint8_t *) *codep = op; + (*codep)++; +} + #define CC_CONDITIONAL 0x100 #define CC_CALL 0x200 + +struct dis_ctx_base { + uint_tptr pc; + const void *ptr; +#if defined(TARGET_x86_64) || defined(TARGET_i386) + uint8_t newop[32]; +#else + uint8_t newop[4]; + uint32_t op; +#endif + uint32_t newval[4]; + bool modify; + int op_size, newop_size; +}; + +#include stringify(TARGET_DIR/arch-dis.h) -- cgit v1.2.3