diff options
author | Maxim Ostapenko <chefmax7@gmail.com> | 2017-04-11 08:13:38 +0000 |
---|---|---|
committer | Maxim Ostapenko <chefmax7@gmail.com> | 2017-04-11 08:13:38 +0000 |
commit | 77094f117908a9b2f3b2cb4ebe5dbf6c744a851d (patch) | |
tree | dfb7edbdacf51c1c19728eeec5dce0d8e4f90840 /lib/lsan/lsan_common.h | |
parent | 769089a0ba7eaefe9d6670fa2c49850e50151364 (diff) |
[lsan] Enable LSan for arm Linux
This patch enables LSan for arm Linux.
Differential Revision: https://reviews.llvm.org/D29586
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@299923 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/lsan/lsan_common.h')
-rw-r--r-- | lib/lsan/lsan_common.h | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/lib/lsan/lsan_common.h b/lib/lsan/lsan_common.h index 082492dec..2851a6672 100644 --- a/lib/lsan/lsan_common.h +++ b/lib/lsan/lsan_common.h @@ -37,6 +37,9 @@ #elif defined(__i386__) && \ (SANITIZER_LINUX && !SANITIZER_ANDROID || SANITIZER_MAC) #define CAN_SANITIZE_LEAKS 1 +#elif defined(__arm__) && \ + SANITIZER_LINUX && !SANITIZER_ANDROID +#define CAN_SANITIZE_LEAKS 1 #else #define CAN_SANITIZE_LEAKS 0 #endif @@ -144,13 +147,36 @@ struct ScopedInterceptorDisabler { ~ScopedInterceptorDisabler() { EnableInThisThread(); } }; +// According to Itanium C++ ABI array cookie is a one word containing +// size of allocated array. +static inline bool IsItaniumABIArrayCookie(uptr chunk_beg, uptr chunk_size, + uptr addr) { + return chunk_size == sizeof(uptr) && chunk_beg + chunk_size == addr && + *reinterpret_cast<uptr *>(chunk_beg) == 0; +} + +// According to ARM C++ ABI array cookie consists of two words: +// struct array_cookie { +// std::size_t element_size; // element_size != 0 +// std::size_t element_count; +// }; +static inline bool IsARMABIArrayCookie(uptr chunk_beg, uptr chunk_size, + uptr addr) { + return chunk_size == 2 * sizeof(uptr) && chunk_beg + chunk_size == addr && + *reinterpret_cast<uptr *>(chunk_beg + sizeof(uptr)) == 0; +} + // Special case for "new T[0]" where T is a type with DTOR. -// new T[0] will allocate one word for the array size (0) and store a pointer -// to the end of allocated chunk. +// new T[0] will allocate a cookie (one or two words) for the array size (0) +// and store a pointer to the end of allocated chunk. The actual cookie layout +// varies between platforms according to their C++ ABI implementation. inline bool IsSpecialCaseOfOperatorNew0(uptr chunk_beg, uptr chunk_size, uptr addr) { - return chunk_size == sizeof(uptr) && chunk_beg + chunk_size == addr && - *reinterpret_cast<uptr *>(chunk_beg) == 0; +#if defined(__arm__) + return IsARMABIArrayCookie(chunk_beg, chunk_size, addr); +#else + return IsItaniumABIArrayCookie(chunk_beg, chunk_size, addr); +#endif } // The following must be implemented in the parent tool. |