diff --git a/compiler-rt/lib/hwasan/hwasan_allocator.h b/compiler-rt/lib/hwasan/hwasan_allocator.h --- a/compiler-rt/lib/hwasan/hwasan_allocator.h +++ b/compiler-rt/lib/hwasan/hwasan_allocator.h @@ -114,7 +114,7 @@ // Aliases are mapped next to shadow so that the upper bits match the shadow // base. return (addr >> kTaggableRegionCheckShift) == - (__hwasan_shadow_memory_dynamic_address >> kTaggableRegionCheckShift); + (SHADOW_OFFSET >> kTaggableRegionCheckShift); #endif return true; } diff --git a/compiler-rt/lib/hwasan/hwasan_mapping.h b/compiler-rt/lib/hwasan/hwasan_mapping.h --- a/compiler-rt/lib/hwasan/hwasan_mapping.h +++ b/compiler-rt/lib/hwasan/hwasan_mapping.h @@ -37,6 +37,12 @@ constexpr uptr kShadowScale = 4; constexpr uptr kShadowAlignment = 1ULL << kShadowScale; +#if SANITIZER_FUCHSIA +# define SHADOW_OFFSET (0) +#else +# define SHADOW_OFFSET __hwasan_shadow_memory_dynamic_address +#endif + namespace __hwasan { extern uptr kLowMemStart; @@ -51,11 +57,10 @@ extern uptr kAliasRegionStart; inline uptr MemToShadow(uptr untagged_addr) { - return (untagged_addr >> kShadowScale) + - __hwasan_shadow_memory_dynamic_address; + return (untagged_addr >> kShadowScale) + SHADOW_OFFSET } inline uptr ShadowToMem(uptr shadow_addr) { - return (shadow_addr - __hwasan_shadow_memory_dynamic_address) << kShadowScale; + return (shadow_addr - SHADOW_OFFSET) << kShadowScale; } inline uptr MemToShadowSize(uptr size) { return size >> kShadowScale;