summaryrefslogtreecommitdiff
path: root/lib/interception/tests
diff options
context:
space:
mode:
authorEtienne Bergeron <etienneb@google.com>2016-07-12 19:39:07 +0000
committerEtienne Bergeron <etienneb@google.com>2016-07-12 19:39:07 +0000
commitcb44d52112956de7705a894cde22483eafb33b54 (patch)
tree3091cf79a4c269aa4d13d1f4db7fa47e8326569f /lib/interception/tests
parent05cef4014c2a4637ec4324de325d8750f8aaeab1 (diff)
[asan] Fix interception unittest on Windows64.
mov edi,edi is _not_ NOP in 64-bit, use 66,90h instead. This bug was causing interception unittest to crash on Windows64 (windows 8 and windows 10). Credits to etienneb for finding the root cause. Patch by: Wei Wang Differential Revision: http://reviews.llvm.org/D22274 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275207 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/interception/tests')
-rw-r--r--lib/interception/tests/interception_win_test.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/interception/tests/interception_win_test.cc b/lib/interception/tests/interception_win_test.cc
index 642afd545..611354f03 100644
--- a/lib/interception/tests/interception_win_test.cc
+++ b/lib/interception/tests/interception_win_test.cc
@@ -234,8 +234,18 @@ static void LoadActiveCode(
// Add the detour instruction (i.e. mov edi, edi)
if (prefix_kind == FunctionPrefixDetour) {
+#if SANITIZER_WINDOWS64
+ // Note that "mov edi,edi" is NOP in 32-bit only, in 64-bit it clears
+ // higher bits of RDI.
+ // Use 66,90H as NOP for Windows64.
+ ActiveCode[position++] = 0x66;
+ ActiveCode[position++] = 0x90;
+#else
+ // mov edi,edi.
ActiveCode[position++] = 0x8B;
ActiveCode[position++] = 0xFF;
+#endif
+
}
// Copy the function body.