[llvm-commits] [llvm] r160694 - /llvm/trunk/lib/Target/X86/Disassembler/X86Disassembler.cpp

Kevin Enderby enderby at apple.com
Tue Jul 24 14:55:01 PDT 2012


Love to have a test case but I don't think we have any LLVM tools that use the LLVM symbolic dissembler interface (yet).  So I don't have a test case.  But the change is actually pretty obvious as it was a copy and paste error.  The copy was likely done from translateRMMemory() that uses displacements and incorrectly pasted into translateImmediate() uses immediates.  And their are other places in translateImmediate() was correctly setting pcrel variable using the immediateOffset and immediateSize from the insn so once I found the fix it was actually "obvious".

The lldb code is where this was actual run into and maybe a test case could be created there.

Kev

On Jul 24, 2012, at 2:46 PM, Jim Grosbach wrote:

> Coolness.
> 
> That said, test case? :)
> 
> On Jul 24, 2012, at 2:40 PM, Kevin Enderby <enderby at apple.com> wrote:
> 
>> Author: enderby
>> Date: Tue Jul 24 16:40:01 2012
>> New Revision: 160694
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=160694&view=rev
>> Log:
>> Fix a bug in the x86 disassembler's symbolic disassembly support for Jcc-Jump
>> if Condition Is Met instuctions that was not correctly determining the target
>> instruction.
>> 
>> So for a jne rel32 instruction:
>> 
>> % cat x.s
>> .byte 0x0f, 0x85, 0x09, 0x00, 0x00, 0x00
>> % as x.s
>> 
>> it was incorrectly deterining the target:
>> 
>> % otool -q -tv a.out 
>> a.out:
>> (__TEXT,__text) section
>> 0000000000000000	jne	0xd
>> 
>> and with the fix it gets this correct as:
>> 
>> % otool -q -tv a.out
>> a.out:
>> (__TEXT,__text) section
>> 0000000000000000	jne	0xf
>> 
>> rdar://11505997
>> 
>> Modified:
>>   llvm/trunk/lib/Target/X86/Disassembler/X86Disassembler.cpp
>> 
>> Modified: llvm/trunk/lib/Target/X86/Disassembler/X86Disassembler.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Disassembler/X86Disassembler.cpp?rev=160694&r1=160693&r2=160694&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Target/X86/Disassembler/X86Disassembler.cpp (original)
>> +++ llvm/trunk/lib/Target/X86/Disassembler/X86Disassembler.cpp Tue Jul 24 16:40:01 2012
>> @@ -327,7 +327,7 @@
>>  if (type == TYPE_RELv) {
>>    isBranch = true;
>>    pcrel = insn.startLocation +
>> -            insn.displacementOffset + insn.displacementSize;
>> +            insn.immediateOffset + insn.immediateSize;
>>    switch (insn.displacementSize) {
>>    default:
>>      break;
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 




More information about the llvm-commits mailing list