[compiler-rt] fc006b3 - [compiler-rt][hwasan] Add GetShadowOffset function
Leonard Chan via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 15 10:48:27 PDT 2021
Author: Leonard Chan
Date: 2021-06-15T10:46:11-07:00
New Revision: fc006b3e5dc3cb33e3dd55955f05664f187e8240
URL: https://github.com/llvm/llvm-project/commit/fc006b3e5dc3cb33e3dd55955f05664f187e8240
DIFF: https://github.com/llvm/llvm-project/commit/fc006b3e5dc3cb33e3dd55955f05664f187e8240.diff
LOG: [compiler-rt][hwasan] Add GetShadowOffset function
Similar to SHADOW_OFFSET on asan, we can use this for hwasan so platforms that
use a constant value for the start of shadow memory can just use the constant
rather than access a global.
Differential Revision: https://reviews.llvm.org/D104275
Added:
Modified:
compiler-rt/lib/hwasan/hwasan_allocator.h
compiler-rt/lib/hwasan/hwasan_mapping.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/hwasan/hwasan_allocator.h b/compiler-rt/lib/hwasan/hwasan_allocator.h
index 438a6c5a13c0c..35c3d6b4bf434 100644
--- a/compiler-rt/lib/hwasan/hwasan_allocator.h
+++ b/compiler-rt/lib/hwasan/hwasan_allocator.h
@@ -15,6 +15,7 @@
#include "hwasan.h"
#include "hwasan_interface_internal.h"
+#include "hwasan_mapping.h"
#include "hwasan_poisoning.h"
#include "sanitizer_common/sanitizer_allocator.h"
#include "sanitizer_common/sanitizer_allocator_checks.h"
@@ -114,7 +115,7 @@ inline bool InTaggableRegion(uptr addr) {
// Aliases are mapped next to shadow so that the upper bits match the shadow
// base.
return (addr >> kTaggableRegionCheckShift) ==
- (__hwasan_shadow_memory_dynamic_address >> kTaggableRegionCheckShift);
+ (GetShadowOffset() >> kTaggableRegionCheckShift);
#endif
return true;
}
diff --git a/compiler-rt/lib/hwasan/hwasan_mapping.h b/compiler-rt/lib/hwasan/hwasan_mapping.h
index 8243d1ec7ed50..20b449aa70a6b 100644
--- a/compiler-rt/lib/hwasan/hwasan_mapping.h
+++ b/compiler-rt/lib/hwasan/hwasan_mapping.h
@@ -50,12 +50,14 @@ extern uptr kHighMemEnd;
extern uptr kAliasRegionStart;
+inline uptr GetShadowOffset() {
+ return SANITIZER_FUCHSIA ? 0 : __hwasan_shadow_memory_dynamic_address;
+}
inline uptr MemToShadow(uptr untagged_addr) {
- return (untagged_addr >> kShadowScale) +
- __hwasan_shadow_memory_dynamic_address;
+ return (untagged_addr >> kShadowScale) + GetShadowOffset();
}
inline uptr ShadowToMem(uptr shadow_addr) {
- return (shadow_addr - __hwasan_shadow_memory_dynamic_address) << kShadowScale;
+ return (shadow_addr - GetShadowOffset()) << kShadowScale;
}
inline uptr MemToShadowSize(uptr size) {
return size >> kShadowScale;
More information about the llvm-commits
mailing list