[asan] Make ReplaceSystemMalloc optional on Android.
Don't fail if __libc_malloc_dispatch is missing; continue running with normal linux interceptors instead. llvm-svn: 210322
This commit is contained in:
@@ -98,6 +98,8 @@ void AppendToErrorMessageBuffer(const char *buffer);
|
||||
|
||||
void ParseExtraActivationFlags();
|
||||
|
||||
void *AsanDlSymNext(const char *sym);
|
||||
|
||||
// Platform-specific options.
|
||||
#if SANITIZER_MAC
|
||||
bool PlatformHasDifferentMemcpyAndMemmove();
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <sys/mman.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/types.h>
|
||||
#include <dlfcn.h>
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
@@ -42,7 +43,6 @@
|
||||
extern "C" void* _DYNAMIC;
|
||||
#else
|
||||
#include <sys/ucontext.h>
|
||||
#include <dlfcn.h>
|
||||
#include <link.h>
|
||||
#endif
|
||||
|
||||
@@ -243,6 +243,10 @@ void ReadContextStack(void *context, uptr *stack, uptr *ssize) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void *AsanDlSymNext(const char *sym) {
|
||||
return dlsym(RTLD_NEXT, sym);
|
||||
}
|
||||
|
||||
} // namespace __asan
|
||||
|
||||
#endif // SANITIZER_FREEBSD || SANITIZER_LINUX
|
||||
|
||||
@@ -42,21 +42,23 @@ const MallocDebug asan_malloc_dispatch ALIGNED(32) = {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user