[sanitizer] Intercept __bzero on Mac.

This should make memset_test pass on Mac.

llvm-svn: 204929
This commit is contained in:
Evgeniy Stepanov 2014-03-27 14:20:34 +00:00
parent be648a3c16
commit a6eb1bb59e
3 changed files with 17 additions and 3 deletions

View File

@ -3470,6 +3470,17 @@ INTERCEPTOR(void *, __aeabi_memclr8, void *block, uptr size) {
#define INIT_AEABI_MEM #define INIT_AEABI_MEM
#endif // SANITIZER_INTERCEPT_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 \ #define SANITIZER_COMMON_INTERCEPTORS_INIT \
INIT_TEXTDOMAIN; \ INIT_TEXTDOMAIN; \
INIT_STRCMP; \ INIT_STRCMP; \
@ -3592,5 +3603,6 @@ INTERCEPTOR(void *, __aeabi_memclr8, void *block, uptr size) {
INIT_GETIFADDRS; \ INIT_GETIFADDRS; \
INIT_IF_INDEXTONAME; \ INIT_IF_INDEXTONAME; \
INIT_CAPGET; \ INIT_CAPGET; \
INIT_AEABI_MEM; INIT_AEABI_MEM; \
INIT___BZERO;
/**/ /**/

View File

@ -188,5 +188,6 @@
#define SANITIZER_INTERCEPT_IF_INDEXTONAME SI_LINUX_NOT_ANDROID || SI_MAC #define SANITIZER_INTERCEPT_IF_INDEXTONAME SI_LINUX_NOT_ANDROID || SI_MAC
#define SANITIZER_INTERCEPT_CAPGET SI_LINUX_NOT_ANDROID #define SANITIZER_INTERCEPT_CAPGET SI_LINUX_NOT_ANDROID
#define SANITIZER_INTERCEPT_AEABI_MEM SI_LINUX && defined(__arm__) #define SANITIZER_INTERCEPT_AEABI_MEM SI_LINUX && defined(__arm__)
#define SANITIZER_INTERCEPT___BZERO SI_MAC
#endif // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H #endif // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H

View File

@ -47,11 +47,12 @@ int main(int argc, char **argv) {
#if defined(TEST_MEMCPY) #if defined(TEST_MEMCPY)
memcpy(q, p, 3000); memcpy(q, p, 3000);
// CHECK-MEMCPY: AddressSanitizer: use-after-poison on address // 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) #elif defined(TEST_MEMMOVE)
memmove(q, p, 3000); memmove(q, p, 3000);
// CHECK-MEMMOVE: AddressSanitizer: use-after-poison on address // CHECK-MEMMOVE: AddressSanitizer: use-after-poison on address
// CHECK-MEMMOVE: in {{.*}}memmove // CHECK-MEMMOVE: in {{.*(memmove|memcpy)}}
#endif #endif
assert(q[1] == 0); assert(q[1] == 0);
free(q); free(q);