[PATCH] D57084: hwasan: Read shadow address from ifunc if we don't need a frame record.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 23 14:33:35 PST 2019


pcc updated this revision to Diff 183179.
pcc added a comment.
Herald added a subscriber: kubamracek.

- Update tests


Repository:
  rL LLVM

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

https://reviews.llvm.org/D57084

Files:
  compiler-rt/test/hwasan/lit.cfg
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
  llvm/test/Instrumentation/HWAddressSanitizer/lazy-thread-init.ll
  llvm/test/Instrumentation/HWAddressSanitizer/prologue.ll


Index: llvm/test/Instrumentation/HWAddressSanitizer/prologue.ll
===================================================================
--- llvm/test/Instrumentation/HWAddressSanitizer/prologue.ll
+++ llvm/test/Instrumentation/HWAddressSanitizer/prologue.ll
@@ -1,14 +1,14 @@
 ; Test -hwasan-with-ifunc flag.
 ;
-; RUN: opt -hwasan -S < %s | \
+; RUN: opt -hwasan -hwasan-allow-ifunc -S < %s | \
 ; RUN:     FileCheck %s --check-prefixes=CHECK,CHECK-NOGLOBAL,CHECK-TLS,CHECK-HISTORY
-; RUN: opt -hwasan -S -hwasan-with-ifunc=0 -hwasan-with-tls=1 -hwasan-record-stack-history=1 < %s | \
+; RUN: opt -hwasan -hwasan-allow-ifunc -S -hwasan-with-ifunc=0 -hwasan-with-tls=1 -hwasan-record-stack-history=1 < %s | \
 ; RUN:     FileCheck %s --check-prefixes=CHECK,CHECK-NOGLOBAL,CHECK-TLS,CHECK-HISTORY
-; RUN: opt -hwasan -S -hwasan-with-ifunc=0 -hwasan-with-tls=1 -hwasan-record-stack-history=0 < %s | \
+; RUN: opt -hwasan -hwasan-allow-ifunc -S -hwasan-with-ifunc=0 -hwasan-with-tls=1 -hwasan-record-stack-history=0 < %s | \
 ; RUN:     FileCheck %s --check-prefixes=CHECK,CHECK-NOGLOBAL,CHECK-IFUNC,CHECK-NOHISTORY
-; RUN: opt -hwasan -S -hwasan-with-ifunc=0 -hwasan-with-tls=0 < %s | \
+; RUN: opt -hwasan -hwasan-allow-ifunc -S -hwasan-with-ifunc=0 -hwasan-with-tls=0 < %s | \
 ; RUN:     FileCheck %s --check-prefixes=CHECK,CHECK-GLOBAL,CHECK-NOHISTORY
-; RUN: opt -hwasan -S -hwasan-with-ifunc=1  -hwasan-with-tls=0 < %s | \
+; RUN: opt -hwasan -hwasan-allow-ifunc -S -hwasan-with-ifunc=1  -hwasan-with-tls=0 < %s | \
 ; RUN:     FileCheck %s --check-prefixes=CHECK,CHECk-NOGLOBAL,CHECK-IFUNC,CHECK-NOHISTORY
 
 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
Index: llvm/test/Instrumentation/HWAddressSanitizer/lazy-thread-init.ll
===================================================================
--- llvm/test/Instrumentation/HWAddressSanitizer/lazy-thread-init.ll
+++ llvm/test/Instrumentation/HWAddressSanitizer/lazy-thread-init.ll
@@ -1,4 +1,4 @@
-; RUN: opt -S -hwasan < %s | FileCheck %s
+; RUN: opt -S -hwasan -hwasan-allow-ifunc < %s | FileCheck %s
 
 target triple = "aarch64--linux-android"
 
Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -160,6 +160,10 @@
                                        cl::desc("inline all checks"),
                                        cl::Hidden, cl::init(false));
 
+static cl::opt<bool> ClAllowIfunc("hwasan-allow-ifunc",
+                                  cl::desc("allow the use of ifunc"),
+                                  cl::Hidden, cl::init(false));
+
 namespace {
 
 /// An instrumentation pass implementing detection of addressability bugs
@@ -832,7 +836,7 @@
   if (!Mapping.InTls)
     return getDynamicShadowNonTls(IRB);
 
-  if (!WithFrameRecord && TargetTriple.isAndroid())
+  if (ClAllowIfunc && !WithFrameRecord && TargetTriple.isAndroid())
     return getDynamicShadowIfunc(IRB);
 
   Value *SlotPtr = getHwasanThreadSlotPtr(IRB, IntptrTy);
Index: compiler-rt/test/hwasan/lit.cfg
===================================================================
--- compiler-rt/test/hwasan/lit.cfg
+++ compiler-rt/test/hwasan/lit.cfg
@@ -11,7 +11,8 @@
 # Setup default compiler flags used with -fsanitize=memory option.
 clang_cflags = [config.target_cflags] + config.debug_info_flags
 clang_cxxflags = config.cxx_mode_flags + clang_cflags
-clang_hwasan_cflags = ["-fsanitize=hwaddress", "-mllvm", "-hwasan-generate-tags-with-calls"] + clang_cflags
+clang_hwasan_cflags = ["-fsanitize=hwaddress", "-mllvm", "-hwasan-generate-tags-with-calls",
+                       "-mllvm", "-hwasan-allow-ifunc"] + clang_cflags
 clang_hwasan_cxxflags = config.cxx_mode_flags + clang_hwasan_cflags
 
 def build_invocation(compile_flags):


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57084.183179.patch
Type: text/x-patch
Size: 3917 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190123/53b7a840/attachment.bin>


More information about the llvm-commits mailing list