[PATCH] D104275: [compiler-rt][hwasan] Add GetShadowOffset function
Leonard Chan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 15 10:44:46 PDT 2021
leonardchan updated this revision to Diff 352186.
leonardchan marked 2 inline comments as done.
leonardchan retitled this revision from "[compiler-rt][hwasan] Add SHADOW_OFFSET macro" to "[compiler-rt][hwasan] Add GetShadowOffset function".
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104275/new/
https://reviews.llvm.org/D104275
Files:
compiler-rt/lib/hwasan/hwasan_allocator.h
compiler-rt/lib/hwasan/hwasan_mapping.h
Index: compiler-rt/lib/hwasan/hwasan_mapping.h
===================================================================
--- compiler-rt/lib/hwasan/hwasan_mapping.h
+++ compiler-rt/lib/hwasan/hwasan_mapping.h
@@ -50,12 +50,14 @@
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;
Index: compiler-rt/lib/hwasan/hwasan_allocator.h
===================================================================
--- compiler-rt/lib/hwasan/hwasan_allocator.h
+++ 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 @@
// 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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104275.352186.patch
Type: text/x-patch
Size: 1629 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210615/62271d6f/attachment.bin>
More information about the cfe-commits
mailing list