Skip to content

Commit 36eaeaf

Browse files
committed
[llvm][hwasan] Add Fuchsia shadow mapping configuration
Ensure that Fuchsia shadow memory starts at zero. Differential Revision: https://reviews.llvm.org/D99380
1 parent ec294eb commit 36eaeaf

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,13 @@ void HWAddressSanitizer::instrumentPersonalityFunctions() {
15311531
void HWAddressSanitizer::ShadowMapping::init(Triple &TargetTriple,
15321532
bool InstrumentWithCalls) {
15331533
Scale = kDefaultShadowScale;
1534-
if (ClMappingOffset.getNumOccurrences() > 0) {
1534+
if (TargetTriple.isOSFuchsia()) {
1535+
// Fuchsia is always PIE, which means that the beginning of the address
1536+
// space is always available.
1537+
InGlobal = false;
1538+
InTls = false;
1539+
Offset = 0;
1540+
} else if (ClMappingOffset.getNumOccurrences() > 0) {
15351541
InGlobal = false;
15361542
InTls = false;
15371543
Offset = ClMappingOffset;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; Check HWASan shadow mapping on Fuchsia.
2+
; RUN: opt -hwasan -S -mtriple=aarch64-unknown-fuchsia < %s | FileCheck %s
3+
4+
define i32 @test_load(i32* %a) sanitize_hwaddress {
5+
; CHECK: %.hwasan.shadow = call i8* asm "", "=r,0"(i8* null)
6+
entry:
7+
%x = load i32, i32* %a, align 4
8+
ret i32 %x
9+
}

0 commit comments

Comments
 (0)