From 4223af42b8f3fbb5eae4d1b531ccccbe12d06aa2 Mon Sep 17 00:00:00 2001 From: Kostya Kortchinsky Date: Tue, 30 Jan 2018 17:59:49 +0000 Subject: [PATCH] [scudo] Add default implementations for weak functions Summary: This is in preparation for platforms where `SANITIZER_SUPPORTS_WEAK_HOOKS` is 0. They require a default implementation. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: delcypher, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D42557 llvm-svn: 323795 --- compiler-rt/lib/scudo/scudo_allocator.cpp | 12 ++++++++++++ compiler-rt/lib/scudo/scudo_flags.cpp | 9 +++++++-- compiler-rt/lib/scudo/scudo_interface_internal.h | 3 +++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/compiler-rt/lib/scudo/scudo_allocator.cpp b/compiler-rt/lib/scudo/scudo_allocator.cpp index 31317b7cf9f5..44cb1821816d 100644 --- a/compiler-rt/lib/scudo/scudo_allocator.cpp +++ b/compiler-rt/lib/scudo/scudo_allocator.cpp @@ -736,6 +736,18 @@ uptr __sanitizer_get_allocated_size(const void *Ptr) { return Instance.getUsableSize(Ptr); } +#if !SANITIZER_SUPPORTS_WEAK_HOOKS +SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_malloc_hook, + void *Ptr, uptr Size) { + (void)Ptr; + (void)Size; +} + +SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_free_hook, void *Ptr) { + (void)Ptr; +} +#endif + // Interface functions void __scudo_set_rss_limit(uptr LimitMb, s32 HardLimit) { diff --git a/compiler-rt/lib/scudo/scudo_flags.cpp b/compiler-rt/lib/scudo/scudo_flags.cpp index 2aff3ef1e8fa..ad50800c473b 100644 --- a/compiler-rt/lib/scudo/scudo_flags.cpp +++ b/compiler-rt/lib/scudo/scudo_flags.cpp @@ -12,13 +12,12 @@ //===----------------------------------------------------------------------===// #include "scudo_flags.h" +#include "scudo_interface_internal.h" #include "scudo_utils.h" #include "sanitizer_common/sanitizer_flags.h" #include "sanitizer_common/sanitizer_flag_parser.h" -SANITIZER_INTERFACE_WEAK_DEF(const char*, __scudo_default_options, void); - namespace __scudo { static Flags ScudoFlags; // Use via getFlags(). @@ -119,3 +118,9 @@ Flags *getFlags() { } } // namespace __scudo + +#if !SANITIZER_SUPPORTS_WEAK_HOOKS +SANITIZER_INTERFACE_WEAK_DEF(const char*, __scudo_default_options, void) { + return ""; +} +#endif diff --git a/compiler-rt/lib/scudo/scudo_interface_internal.h b/compiler-rt/lib/scudo/scudo_interface_internal.h index 7e8a12c834b4..e2c63db23546 100644 --- a/compiler-rt/lib/scudo/scudo_interface_internal.h +++ b/compiler-rt/lib/scudo/scudo_interface_internal.h @@ -20,6 +20,9 @@ using __sanitizer::uptr; using __sanitizer::s32; extern "C" { +SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE +const char* __scudo_default_options(); + SANITIZER_INTERFACE_ATTRIBUTE void __scudo_set_rss_limit(uptr LimitMb, s32 HardLimit); } // extern "C"