summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEtienne Bergeron <etienneb@google.com>2016-07-14 22:29:22 +0000
committerEtienne Bergeron <etienneb@google.com>2016-07-14 22:29:22 +0000
commit48ccea3ee6b4f48ab17a4753694c1d1f39ce5525 (patch)
treef8e628c2b7106fb5768d6707e4229840d5637a19
parent552ecd1efb3769478909dd71f821c01d54bdfde5 (diff)
downloadcompiler-rt-48ccea3ee6b4f48ab17a4753694c1d1f39ce5525.tar.gz
[asan] Avoid hooking memchr() on Windows64
There is not enough padding in front of memchr(), and, the first 6 bytes contains a branch instruction. Basically the current interception will not work on memchr(). It was disabled before, but was missing the part to disable it for INTERCEPT_LIBRARY_FUNCTION. Patch by Wei Wang Differential Revision: https://reviews.llvm.org/D22371 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275494 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/asan/asan_win_dll_thunk.cc3
-rw-r--r--lib/sanitizer_common/sanitizer_platform_interceptors.h3
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/asan/asan_win_dll_thunk.cc b/lib/asan/asan_win_dll_thunk.cc
index eff00f9f9..725ead1ac 100644
--- a/lib/asan/asan_win_dll_thunk.cc
+++ b/lib/asan/asan_win_dll_thunk.cc
@@ -21,6 +21,7 @@
#ifdef ASAN_DLL_THUNK
#include "asan_init_version.h"
#include "interception/interception.h"
+#include "sanitizer_common/sanitizer_platform_interceptors.h"
// ---------- Function interception helper functions and macros ----------- {{{1
extern "C" {
@@ -390,7 +391,9 @@ INTERCEPTOR(int, _except_handler4, void *a, void *b, void *c, void *d) {
INTERCEPT_LIBRARY_FUNCTION(frexp);
INTERCEPT_LIBRARY_FUNCTION(longjmp);
+#if SANITIZER_INTERCEPT_MEMCHR
INTERCEPT_LIBRARY_FUNCTION(memchr);
+#endif
INTERCEPT_LIBRARY_FUNCTION(memcmp);
INTERCEPT_LIBRARY_FUNCTION(memcpy);
INTERCEPT_LIBRARY_FUNCTION(memmove);
diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h
index 27233eeff..0e70a1800 100644
--- a/lib/sanitizer_common/sanitizer_platform_interceptors.h
+++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h
@@ -83,10 +83,9 @@
#define SANITIZER_INTERCEPT_MEMMOVE 1
#define SANITIZER_INTERCEPT_MEMCPY 1
#define SANITIZER_INTERCEPT_MEMCMP 1
-// TODO(wwchrome): Re-enable intercepting memchr() when ready.
// The function memchr() contains a jump in the first 6 bytes
// that is problematic to intercept correctly on Win64.
-// Disable memchr() interception for Win64 temporarily.
+// Disable memchr() interception for Win64.
#if SANITIZER_WINDOWS64
#define SANITIZER_INTERCEPT_MEMCHR 0
#else