diff --git a/compiler-rt/lib/asan/asan_interface.h b/compiler-rt/lib/asan/asan_interface.h index 3a613f600f73..7f4fdbe04e63 100644 --- a/compiler-rt/lib/asan/asan_interface.h +++ b/compiler-rt/lib/asan/asan_interface.h @@ -16,10 +16,11 @@ #define ASAN_INTERFACE_H #if !defined(_WIN32) -#include // for __WORDSIZE +#include // for uintptr_t +#define ASAN_INTERFACE_FUNCTION_ATTRIBUTE __attribute__((visibility("default"))) #else -// The __attribute__ keyword is not understood by Visual Studio. -#define __attribute__(x) +// TODO(timurrrr): find out what we need on Windows. __declspec(dllexport) ? +#define ASAN_INTERFACE_FUNCTION_ATTRIBUTE #endif #include // for size_t @@ -29,13 +30,12 @@ extern "C" { // This function should be called at the very beginning of the process, // before any instrumented code is executed and before any call to malloc. - void __asan_init() - __attribute__((visibility("default"))); + void __asan_init() ASAN_INTERFACE_FUNCTION_ATTRIBUTE; // This function should be called by the instrumented code. // 'addr' is the address of a global variable called 'name' of 'size' bytes. void __asan_register_global(uintptr_t addr, size_t size, const char *name) - __attribute__((visibility("default"))); + ASAN_INTERFACE_FUNCTION_ATTRIBUTE; // This structure describes an instrumented global variable. struct __asan_global { @@ -48,18 +48,18 @@ extern "C" { // These two functions should be called by the instrumented code. // 'globals' is an array of structures describing 'n' globals. void __asan_register_globals(__asan_global *globals, size_t n) - __attribute__((visibility("default"))); + ASAN_INTERFACE_FUNCTION_ATTRIBUTE; void __asan_unregister_globals(__asan_global *globals, size_t n) - __attribute__((visibility("default"))); + ASAN_INTERFACE_FUNCTION_ATTRIBUTE; // These two functions are used by the instrumented code in the // use-after-return mode. __asan_stack_malloc allocates size bytes of // fake stack and __asan_stack_free poisons it. real_stack is a pointer to // the real stack region. size_t __asan_stack_malloc(size_t size, size_t real_stack) - __attribute__((visibility("default"))); + ASAN_INTERFACE_FUNCTION_ATTRIBUTE; void __asan_stack_free(size_t ptr, size_t size, size_t real_stack) - __attribute__((visibility("default"))); + ASAN_INTERFACE_FUNCTION_ATTRIBUTE; // Marks memory region [addr, addr+size) as unaddressable. // This memory must be previously allocated by the user program. Accessing @@ -101,7 +101,7 @@ extern "C" { // set a breakpoint on this function in a debugger. void __asan_report_error(uintptr_t pc, uintptr_t bp, uintptr_t sp, uintptr_t addr, bool is_write, size_t access_size) - __attribute__((visibility("default"))); + ASAN_INTERFACE_FUNCTION_ATTRIBUTE; // Sets the exit code to use when reporting an error. // Returns the old value. @@ -137,4 +137,5 @@ extern "C" { void __asan_print_accumulated_stats(); } // namespace +#undef ASAN_INTERFACE_FUNCTION_ATTRIBUTE #endif // ASAN_INTERFACE_H diff --git a/compiler-rt/lib/asan/asan_internal.h b/compiler-rt/lib/asan/asan_internal.h index eecedd655c6e..65c825e920bb 100644 --- a/compiler-rt/lib/asan/asan_internal.h +++ b/compiler-rt/lib/asan/asan_internal.h @@ -35,9 +35,9 @@ typedef __int64 int64_t; #endif // _WIN32 // If __WORDSIZE was undefined by the platform, define it in terms of the -// compiler built-in __LP64__. +// compiler built-ins __LP64__ and _WIN64. #ifndef __WORDSIZE -#if __LP64__ +#if __LP64__ || defined(_WIN64) #define __WORDSIZE 64 #else #define __WORDSIZE 32