Commit b3f67e05 authored by Seth Hinze's avatar Seth Hinze Committed by Facebook GitHub Bot

Fix linker error with SanitizeAddress.cpp on non-ASAN win32 builds

Summary:
Win32 does not support weak symbols.  This means the linker will fail due to the unresolved symbol `__asan_region_is_poisoned` when ASAN is not available.
Use `FOLLY_CREATE_EXTERN_ACCESSOR` macro when filtering for ASAN availability in `SanitizeAddress.cpp` to ensure the symbol `__asan_region_is_poisoned` is referenced only when ASAN is available.

Reviewed By: yfeldblum, luciang

Differential Revision: D27278826

fbshipit-source-id: 3c8efbfc687295c2fa70e3712402fd8dfe81bc45
parent 09cc63cb
......@@ -14,21 +14,23 @@
* limitations under the License.
*/
#include <folly/lang/Extern.h>
#include <folly/memory/SanitizeAddress.h>
// Address Sanitizer interface may be found at:
// https://github.com/llvm-mirror/compiler-rt/blob/master/include/sanitizer/asan_interface.h
extern "C" FOLLY_ATTR_WEAK void* __asan_region_is_poisoned(void*, std::size_t);
extern "C" void* __asan_region_is_poisoned(void*, std::size_t);
namespace folly {
namespace detail {
FOLLY_CREATE_EXTERN_ACCESSOR(
asan_region_is_poisoned_access_v, __asan_region_is_poisoned);
void* asan_region_is_poisoned_(void* const ptr, std::size_t len) {
if (kIsLibrarySanitizeAddress) {
return __asan_region_is_poisoned(ptr, len);
} else {
return nullptr;
}
constexpr auto fun =
asan_region_is_poisoned_access_v<kIsLibrarySanitizeAddress>;
return fun ? fun(ptr, len) : nullptr;
}
} // namespace detail
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment