[PATCH] D95682: [X86] Fix disassembly of x86-64 GDTLS code sequence
Andrew Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 29 07:14:24 PST 2021
andrewng created this revision.
andrewng added reviewers: craig.topper, MaskRay.
Herald added subscribers: pengfei, rupprecht, hiraditya.
Herald added a reviewer: jhenderson.
andrewng requested review of this revision.
Herald added a project: LLVM.
For x86-64 the REX.w prefix takes precedence over any other size
override (i.e. 0x66). Therefore, for x86-64 when REX.w is present set
'hasOpSize' to false to ensure that any size override is ignored.
Fixes PR48901.
https://reviews.llvm.org/D95682
Files:
llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp
llvm/test/MC/Disassembler/X86/x86-64.txt
llvm/test/tools/llvm-objdump/X86/disassemble-gdtls.s
Index: llvm/test/tools/llvm-objdump/X86/disassemble-gdtls.s
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-objdump/X86/disassemble-gdtls.s
@@ -0,0 +1,18 @@
+# RUN: llvm-mc %s -filetype=obj -triple=x86_64-pc-linux | llvm-objdump -d - | FileCheck %s
+
+# CHECK: <foo>:
+# CHECK-NEXT: 0: 66 48 8d 3d 00 00 00 00 leaq (%rip), %rdi # 8 <foo+0x8>
+# CHECK-NEXT: 8: 66 66 48 e8 00 00 00 00 callq 0x10 <foo+0x10>
+# CHECK-EMPTY:
+
+foo:
+ data16
+ leaq bar at TLSGD(%rip),%rdi
+ data16
+ data16
+ rex64
+ callq __tls_get_addr at PLT
+
+.section .tdata,"awT", at progbits
+bar:
+.long 42
Index: llvm/test/MC/Disassembler/X86/x86-64.txt
===================================================================
--- llvm/test/MC/Disassembler/X86/x86-64.txt
+++ llvm/test/MC/Disassembler/X86/x86-64.txt
@@ -329,8 +329,8 @@
# CHECK: callw 32767
0x66 0xe8 0xff 0x7f
-# CHECK: callw 32767
-0x66 0x66 0x48 0xe8 0xff 0x7f
+# CHECK: callq 32767
+0x66 0x66 0x48 0xe8 0xff 0x7f 0x00 0x00
# CHECK: jmp -32769
0xe9 0xff 0x7f 0xff 0xff
@@ -339,7 +339,7 @@
0x66 0xe9 0xff 0x7f
# CHECK: jmp 32767
-0x66 0x66 0x48 0xe9 0xff 0x7f
+0x66 0x66 0x48 0xe9 0xff 0x7f 0x00 0x00
# CHECK: jo -32769
0x0f 0x80 0xff 0x7f 0xff 0xff
Index: llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp
===================================================================
--- llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp
+++ llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp
@@ -492,6 +492,7 @@
insn->addressSize = (insn->hasAdSize ? 4 : 8);
insn->displacementSize = 4;
insn->immediateSize = 4;
+ insn->hasOpSize = false;
} else {
insn->registerSize = (insn->hasOpSize ? 2 : 4);
insn->addressSize = (insn->hasAdSize ? 4 : 8);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95682.320127.patch
Type: text/x-patch
Size: 1818 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210129/19fd94b0/attachment.bin>
More information about the llvm-commits
mailing list