Skip to content

Commit

Permalink
[tsan] Use REAL(malloc) instead of __libc_malloc for Android.
Browse files Browse the repository at this point in the history
Summary:
Android doesn't have __libc_malloc and related allocation
functions. As its dynamic linker doesn't use malloc, so
we can use REAL(malloc) to replace __libc_malloc safely.

Reviewers: kcc, eugenis, dvyukov

Subscribers: llvm-commits, tberghammer, danalbert, srhines

Differential Revision: http://reviews.llvm.org/D15297

llvm-svn: 255167
  • Loading branch information
yabinc committed Dec 9, 2015
1 parent 02b8e94 commit 4ddbe85
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
Expand Up @@ -48,6 +48,13 @@ using namespace __tsan; // NOLINT
#define __libc_realloc REAL(realloc)
#define __libc_calloc REAL(calloc)
#define __libc_free REAL(free)
#elif SANITIZER_ANDROID
#define __errno_location __errno
#define __libc_malloc REAL(malloc)
#define __libc_realloc REAL(realloc)
#define __libc_calloc REAL(calloc)
#define __libc_free REAL(free)
#define mallopt(a, b)
#endif

#if SANITIZER_LINUX || SANITIZER_FREEBSD
Expand Down Expand Up @@ -105,10 +112,12 @@ extern "C" void *pthread_self();
extern "C" void _exit(int status);
extern "C" int *__errno_location();
extern "C" int fileno_unlocked(void *stream);
#if !SANITIZER_ANDROID
extern "C" void *__libc_calloc(uptr size, uptr n);
extern "C" void *__libc_realloc(void *ptr, uptr size);
#endif
extern "C" int dirfd(void *dirp);
#if !SANITIZER_FREEBSD
#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID
extern "C" int mallopt(int param, int value);
#endif
extern __sanitizer_FILE *stdout, *stderr;
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/lib/tsan/rtl/tsan_new_delete.cc
Expand Up @@ -23,7 +23,7 @@ struct nothrow_t {};

DECLARE_REAL(void *, malloc, uptr size)
DECLARE_REAL(void, free, void *ptr)
#if SANITIZER_MAC
#if SANITIZER_MAC || SANITIZER_ANDROID
#define __libc_malloc REAL(malloc)
#define __libc_free REAL(free)
#endif
Expand Down

0 comments on commit 4ddbe85

Please sign in to comment.