[PATCH] Enable generation of unwind tables when building with sanitizers

Evgeniy Stepanov eugenis at google.com
Thu Feb 13 04:14:29 PST 2014


Hi kcc, samsonov,

http://llvm-reviews.chandlerc.com/D2762

Files:
  lib/Driver/Tools.cpp
  test/Driver/sanitize_unwind_tables.c
  include/clang/Driver/SanitizerArgs.h

Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2498,10 +2498,11 @@
   // -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more
   // complicated ways.
   bool AsynchronousUnwindTables =
-    Args.hasFlag(options::OPT_fasynchronous_unwind_tables,
-                 options::OPT_fno_asynchronous_unwind_tables,
-                 getToolChain().IsUnwindTablesDefault() &&
-                 !KernelOrKext);
+      Args.hasFlag(options::OPT_fasynchronous_unwind_tables,
+                   options::OPT_fno_asynchronous_unwind_tables,
+                   (getToolChain().IsUnwindTablesDefault() ||
+                    getToolChain().getSanitizerArgs().needsUnwindTables()) &&
+                       !KernelOrKext);
   if (Args.hasFlag(options::OPT_funwind_tables, options::OPT_fno_unwind_tables,
                    AsynchronousUnwindTables))
     CmdArgs.push_back("-munwind-tables");
Index: test/Driver/sanitize_unwind_tables.c
===================================================================
--- test/Driver/sanitize_unwind_tables.c
+++ test/Driver/sanitize_unwind_tables.c
@@ -0,0 +1,8 @@
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 |  FileCheck %s
+// RUN: %clang -target i686-linux-gnu -fsanitize=address %s -### 2>&1 |  FileCheck %s
+// RUN: %clang -target arm-linux-androideabi -fsanitize=address %s -### 2>&1 |  FileCheck %s
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 |  FileCheck %s
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread %s -### 2>&1 |  FileCheck %s
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=dataflow %s -### 2>&1 |  FileCheck %s
+
+// CHECK: -munwind-tables
Index: include/clang/Driver/SanitizerArgs.h
===================================================================
--- include/clang/Driver/SanitizerArgs.h
+++ include/clang/Driver/SanitizerArgs.h
@@ -42,7 +42,8 @@
     NeedsLeakDetection = Leak,
     NeedsUbsanRt = Undefined | Integer,
     NotAllowedWithTrap = Vptr,
-    HasZeroBaseShadow = Thread | Memory | DataFlow
+    HasZeroBaseShadow = Thread | Memory | DataFlow,
+    NeedsUnwindTables = Address | Thread | Memory | DataFlow
   };
   unsigned Kind;
 
@@ -73,6 +74,7 @@
   bool hasZeroBaseShadow() const {
     return (Kind & HasZeroBaseShadow) || AsanZeroBaseShadow;
   }
+  bool needsUnwindTables() const { return Kind & NeedsUnwindTables; }
   void addArgs(const llvm::opt::ArgList &Args,
                llvm::opt::ArgStringList &CmdArgs) const;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2762.1.patch
Type: text/x-patch
Size: 2589 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140213/f8216e81/attachment.bin>


More information about the cfe-commits mailing list