From: Andrew Ng Date: Wed, 27 Jan 2021 16:47:21 +0000 (+0000) Subject: [X86] Fix disassembly of x86-64 GDTLS code sequence X-Git-Tag: llvmorg-14-init~16301 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=94fedd266125a5425aa33e11332bf414f0b6dc35;p=platform%2Fupstream%2Fllvm.git [X86] Fix disassembly of x86-64 GDTLS code sequence 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. Differential Revision: https://reviews.llvm.org/D95682 --- diff --git a/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp b/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp index 05e482a..4e6d8e8 100644 --- a/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp +++ b/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp @@ -492,6 +492,7 @@ static int readPrefixes(struct InternalInstruction *insn) { 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); diff --git a/llvm/test/MC/Disassembler/X86/x86-64.txt b/llvm/test/MC/Disassembler/X86/x86-64.txt index d91ef25..5e56d4c 100644 --- a/llvm/test/MC/Disassembler/X86/x86-64.txt +++ b/llvm/test/MC/Disassembler/X86/x86-64.txt @@ -329,8 +329,10 @@ # CHECK: callw 32767 0x66 0xe8 0xff 0x7f -# CHECK: callw 32767 -0x66 0x66 0x48 0xe8 0xff 0x7f +# TODO: Should display data16 prefixes. +# CHECK-NOT: data16 +# CHECK: callq 32767 +0x66 0x66 0x48 0xe8 0xff 0x7f 0x00 0x00 # CHECK: jmp -32769 0xe9 0xff 0x7f 0xff 0xff @@ -338,8 +340,10 @@ # CHECK: jmp 32767 0x66 0xe9 0xff 0x7f +# TODO: Should display data16 prefixes. +# CHECK-NOT: data16 # 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 diff --git a/llvm/test/tools/llvm-objdump/X86/disassemble-gdtls.s b/llvm/test/tools/llvm-objdump/X86/disassemble-gdtls.s new file mode 100644 index 0000000..e913f5f --- /dev/null +++ b/llvm/test/tools/llvm-objdump/X86/disassemble-gdtls.s @@ -0,0 +1,19 @@ +# RUN: llvm-mc %s -filetype=obj -triple=x86_64 | llvm-objdump -d - | FileCheck %s + +# CHECK: : +# TODO: Should display data16 prefixes. +# CHECK-NEXT: 0: 66 48 8d 3d 00 00 00 00 leaq (%rip), %rdi # 8 +# CHECK-NEXT: 8: 66 66 48 e8 00 00 00 00 callq 0x10 +# CHECK-EMPTY: + +PR48901: + data16 + leaq bar@TLSGD(%rip),%rdi + data16 + data16 + rex64 + callq __tls_get_addr@PLT + +.section .tdata,"awT",@progbits +bar: +.long 42