[PATCH] D99380: [llvm][hwasan] Add Fuchsia shadow mapping configuration

Leonard Chan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 25 15:28:33 PDT 2021


leonardchan updated this revision to Diff 333438.
leonardchan marked 2 inline comments as done.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99380/new/

https://reviews.llvm.org/D99380

Files:
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
  llvm/test/Instrumentation/HWAddressSanitizer/fuchsia.ll


Index: llvm/test/Instrumentation/HWAddressSanitizer/fuchsia.ll
===================================================================
--- /dev/null
+++ 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
+}
Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -1531,7 +1531,13 @@
 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99380.333438.patch
Type: text/x-patch
Size: 1364 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210325/c8acd3c1/attachment.bin>


More information about the llvm-commits mailing list