summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common
diff options
context:
space:
mode:
authorDan Liew <dan@su-root.co.uk>2018-11-02 15:28:11 +0000
committerDan Liew <dan@su-root.co.uk>2018-11-02 15:28:11 +0000
commita8eaaa80067f26f23aa2853ecb7197327afc7730 (patch)
treefdafb2e10c5515f27247147653284806ee014c86 /compiler-rt/lib/sanitizer_common
parent2dc07d0cf3ec9222eba1087ab68d0c15d1b48b9f (diff)
downloadbcm5719-llvm-a8eaaa80067f26f23aa2853ecb7197327afc7730.tar.gz
bcm5719-llvm-a8eaaa80067f26f23aa2853ecb7197327afc7730.zip
[NFC] Refactor initialisation of Darwin malloc zone fields into separate function called `InitMallocZoneFields()` which is now called from `ReplaceSystemMalloc()`.
Summary: The motivation here is to be able support initialisation of the malloc zone on other code paths. rdar://problem/45284065 Reviewers: kubamracek, george.karpenkov Subscribers: llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D54037 llvm-svn: 345983
Diffstat (limited to 'compiler-rt/lib/sanitizer_common')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_malloc_mac.inc6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_malloc_mac.inc b/compiler-rt/lib/sanitizer_common/sanitizer_malloc_mac.inc
index e69d6f94b0e..f9f40f8bf02 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_malloc_mac.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_malloc_mac.inc
@@ -302,7 +302,7 @@ boolean_t mi_zone_locked(malloc_zone_t *zone) {
namespace COMMON_MALLOC_NAMESPACE {
-void ReplaceSystemMalloc() {
+void InitMallocZoneFields() {
static malloc_introspection_t sanitizer_zone_introspection;
// Ok to use internal_memset, these places are not performance-critical.
internal_memset(&sanitizer_zone_introspection, 0,
@@ -335,6 +335,10 @@ void ReplaceSystemMalloc() {
sanitizer_zone.free_definite_size = 0;
sanitizer_zone.memalign = &__sanitizer_mz_memalign;
sanitizer_zone.introspect = &sanitizer_zone_introspection;
+}
+
+void ReplaceSystemMalloc() {
+ InitMallocZoneFields();
// Register the zone.
malloc_zone_register(&sanitizer_zone);
OpenPOWER on IntegriCloud