diff options
author | Jim Stichnoth <stichnot@chromium.org> | 2013-06-19 13:00:35 -0700 |
---|---|---|
committer | Jim Stichnoth <stichnot@chromium.org> | 2013-06-19 13:00:35 -0700 |
commit | bce9cade729651fdddd9852d0467e0cd7476a54f (patch) | |
tree | 2aae4087eae2a19e8d705a8cef6a2d6e9dc3692e | |
parent | 8cbf33322a220878bba45b8c7977e69b1ca348d4 (diff) |
Fix an x86-64 fast-isel address calculation overflow.
Disallow large displacements in NaCl addressing modes, by
rejecting the fast-isel selection and using the logic in the
DAG-based isel.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3502
R=dschuff@chromium.org
Review URL: https://codereview.chromium.org/16959013
-rw-r--r-- | lib/Target/X86/X86FastISel.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp index df3b87942a..a4d6df8fe1 100644 --- a/lib/Target/X86/X86FastISel.cpp +++ b/lib/Target/X86/X86FastISel.cpp @@ -405,6 +405,18 @@ static bool isLegalAddressingModeForNaCl(const X86Subtarget *Subtarget, ++NumFastIselNaClFailures; return false; } + + // See X86DAGToDAGISel::FoldOffsetIntoAddress(). + // Check for the equivalent of + // ((AM.BaseType == X86ISelAddressMode::RegBase || + // AM.BaseType == X86ISelAddressMode::FrameIndexBase) && + // (Val > 65535 || Val < -65536)) + if ((AM.BaseType == X86AddressMode::RegBase || + AM.BaseType == X86AddressMode::FrameIndexBase) && + (AM.Disp > 65535 || AM.Disp < -65536)) { + ++NumFastIselNaClFailures; + return false; + } } return true; |