Bug ID 26248
Summary Disassembly incorrect for x64 RIP-relative
Product lldb
Version 3.4
Hardware Macintosh
OS MacOS X
Status NEW
Severity normal
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter mhop@microsoft.com
CC llvm-bugs@lists.llvm.org
Classification Unclassified
Created attachment 15687 [details]
Program demonstrates incorrect disassembly for x64 RIP relative.
The disassemble command for x64 RIP relative addressing modes displays the
wrong disassembly. As an example, the byte sequence
49 8b 05 78 56 34 12
disassembles to three instructions like
(lldb) di -c3 -b -s &a
0x7fff5fbff740: 49 8b 05 movq (%r13), %rax
0x7fff5fbff743: 78 56 js 0x7fff5fbff79b
0x7fff5fbff745: 34 12 xorb $0x12, %al
when it should produce a single instruction like
0x7fff5fbff740: 49 8b 05 78 56 34 12 movq (%rip + 12345679), %rax
I've attached a small C++ program to demonstrate the problem in the debugger.
The program just declares an array to hold the byte sequence above and then
prints out instructions to copy/paste into the LLDB. Here are the instructions
from the attached program (note that g++ on the Mac maps to LLVM).
REPRO STEPS:
g++ -g lldb-disassemble-rip.cxx
lldb a.out
breakpoint set -f lldb-disassemble-rip.cxx -l 7
r
di -c3 -b -s &a
EXPECT:
Something like
(lldb) di -c3 -b -s &a
0x7fff5fbff740: 49 8b 05 78 56 34 12 movq (%rip + 12345679), %rax
OBSERVE:
Something like
(lldb) di -c3 -b -s &a
0x7fff5fbff740: 49 8b 05 movq (%r13), %rax
0x7fff5fbff743: 78 56 js 0x7fff5fbff79b
0x7fff5fbff745: 34 12 xorb $0x12, %al
I am seeing this problem on Mac OS X Yosemite Version 10.10.5 with
lldb-340.4.110.1.
This bug may be more impactful than incorrect output if it prevents lldb from
single stepping. In order to test whether lldb single stepping is broken, one
would need an example with the correct stack unwinding provisions.