summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_printf.cc
diff options
context:
space:
mode:
authorMarcos Pividori <mpividori@google.com>2017-01-29 05:44:59 +0000
committerMarcos Pividori <mpividori@google.com>2017-01-29 05:44:59 +0000
commit6ef4606343358c8f0365f7741b5033c42fbabb0e (patch)
tree1766039b062548830425f30d64ee2d9cea2de241 /lib/sanitizer_common/sanitizer_printf.cc
parentae08a22cc215448aa3ad5a6fb099f6df77e9fa01 (diff)
General definition for weak functions
In this diff, I define a general macro for defining weak functions with a default implementation: "SANITIZER_INTERFACE_WEAK_DEF()". This way, we simplify the implementation for different platforms. For example, we cannot define weak functions on Windows, but we can use linker pragmas to create an alias to a default implementation. All of these implementation details are hidden in the new macro. Also, as I modify the name for exported weak symbols on Windows, I needed to temporarily disable "dll_host" test for asan, which checks the list of functions included in asan_win_dll_thunk. Differential Revision: https://reviews.llvm.org/D28596 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293419 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_printf.cc')
-rw-r--r--lib/sanitizer_common/sanitizer_printf.cc12
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/sanitizer_common/sanitizer_printf.cc b/lib/sanitizer_common/sanitizer_printf.cc
index c8317be60..99b7ff1b5 100644
--- a/lib/sanitizer_common/sanitizer_printf.cc
+++ b/lib/sanitizer_common/sanitizer_printf.cc
@@ -214,15 +214,11 @@ void SetPrintfAndReportCallback(void (*callback)(const char *)) {
}
// Can be overriden in frontend.
-#if SANITIZER_SUPPORTS_WEAK_HOOKS
-SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
-void OnPrint(const char *str) {
- (void)str;
-}
-#elif SANITIZER_GO && defined(TSAN_EXTERNAL_HOOKS)
-void OnPrint(const char *str);
+#if SANITIZER_GO && defined(TSAN_EXTERNAL_HOOKS)
+// Implementation must be defined in frontend.
+extern "C" void OnPrint(const char *str);
#else
-void OnPrint(const char *str) {
+SANITIZER_INTERFACE_WEAK_DEF(void, OnPrint, const char *str) {
(void)str;
}
#endif