summaryrefslogtreecommitdiffstats
path: root/compiler-rt
diff options
context:
space:
mode:
authorKostya Kortchinsky <kostyak@google.com>2018-04-13 19:21:27 +0000
committerKostya Kortchinsky <kostyak@google.com>2018-04-13 19:21:27 +0000
commit4563b78b99f8677eccf839a852bc10ab2fdfc9b6 (patch)
tree6db18ca7c9383443085d703f0686ca8a6f428d86 /compiler-rt
parent3ede11b58cf5e71ce8a9e664587ee01325365ff4 (diff)
downloadbcm5719-llvm-4563b78b99f8677eccf839a852bc10ab2fdfc9b6.tar.gz
bcm5719-llvm-4563b78b99f8677eccf839a852bc10ab2fdfc9b6.zip
[sanitizer] Allow for the allocator "names" to be set by the tools
Summary: In the same spirit of SanitizerToolName, allow the Primary & Secondary allocators to have names that can be set by the tools via PrimaryAllocatorName and SecondaryAllocatorName. Additionally, set a non-default name for Scudo. Reviewers: alekseyshl, vitalybuka Reviewed By: alekseyshl, vitalybuka Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D45600 llvm-svn: 330055
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc4
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_allocator.h4
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h4
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h8
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_allocator_secondary.h4
-rw-r--r--compiler-rt/lib/scudo/scudo_allocator.cpp3
-rw-r--r--compiler-rt/lib/scudo/scudo_allocator_secondary.h2
7 files changed, 20 insertions, 9 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc
index 61a671d149b..0fdaef17f87 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc
@@ -21,6 +21,10 @@
namespace __sanitizer {
+// Default allocator names.
+const char *PrimaryAllocatorName = "SizeClassAllocator";
+const char *SecondaryAllocatorName = "LargeMmapAllocator";
+
// ThreadSanitizer for Go uses libc malloc/free.
#if SANITIZER_GO || defined(SANITIZER_USE_MALLOC)
# if SANITIZER_LINUX && !SANITIZER_ANDROID
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h
index 8c6bb3968d2..1f8a5800f32 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h
@@ -24,6 +24,10 @@
namespace __sanitizer {
+// Allows the tools to name their allocations appropriately.
+extern const char *PrimaryAllocatorName;
+extern const char *SecondaryAllocatorName;
+
// Since flags are immutable and allocator behavior can be changed at runtime
// (unit tests or ASan on Android are some examples), allocator_may_return_null
// flag value is cached here and can be altered later.
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h
index ce7b11b6295..0fb94a12e1e 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h
@@ -125,7 +125,7 @@ class SizeClassAllocator32 {
}
void *MapWithCallback(uptr size) {
- void *res = MmapOrDie(size, "SizeClassAllocator32");
+ void *res = MmapOrDie(size, PrimaryAllocatorName);
MapUnmapCallback().OnMap((uptr)res, size);
return res;
}
@@ -286,7 +286,7 @@ class SizeClassAllocator32 {
uptr AllocateRegion(AllocatorStats *stat, uptr class_id) {
CHECK_LT(class_id, kNumClasses);
uptr res = reinterpret_cast<uptr>(MmapAlignedOrDieOnFatalError(
- kRegionSize, kRegionSize, "SizeClassAllocator32"));
+ kRegionSize, kRegionSize, PrimaryAllocatorName));
if (UNLIKELY(!res))
return 0;
MapUnmapCallback().OnMap(res, kRegionSize);
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
index 255981733f3..7a0ab5624b1 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
@@ -72,10 +72,11 @@ class SizeClassAllocator64 {
void Init(s32 release_to_os_interval_ms) {
uptr TotalSpaceSize = kSpaceSize + AdditionalSize();
if (kUsingConstantSpaceBeg) {
- CHECK_EQ(kSpaceBeg, address_range.Init(TotalSpaceSize, AllocatorName(),
- kSpaceBeg));
+ CHECK_EQ(kSpaceBeg, address_range.Init(TotalSpaceSize,
+ PrimaryAllocatorName, kSpaceBeg));
} else {
- NonConstSpaceBeg = address_range.Init(TotalSpaceSize, AllocatorName());
+ NonConstSpaceBeg = address_range.Init(TotalSpaceSize,
+ PrimaryAllocatorName);
CHECK_NE(NonConstSpaceBeg, ~(uptr)0);
}
SetReleaseToOSIntervalMs(release_to_os_interval_ms);
@@ -546,7 +547,6 @@ class SizeClassAllocator64 {
friend class MemoryMapper;
ReservedAddressRange address_range;
- static const char *AllocatorName() { return "sanitizer_allocator"; }
static const uptr kRegionSize = kSpaceSize / kNumClassesRounded;
// FreeArray is the array of free-d chunks (stored as 4-byte offsets).
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_secondary.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_secondary.h
index cb84e8fe686..a67d70dcc51 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_secondary.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_secondary.h
@@ -34,7 +34,7 @@ class LargeMmapAllocatorPtrArrayDynamic {
public:
INLINE void *Init() {
uptr p = address_range_.Init(kMaxNumChunks * sizeof(uptr),
- "sanitizer_large_allocator");
+ SecondaryAllocatorName);
CHECK(p);
return reinterpret_cast<void*>(p);
}
@@ -94,7 +94,7 @@ class LargeMmapAllocator {
return nullptr;
}
uptr map_beg = reinterpret_cast<uptr>(
- MmapOrDieOnFatalError(map_size, "LargeMmapAllocator"));
+ MmapOrDieOnFatalError(map_size, SecondaryAllocatorName));
if (!map_beg)
return nullptr;
CHECK(IsAligned(map_beg, page_size_));
diff --git a/compiler-rt/lib/scudo/scudo_allocator.cpp b/compiler-rt/lib/scudo/scudo_allocator.cpp
index bd9c9b7b14e..e0f78a01542 100644
--- a/compiler-rt/lib/scudo/scudo_allocator.cpp
+++ b/compiler-rt/lib/scudo/scudo_allocator.cpp
@@ -278,6 +278,9 @@ struct ScudoAllocator {
void init() {
SanitizerToolName = "Scudo";
+ PrimaryAllocatorName = "ScudoPrimary";
+ SecondaryAllocatorName = "ScudoSecondary";
+
initFlags();
performSanityChecks();
diff --git a/compiler-rt/lib/scudo/scudo_allocator_secondary.h b/compiler-rt/lib/scudo/scudo_allocator_secondary.h
index 834b91b3871..34ee5cd03b5 100644
--- a/compiler-rt/lib/scudo/scudo_allocator_secondary.h
+++ b/compiler-rt/lib/scudo/scudo_allocator_secondary.h
@@ -89,7 +89,7 @@ class ScudoLargeMmapAllocator {
ReservedSize += 2 * PageSize;
ReservedAddressRange AddressRange;
- uptr ReservedBeg = AddressRange.Init(ReservedSize);
+ uptr ReservedBeg = AddressRange.Init(ReservedSize, SecondaryAllocatorName);
if (UNLIKELY(ReservedBeg == ~static_cast<uptr>(0)))
return ReturnNullOrDieOnFailure::OnOOM();
// A page-aligned pointer is assumed after that, so check it now.
OpenPOWER on IntegriCloud