From d85137ed65d5f8834d2caf749f575e9fab00eef6 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 6 Mar 2017 18:29:36 -0500 Subject: [PATCH] interface_x64: Amend LLVM disassembly code This would previously attempt to perform pointer arithmetic on void pointers, which would cause compilation errors. --- src/backend_x64/interface_x64.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/backend_x64/interface_x64.cpp b/src/backend_x64/interface_x64.cpp index 7724a7ff..63d524d2 100644 --- a/src/backend_x64/interface_x64.cpp +++ b/src/backend_x64/interface_x64.cpp @@ -58,20 +58,21 @@ struct Jit::Impl { std::string result = fmt::format("address: {}\nsize: {} bytes\n", block.code_ptr, block.size); #ifdef DYNARMIC_USE_LLVM - CodePtr end = block.code_ptr + block.size; - size_t remaining = block.size; - LLVMInitializeX86TargetInfo(); LLVMInitializeX86TargetMC(); LLVMInitializeX86Disassembler(); LLVMDisasmContextRef llvm_ctx = LLVMCreateDisasm("x86_64", nullptr, 0, nullptr, nullptr); LLVMSetDisasmOptions(llvm_ctx, LLVMDisassembler_Option_AsmPrinterVariant); - for (CodePtr pos = block.code_ptr; pos < end;) { + const u8* pos = static_cast(block.code_ptr); + const u8* end = pos + block.size; + size_t remaining = block.size; + + while (pos < end) { char buffer[80]; size_t inst_size = LLVMDisasmInstruction(llvm_ctx, const_cast(pos), remaining, (u64)pos, buffer, sizeof(buffer)); ASSERT(inst_size); - for (CodePtr i = pos; i < pos + inst_size; i++) + for (const u8* i = pos; i < pos + inst_size; i++) result += fmt::format("{:02x} ", *i); for (size_t i = inst_size; i < 10; i++) result += " ";