summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc
diff options
context:
space:
mode:
authorDimitry Andric <dimitry@andric.com>2017-01-27 22:19:11 +0000
committerDimitry Andric <dimitry@andric.com>2017-01-27 22:19:11 +0000
commit47e0ef31483f99469fe3e3e67a21f061cb6e007b (patch)
tree24451bca960a426e00f2e41ecf17e0c7c9728a3f /compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc
parent9d0eb9960c7e39048de3eabd7e9c96b82b3a7bab (diff)
downloadbcm5719-llvm-47e0ef31483f99469fe3e3e67a21f061cb6e007b.tar.gz
bcm5719-llvm-47e0ef31483f99469fe3e3e67a21f061cb6e007b.zip
Stop intercepting some malloc-related functions on FreeBSD and macOS
Summary: In https://bugs.freebsd.org/215125 I was notified that some configure scripts attempt to test for the Linux-specific `mallinfo` and `mallopt` functions by compiling and linking small programs which references the functions, and observing whether that results in errors. FreeBSD and macOS do not have the `mallinfo` and `mallopt` functions, so normally these tests would fail, but when sanitizers are enabled, they incorrectly succeed, because the sanitizers define interceptors for these functions. This also applies to some other malloc-related functions, such as `memalign`, `pvalloc` and `cfree`. Fix this by not intercepting `mallinfo`, `mallopt`, `memalign`, `pvalloc` and `cfree` for FreeBSD and macOS, in all sanitizers. Reviewers: emaste, kcc Subscribers: hans, joerg, llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D27654 llvm-svn: 293337
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc')
-rw-r--r--compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc
index c6dd3c4bb20..d2920d8f7f6 100644
--- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc
+++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc
@@ -139,6 +139,7 @@ void *realloc(void *p, size_t size) {
return p;
}
+#if SANITIZER_INTERCEPT_MEMALIGN
void *memalign(size_t alignment, size_t size) {
if (UNLIKELY(!thread_inited))
thread_init();
@@ -146,6 +147,7 @@ void *memalign(size_t alignment, size_t size) {
SANITIZER_MALLOC_HOOK(p, size);
return p;
}
+#endif // SANITIZER_INTERCEPT_MEMALIGN
int posix_memalign(void **memptr, size_t alignment, size_t size) {
if (UNLIKELY(!thread_inited))
@@ -165,18 +167,26 @@ void *valloc(size_t size) {
return p;
}
+#if SANITIZER_INTERCEPT_CFREE
void cfree(void *p) ALIAS("free");
+#endif // SANITIZER_INTERCEPT_CFREE
+#if SANITIZER_INTERCEPT_PVALLOC
void *pvalloc(size_t size) ALIAS("valloc");
+#endif // SANITIZER_INTERCEPT_PVALLOC
+#if SANITIZER_INTERCEPT_MEMALIGN
void *__libc_memalign(size_t alignment, size_t size) ALIAS("memalign");
+#endif // SANITIZER_INTERCEPT_MEMALIGN
void malloc_usable_size() {
}
+#if SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO
void mallinfo() {
}
void mallopt() {
}
+#endif // SANITIZER_INTERCEPT_MALLOPT_AND_MALLINFO
} // extern "C"
namespace std {
OpenPOWER on IntegriCloud