[compiler-rt] r204929 - [sanitizer] Intercept __bzero on Mac.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Thu Mar 27 07:20:34 PDT 2014
Author: eugenis
Date: Thu Mar 27 09:20:34 2014
New Revision: 204929
URL: http://llvm.org/viewvc/llvm-project?rev=204929&view=rev
Log:
[sanitizer] Intercept __bzero on Mac.
This should make memset_test pass on Mac.
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/memset_test.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=204929&r1=204928&r2=204929&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Thu Mar 27 09:20:34 2014
@@ -3470,6 +3470,17 @@ INTERCEPTOR(void *, __aeabi_memclr8, voi
#define INIT_AEABI_MEM
#endif // SANITIZER_INTERCEPT_AEABI_MEM
+#if SANITIZER_INTERCEPT___BZERO
+DECLARE_REAL_AND_INTERCEPTOR(void *, memset, void *, int, uptr);
+
+INTERCEPTOR(void *, __bzero, void *block, uptr size) {
+ return WRAP(memset)(block, 0, size);
+}
+#define INIT___BZERO COMMON_INTERCEPT_FUNCTION(__bzero);
+#else
+#define INIT___BZERO
+#endif // SANITIZER_INTERCEPT___BZERO
+
#define SANITIZER_COMMON_INTERCEPTORS_INIT \
INIT_TEXTDOMAIN; \
INIT_STRCMP; \
@@ -3592,5 +3603,6 @@ INTERCEPTOR(void *, __aeabi_memclr8, voi
INIT_GETIFADDRS; \
INIT_IF_INDEXTONAME; \
INIT_CAPGET; \
- INIT_AEABI_MEM;
+ INIT_AEABI_MEM; \
+ INIT___BZERO;
/**/
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=204929&r1=204928&r2=204929&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h Thu Mar 27 09:20:34 2014
@@ -188,5 +188,6 @@
#define SANITIZER_INTERCEPT_IF_INDEXTONAME SI_LINUX_NOT_ANDROID || SI_MAC
#define SANITIZER_INTERCEPT_CAPGET SI_LINUX_NOT_ANDROID
#define SANITIZER_INTERCEPT_AEABI_MEM SI_LINUX && defined(__arm__)
+#define SANITIZER_INTERCEPT___BZERO SI_MAC
#endif // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H
Modified: compiler-rt/trunk/test/asan/TestCases/memset_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/memset_test.cc?rev=204929&r1=204928&r2=204929&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/memset_test.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/memset_test.cc Thu Mar 27 09:20:34 2014
@@ -47,11 +47,12 @@ int main(int argc, char **argv) {
#if defined(TEST_MEMCPY)
memcpy(q, p, 3000);
// CHECK-MEMCPY: AddressSanitizer: use-after-poison on address
- // CHECK-MEMCPY: in {{.*}}memcpy
+ // On Mac, memmove and memcpy are the same. Accept either one.
+ // CHECK-MEMCPY: in {{.*(memmove|memcpy)}}
#elif defined(TEST_MEMMOVE)
memmove(q, p, 3000);
// CHECK-MEMMOVE: AddressSanitizer: use-after-poison on address
- // CHECK-MEMMOVE: in {{.*}}memmove
+ // CHECK-MEMMOVE: in {{.*(memmove|memcpy)}}
#endif
assert(q[1] == 0);
free(q);
More information about the llvm-commits
mailing list