[llvm] 36eaeaf - [llvm][hwasan] Add Fuchsia shadow mapping configuration
Leonard Chan via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 25 15:29:21 PDT 2021
Author: Leonard Chan
Date: 2021-03-25T15:28:59-07:00
New Revision: 36eaeaf728d303c5b42c4d22724406b14b9f0f56
URL: https://github.com/llvm/llvm-project/commit/36eaeaf728d303c5b42c4d22724406b14b9f0f56
DIFF: https://github.com/llvm/llvm-project/commit/36eaeaf728d303c5b42c4d22724406b14b9f0f56.diff
LOG: [llvm][hwasan] Add Fuchsia shadow mapping configuration
Ensure that Fuchsia shadow memory starts at zero.
Differential Revision: https://reviews.llvm.org/D99380
Added:
llvm/test/Instrumentation/HWAddressSanitizer/fuchsia.ll
Modified:
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index 07892bdc854b..04761f0d89f0 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -1531,7 +1531,13 @@ void HWAddressSanitizer::instrumentPersonalityFunctions() {
void HWAddressSanitizer::ShadowMapping::init(Triple &TargetTriple,
bool InstrumentWithCalls) {
Scale = kDefaultShadowScale;
- if (ClMappingOffset.getNumOccurrences() > 0) {
+ if (TargetTriple.isOSFuchsia()) {
+ // Fuchsia is always PIE, which means that the beginning of the address
+ // space is always available.
+ InGlobal = false;
+ InTls = false;
+ Offset = 0;
+ } else if (ClMappingOffset.getNumOccurrences() > 0) {
InGlobal = false;
InTls = false;
Offset = ClMappingOffset;
diff --git a/llvm/test/Instrumentation/HWAddressSanitizer/fuchsia.ll b/llvm/test/Instrumentation/HWAddressSanitizer/fuchsia.ll
new file mode 100644
index 000000000000..900583000835
--- /dev/null
+++ b/llvm/test/Instrumentation/HWAddressSanitizer/fuchsia.ll
@@ -0,0 +1,9 @@
+; Check HWASan shadow mapping on Fuchsia.
+; RUN: opt -hwasan -S -mtriple=aarch64-unknown-fuchsia < %s | FileCheck %s
+
+define i32 @test_load(i32* %a) sanitize_hwaddress {
+; CHECK: %.hwasan.shadow = call i8* asm "", "=r,0"(i8* null)
+entry:
+ %x = load i32, i32* %a, align 4
+ ret i32 %x
+}
More information about the llvm-commits
mailing list