diff options
author | Etienne Bergeron <etienneb@google.com> | 2016-07-21 19:49:11 +0000 |
---|---|---|
committer | Etienne Bergeron <etienneb@google.com> | 2016-07-21 19:49:11 +0000 |
commit | 9a0088df015da1d02b7d85b901c24128096d7931 (patch) | |
tree | 025cae01ae8c969196ae9e90d4fdf6ef5b693f7b | |
parent | 52ee88fd9cb9eaadfb9e8a6b460b57c2e25cb95d (diff) |
[compiler-rt] Fix interception of memcpy/memmove on win64
Summary:
This patch is fixing running interception unittests for memcpy/memmove on
windows 64.
Reviewers: rnk
Subscribers: llvm-commits, wang0109, kubabrecka, chrisha
Differential Revision: https://reviews.llvm.org/D22641
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276324 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/sanitizer_common/sanitizer_common_interceptors.inc | 7 | ||||
-rw-r--r-- | lib/sanitizer_common/sanitizer_platform_interceptors.h | 7 | ||||
-rw-r--r-- | test/asan/TestCases/Windows/intercept_memcpy.cc | 4 |
3 files changed, 8 insertions, 10 deletions
diff --git a/lib/sanitizer_common/sanitizer_common_interceptors.inc b/lib/sanitizer_common/sanitizer_common_interceptors.inc index ae1a78471..3660f6b8b 100644 --- a/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -663,7 +663,12 @@ INTERCEPTOR(void*, memchr, const void *s, int c, SIZE_T n) { return internal_memchr(s, c, n); void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, memchr, s, c, n); - void *res = REAL(memchr)(s, c, n); + void *res; + if (REAL(memchr)) { + res = REAL(memchr)(s, c, n); + } else { + res = internal_memchr(s, c, n); + } uptr len = res ? (char *)res - (const char *)s + 1 : n; COMMON_INTERCEPTOR_READ_RANGE(ctx, s, len); return res; diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h index a4afc0f12..1e53dd163 100644 --- a/lib/sanitizer_common/sanitizer_platform_interceptors.h +++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h @@ -85,14 +85,7 @@ #define SANITIZER_INTERCEPT_MEMCMP 1 // FIXME: enable memmem on Windows. #define SANITIZER_INTERCEPT_MEMMEM SI_NOT_WINDOWS -// The function memchr() contains a jump in the first 6 bytes -// that is problematic to intercept correctly on Win64. -// Disable memchr() interception for Win64. -#if SANITIZER_WINDOWS64 -#define SANITIZER_INTERCEPT_MEMCHR 0 -#else #define SANITIZER_INTERCEPT_MEMCHR 1 -#endif #define SANITIZER_INTERCEPT_MEMRCHR SI_FREEBSD || SI_LINUX #define SANITIZER_INTERCEPT_READ SI_NOT_WINDOWS diff --git a/test/asan/TestCases/Windows/intercept_memcpy.cc b/test/asan/TestCases/Windows/intercept_memcpy.cc index 9ee984b18..6e45e7fc6 100644 --- a/test/asan/TestCases/Windows/intercept_memcpy.cc +++ b/test/asan/TestCases/Windows/intercept_memcpy.cc @@ -22,8 +22,8 @@ int main() { call_memcpy(&memcpy, buff2, buff1, 6); // CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] // CHECK: WRITE of size 6 at [[ADDR]] thread T0 -// CHECK-NEXT: __asan_{{.*}}memcpy -// CHECK-NEXT: call_memcpy +// CHECK-NEXT: __asan_{{.*}}mem{{.*}} +// CHECK-NEXT: call_mem{{.*}} // CHECK-NEXT: main {{.*}}intercept_memcpy.cc:[[@LINE-5]] // CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame // CHECK-NEXT: #0 {{.*}} main |