summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_win.cc
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-09-15 15:39:52 +0000
committerReid Kleckner <rnk@google.com>2016-09-15 15:39:52 +0000
commitc159cd75fbf59c8606b84bf3c43e7d44b5f0eb07 (patch)
tree6a6553a9852afdc5eb6b9a4ef4cb43285adb40e8 /lib/sanitizer_common/sanitizer_win.cc
parent1e567a616bc127fee5319a9b0e4e14b3b5e8f195 (diff)
Really fix the Windows sanitizer build
Don't list __sanitizer_print_memory profile as an INTERFACE_FUNCTION. It is not exported by ASan; it is exported by user code. Move the weak definition from asan_win.cc to sanitizer_win.cc to fix the ubsan tests. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281619 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_win.cc')
-rw-r--r--lib/sanitizer_common/sanitizer_win.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_win.cc b/lib/sanitizer_common/sanitizer_win.cc
index 04e1e11bb..7555360c6 100644
--- a/lib/sanitizer_common/sanitizer_win.cc
+++ b/lib/sanitizer_common/sanitizer_win.cc
@@ -895,4 +895,16 @@ void GetMemoryProfile(fill_profile_f cb, uptr *stats, uptr stats_size) { }
} // namespace __sanitizer
+// Workaround to implement weak hooks on Windows. COFF doesn't directly support
+// weak symbols, but it does support /alternatename, which is similar. If the
+// user does not override the hook, we will use this default definition instead
+// of null.
+extern "C" void __sanitizer_print_memory_profile(int top_percent) {}
+
+#ifdef _WIN64
+#pragma comment(linker, "/alternatename:__sanitizer_print_memory_profile=__sanitizer_default_print_memory_profile") // NOLINT
+#else
+#pragma comment(linker, "/alternatename:___sanitizer_print_memory_profile=___sanitizer_default_print_memory_profile") // NOLINT
+#endif
+
#endif // _WIN32