void ParseExtraActivationFlags();
+void *AsanDlSymNext(const char *sym);
+
// Platform-specific options.
#if SANITIZER_MAC
bool PlatformHasDifferentMemcpyAndMemmove();
#include <sys/mman.h>
#include <sys/syscall.h>
#include <sys/types.h>
+#include <dlfcn.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdio.h>
extern "C" void* _DYNAMIC;
#else
#include <sys/ucontext.h>
-#include <dlfcn.h>
#include <link.h>
#endif
}
#endif
+void *AsanDlSymNext(const char *sym) {
+ return dlsym(RTLD_NEXT, sym);
+}
+
} // namespace __asan
#endif // SANITIZER_FREEBSD || SANITIZER_LINUX
WRAP(malloc), WRAP(free), WRAP(calloc), WRAP(realloc), WRAP(memalign)
};
-extern "C" const MallocDebug* __libc_malloc_dispatch;
-
namespace __asan {
void ReplaceSystemMalloc() {
- __libc_malloc_dispatch = &asan_malloc_dispatch;
+ const MallocDebug** __libc_malloc_dispatch_p;
+ __libc_malloc_dispatch_p =
+ (const MallocDebug **)AsanDlSymNext("__libc_malloc_dispatch");
+ if (__libc_malloc_dispatch_p)
+ *__libc_malloc_dispatch_p = &asan_malloc_dispatch;
}
} // namespace __asan
-#else // ANDROID
+#else // SANITIZER_ANDROID
namespace __asan {
void ReplaceSystemMalloc() {
}
} // namespace __asan
-#endif // ANDROID
+#endif // SANITIZER_ANDROID
// ---------------------- Replacement functions ---------------- {{{1
using namespace __asan; // NOLINT