diff --git a/compiler-rt/lib/asan/asan_mapping.h b/compiler-rt/lib/asan/asan_mapping.h --- a/compiler-rt/lib/asan/asan_mapping.h +++ b/compiler-rt/lib/asan/asan_mapping.h @@ -13,8 +13,6 @@ #ifndef ASAN_MAPPING_H #define ASAN_MAPPING_H -#include "asan_internal.h" - // The full explanation of the memory mapping could be found here: // https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm // @@ -153,8 +151,6 @@ #define ASAN_SHADOW_SCALE 3 -static const u64 kDefaultShadowSentinel = ~(uptr)0; - #if SANITIZER_FUCHSIA # define ASAN_SHADOW_OFFSET_CONST (0) #elif SANITIZER_WORDSIZE == 32 @@ -199,12 +195,20 @@ # elif SANITIZER_WINDOWS64 # define ASAN_SHADOW_OFFSET_DYNAMIC # else -# define ASAN_SHADOW_OFFSET_CONST \ - 0x000000007FFFFFFF & (~0xFFFULL << ASAN_SHADOW_SCALE) +# if ASAN_SHADOW_SCALE != 3 +# error "Value below is based on shadow scale = 3." +# error "Original formula was: "0x7FFFFFFF & (~0xFFFULL << SHADOW_SCALE)"." +# endif +# define ASAN_SHADOW_OFFSET_CONST 0x000000007fff8000 # endif #endif -#if defined(ASAN_SHADOW_OFFSET_CONST) +#if defined(__cplusplus) +# include "asan_internal.h" + +static const u64 kDefaultShadowSentinel = ~(uptr)0; + +# if defined(ASAN_SHADOW_OFFSET_CONST) static const u64 kConstShadowOffset = ASAN_SHADOW_OFFSET_CONST; # define ASAN_SHADOW_OFFSET kConstShadowOffset #elif defined(ASAN_SHADOW_OFFSET_DYNAMIC) @@ -382,4 +386,6 @@ } // namespace __asan +#endif // __cplusplus + #endif // ASAN_MAPPING_H