summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/lsan/lsan_common.h
diff options
context:
space:
mode:
authorMaxim Ostapenko <chefmax7@gmail.com>2017-04-11 14:58:26 +0000
committerMaxim Ostapenko <chefmax7@gmail.com>2017-04-11 14:58:26 +0000
commitde3b9a2ecc7e9ebe3fc1780aede0223821c52d2a (patch)
tree0fabd59de3a5b0fa9ed530fd33b6c0a65468df72 /compiler-rt/lib/lsan/lsan_common.h
parente1f12fadc0ce37def3fbf99373f315a3667c4766 (diff)
downloadbcm5719-llvm-de3b9a2ecc7e9ebe3fc1780aede0223821c52d2a.tar.gz
bcm5719-llvm-de3b9a2ecc7e9ebe3fc1780aede0223821c52d2a.zip
Reapply "Enable LSan for arm Linux"
This patch reapplies r299923 with typo fixed in BLX macros. llvm-svn: 299948
Diffstat (limited to 'compiler-rt/lib/lsan/lsan_common.h')
-rw-r--r--compiler-rt/lib/lsan/lsan_common.h34
1 files changed, 30 insertions, 4 deletions
diff --git a/compiler-rt/lib/lsan/lsan_common.h b/compiler-rt/lib/lsan/lsan_common.h
index 082492dec2f..2851a6672d2 100644
--- a/compiler-rt/lib/lsan/lsan_common.h
+++ b/compiler-rt/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.
OpenPOWER on IntegriCloud