[llvm] r221751 - Pass an ArrayRef to MCDisassembler::getInstruction.

Rafael Espíndola rafael.espindola at gmail.com
Thu Nov 13 06:51:57 PST 2014


I will try to fix it and if possible write a test. Failing that, is it
possible to use trunk LLVM with otool via DYLD_LIBRARY_PATH?

On 12 November 2014 20:09, Kevin Enderby <enderby at apple.com> wrote:
> Hi Rafael,
>
> I found part of this change broke darwin’s otool(1) and its ability to
> symbolicate operands because the PC is no longer passed as
> getinstruction()’s Address parameter in the disassembler's ‘C’ API.  This
> eventually gets passed to the GetOpInfo() call back to look for relocation
> entries.  Since the PC is not correct it never finds the needed relocation
> entry to do the symbolication.
>
> Could you see the change below.  If PC is put back darwin’s otool(1) seems
> to work again.
>
> Kev
>
> P.S. Sorry there are no tests in the tree to check the disassembler ‘C’ API,
> we never figured out how to do that.
>
> On Nov 11, 2014, at 6:04 PM, Rafael Espindola <rafael.espindola at gmail.com>
> wrote:
>
> Modified: llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp?rev=221751&r1=221750&r2=221751&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp (original)
> +++ llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp Tue Nov 11 20:04:27
> 2014
> @@ -245,8 +245,7 @@ size_t LLVMDisasmInstruction(LLVMDisasmC
>                              size_t OutStringSize){
>   LLVMDisasmContext *DC = (LLVMDisasmContext *)DCR;
>   // Wrap the pointer to the Bytes, BytesSize and PC in a MemoryObject.
> -  StringRef Data((const char*) Bytes, BytesSize);
> -  StringRefMemoryObject MemoryObject(Data, PC);
> +  ArrayRef<uint8_t> Data(Bytes, BytesSize);
>
>   uint64_t Size;
>   MCInst Inst;
> @@ -255,7 +254,7 @@ size_t LLVMDisasmInstruction(LLVMDisasmC
>   MCDisassembler::DecodeStatus S;
>   SmallVector<char, 64> InsnStr;
>   raw_svector_ostream Annotations(InsnStr);
> -  S = DisAsm->getInstruction(Inst, Size, MemoryObject, PC,
> +  S = DisAsm->getInstruction(Inst, Size, Data, 0,
>
>
> The 0 above for the Address parameter should have remained PC.
>
>                              /*REMOVE*/ nulls(), Annotations);
>   switch (S) {
>   case MCDisassembler::Fail:
>
>




More information about the llvm-commits mailing list