[LLVMdev] Possible regression in X86 Disassembler

James Courtier-Dutton james.dutton at gmail.com
Mon May 11 13:53:05 PDT 2015


Hi,

I have a program that uses LLVM as a disassembler.
When using LLVM 3.5 I could pass "getInstruction" a byte pointer and
and address. The address was the offset within the bytes to start
disassembling at.

With LLVM 3.5, this changed. the use of a Region was used.
But it seems to be incorrectly used. with address being used to set
the base of the region.
This means that when calling the "getInstruction" method, I now have
to call it with the byte pointer already having had the offset added,
and instead set the address offset to zero.

Please see below where I think the bug is, and how to fix it.

Kind Regards

James



diff --git a/lib/Target/X86/Disassembler/X86Disassembler.cpp
b/lib/Target/X86/Disassembler/X86Disassembler.cpp
index 1c56182..4a9774e 100644
--- a/lib/Target/X86/Disassembler/X86Disassembler.cpp
+++ b/lib/Target/X86/Disassembler/X86Disassembler.cpp
@@ -147,7 +147,7 @@ MCDisassembler::DecodeStatus
X86GenericDisassembler::getInstruction(
   if (&VStream == &nulls())
     LoggerFn = nullptr; // Disable logging completely if it's going to nulls().

-  Region R(Bytes, Address);
+  Region R(Bytes, 0);

   int Ret = decodeInstruction(&InternalInstr, regionReader, (const void *)&R,
                               LoggerFn, (void *)&VStream,



More information about the llvm-dev mailing list