Index: lib/asan/asan_malloc_linux.cc =================================================================== --- lib/asan/asan_malloc_linux.cc +++ lib/asan/asan_malloc_linux.cc @@ -114,6 +114,7 @@ return asan_malloc_usable_size(ptr, pc, bp); } +#if SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO // We avoid including malloc.h for portability reasons. // man mallinfo says the fields are "long", but the implementation uses int. // It doesn't matter much -- we just need to make sure that the libc's mallinfo @@ -131,6 +132,7 @@ INTERCEPTOR(int, mallopt, int cmd, int value) { return -1; } +#endif // SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO INTERCEPTOR(int, posix_memalign, void **memptr, uptr alignment, uptr size) { GET_STACK_TRACE_MALLOC; @@ -168,7 +170,9 @@ struct MallocDebugL { void *(*calloc)(uptr n_elements, uptr elem_size); void (*free)(void *mem); +#if SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO fake_mallinfo (*mallinfo)(void); +#endif // SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO void *(*malloc)(uptr bytes); uptr (*malloc_usable_size)(void *mem); void *(*memalign)(uptr alignment, uptr bytes); @@ -183,7 +187,10 @@ WRAP(realloc), WRAP(memalign), WRAP(malloc_usable_size)}; ALIGNED(32) const MallocDebugL asan_malloc_dispatch_l = { - WRAP(calloc), WRAP(free), WRAP(mallinfo), + WRAP(calloc), WRAP(free), +#if SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO + WRAP(mallinfo), +#endif // SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO WRAP(malloc), WRAP(malloc_usable_size), WRAP(memalign), WRAP(posix_memalign), WRAP(pvalloc), WRAP(realloc), WRAP(valloc)}; Index: lib/lsan/lsan_interceptors.cc =================================================================== --- lib/lsan/lsan_interceptors.cc +++ lib/lsan/lsan_interceptors.cc @@ -127,6 +127,7 @@ return GetMallocUsableSize(ptr); } +#if SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO struct fake_mallinfo { int x[10]; }; @@ -140,6 +141,7 @@ INTERCEPTOR(int, mallopt, int cmd, int value) { return -1; } +#endif // SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO INTERCEPTOR(void*, pvalloc, uptr size) { ENSURE_LSAN_INITED; @@ -286,8 +288,10 @@ INTERCEPT_FUNCTION(valloc); INTERCEPT_FUNCTION(pvalloc); INTERCEPT_FUNCTION(malloc_usable_size); +#if SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO INTERCEPT_FUNCTION(mallinfo); INTERCEPT_FUNCTION(mallopt); +#endif // SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO INTERCEPT_FUNCTION(pthread_create); INTERCEPT_FUNCTION(pthread_join); Index: lib/sanitizer_common/sanitizer_platform_interceptors.h =================================================================== --- lib/sanitizer_common/sanitizer_platform_interceptors.h +++ lib/sanitizer_common/sanitizer_platform_interceptors.h @@ -312,4 +312,6 @@ #define SANITIZER_INTERCEPT___XSTAT64 SI_LINUX_NOT_ANDROID #define SANITIZER_INTERCEPT___LXSTAT SANITIZER_INTERCEPT___XSTAT #define SANITIZER_INTERCEPT___LXSTAT64 SI_LINUX_NOT_ANDROID + +#define SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO (!SANITIZER_FREEBSD) #endif // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H Index: lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc =================================================================== --- lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc +++ lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc @@ -172,11 +172,13 @@ void malloc_usable_size() { } +#if SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO void mallinfo() { } void mallopt() { } +#endif // SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO } // extern "C" namespace std {