From: Craig Topper Date: Sun, 22 Oct 2017 04:32:30 +0000 (+0000) Subject: [X86] Don't allow gather/scatter to disassembler if memory operand does not use a... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=158bc6474a5192bb42e8d03944ad0b689e6e2d56;p=platform%2Fupstream%2Fllvm.git [X86] Don't allow gather/scatter to disassembler if memory operand does not use a SIB byte. Fixes PR34998. llvm-svn: 316282 --- diff --git a/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp b/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp index 6884f2a..e781c98 100644 --- a/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp +++ b/llvm/lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp @@ -1723,6 +1723,10 @@ static int readOperands(struct InternalInstruction* insn) { if (readModRM(insn)) return -1; + // Reject if SIB wasn't used. + if (insn->eaBase != EA_BASE_sib && insn->eaBase != EA_BASE_sib64) + return -1; + // If sibIndex was set to SIB_INDEX_NONE, index offset is 4. if (insn->sibIndex == SIB_INDEX_NONE) insn->sibIndex = (SIBIndex)4; diff --git a/llvm/test/MC/Disassembler/X86/gather-novsib.txt b/llvm/test/MC/Disassembler/X86/gather-novsib.txt new file mode 100644 index 0000000..d14abc1 --- /dev/null +++ b/llvm/test/MC/Disassembler/X86/gather-novsib.txt @@ -0,0 +1,4 @@ +# RUN: llvm-mc --disassemble %s -triple=x86_64-apple-darwin9 2>&1 | grep "invalid instruction encoding" + +// This corresponds to a gather, but doesn't use a SIB byte. +0xc4,0xe2,0xe9,0x92,0x08