Bug 1306642, ASAN poisoning functions shouldn't be dllimport on Windows, r=kaie
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Wed, 15 Aug 2018 21:41:23 +0200
changeset 4791 6e31156d7002
parent 4790 9510317eda5b
child 4792 34274ae8c85e
push id299
push userkaie@kuix.de
push dateWed, 15 Aug 2018 19:40:23 +0000
reviewerskaie
bugs1306642
Bug 1306642, ASAN poisoning functions shouldn't be dllimport on Windows, r=kaie
lib/ds/plarena.h
--- a/lib/ds/plarena.h
+++ b/lib/ds/plarena.h
@@ -90,23 +90,34 @@ struct PLArenaPool {
 #define PL_SANITIZE_ADDRESS 1
 #endif
 #elif defined(__SANITIZE_ADDRESS__)
 #define PL_SANITIZE_ADDRESS 1
 #endif
 
 #if defined(PL_SANITIZE_ADDRESS)
 
+#if defined(_MSC_VER)
+/* We can't use dllimport due to DLL linkage mismatch with
+ * sanitizer/asan_interface.h.
+ */
+#define PL_ASAN_VISIBILITY(type_) type_
+#else
+#define PL_ASAN_VISIBILITY(type_) PR_IMPORT(type_)
+#endif
+
 /* These definitions are usually provided through the
  * sanitizer/asan_interface.h header installed by ASan.
  * See https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning
  */
 
-PR_IMPORT(void) __asan_poison_memory_region(void const volatile *addr, size_t size);
-PR_IMPORT(void) __asan_unpoison_memory_region(void const volatile *addr, size_t size);
+PL_ASAN_VISIBILITY(void) __asan_poison_memory_region(
+    void const volatile *addr, size_t size);
+PL_ASAN_VISIBILITY(void) __asan_unpoison_memory_region(
+    void const volatile *addr, size_t size);
 
 #define PL_MAKE_MEM_NOACCESS(addr, size) \
     __asan_poison_memory_region((addr), (size))
 
 #define PL_MAKE_MEM_UNDEFINED(addr, size) \
     __asan_unpoison_memory_region((addr), (size))
 
 #define PL_MAKE_MEM_DEFINED(addr, size) \