James Courtier-Dutton
2015-May-11 20:53 UTC
[LLVMdev] Possible regression in X86 Disassembler
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,
James Courtier-Dutton
2015-May-11 20:54 UTC
[LLVMdev] Possible regression in X86 Disassembler
On 11 May 2015 at 21:53, James Courtier-Dutton <james.dutton at gmail.com> wrote:> 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.This should be LLVM 3.6. I.e. the bug was introduced in LLVM 3.6, whereas it was fine in LLVM 3.5> 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,