[compiler-rt] [llvm] [HWASan][Fuchsia] Have Fuchsia use a dynamic shadow start (PR #180881)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 10 20:30:28 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
@llvm/pr-subscribers-llvm-transforms
Author: None (PiJoules)
<details>
<summary>Changes</summary>
The dynamic shadow global is still set to zero, but this will change in the future.
---
Full diff: https://github.com/llvm/llvm-project/pull/180881.diff
3 Files Affected:
- (modified) compiler-rt/lib/hwasan/hwasan_fuchsia.cpp (+7-2)
- (modified) compiler-rt/lib/hwasan/hwasan_mapping.h (+1-3)
- (modified) llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp (+1-1)
``````````diff
diff --git a/compiler-rt/lib/hwasan/hwasan_fuchsia.cpp b/compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
index 647211bf199e1..3f1d59061ef13 100644
--- a/compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
@@ -46,12 +46,17 @@ bool InitShadow() {
__sanitizer::InitShadowBounds();
CHECK_NE(__sanitizer::ShadowBounds.shadow_limit, 0);
+ __hwasan_shadow_memory_dynamic_address = 0;
+
// These variables are used by MemIsShadow for asserting we have a correct
// shadow address. On Fuchsia, we only have one region of shadow, so the
// bounds of Low shadow can be zero while High shadow represents the true
// bounds. Note that these are inclusive ranges.
- kLowShadowStart = 0;
- kLowShadowEnd = 0;
+ uintptr_t LowMemEnd = __hwasan_shadow_memory_dynamic_address
+ ? __hwasan_shadow_memory_dynamic_address - 1
+ : 0;
+ kLowShadowStart = __hwasan_shadow_memory_dynamic_address;
+ kLowShadowEnd = MemToShadow(LowMemEnd);
kHighShadowStart = __sanitizer::ShadowBounds.shadow_base;
kHighShadowEnd = __sanitizer::ShadowBounds.shadow_limit - 1;
diff --git a/compiler-rt/lib/hwasan/hwasan_mapping.h b/compiler-rt/lib/hwasan/hwasan_mapping.h
index 79a143632f6ab..eddc65b8d37f3 100644
--- a/compiler-rt/lib/hwasan/hwasan_mapping.h
+++ b/compiler-rt/lib/hwasan/hwasan_mapping.h
@@ -48,9 +48,7 @@ extern uptr kHighShadowEnd;
extern uptr kHighMemStart;
extern uptr kHighMemEnd;
-inline uptr GetShadowOffset() {
- return SANITIZER_FUCHSIA ? 0 : __hwasan_shadow_memory_dynamic_address;
-}
+inline uptr GetShadowOffset() { return __hwasan_shadow_memory_dynamic_address; }
inline uptr MemToShadow(uptr untagged_addr) {
return (untagged_addr >> kShadowScale) + GetShadowOffset();
}
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index f7f82842989ef..495b289fee54a 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -1900,7 +1900,7 @@ void HWAddressSanitizer::ShadowMapping::init(Triple &TargetTriple,
if (TargetTriple.isOSFuchsia()) {
// Fuchsia is always PIE, which means that the beginning of the address
// space is always available.
- SetFixed(0);
+ Kind = OffsetKind::kGlobal;
} else if (CompileKernel || InstrumentWithCalls) {
SetFixed(0);
WithFrameRecord = false;
``````````
</details>
https://github.com/llvm/llvm-project/pull/180881
More information about the llvm-commits
mailing list