Skip to content

Commit

Permalink
[X86] Don't allow gather/scatter to disassembler if memory operand do…
Browse files Browse the repository at this point in the history
…es not use a SIB byte.

Fixes PR34998.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316282 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
topperc committed Oct 22, 2017
1 parent 7f2ed03 commit 7447532
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Target/X86/Disassembler/X86DisassemblerDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions test/MC/Disassembler/X86/gather-novsib.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7447532

Please sign in to comment.