[compiler-rt] r276324 - [compiler-rt] Fix interception of memcpy/memmove on win64
Etienne Bergeron via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 21 12:49:11 PDT 2016
Author: etienneb
Date: Thu Jul 21 14:49:11 2016
New Revision: 276324
URL: http://llvm.org/viewvc/llvm-project?rev=276324&view=rev
Log:
[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
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
compiler-rt/trunk/test/asan/TestCases/Windows/intercept_memcpy.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc?rev=276324&r1=276323&r2=276324&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Thu Jul 21 14:49:11 2016
@@ -663,7 +663,12 @@ INTERCEPTOR(void*, memchr, const void *s
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;
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h?rev=276324&r1=276323&r2=276324&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h Thu Jul 21 14:49:11 2016
@@ -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
Modified: compiler-rt/trunk/test/asan/TestCases/Windows/intercept_memcpy.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Windows/intercept_memcpy.cc?rev=276324&r1=276323&r2=276324&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/intercept_memcpy.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Windows/intercept_memcpy.cc Thu Jul 21 14:49:11 2016
@@ -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
More information about the llvm-commits
mailing list