[PATCH] Always add -lc++abi when using vptr sanitizer on Darwin.

Alexey Samsonov vonosmas at gmail.com
Tue Jan 13 16:09:16 PST 2015


Hi kubabrecka,

-fsanitize=vptr implementation depends on RTTI descriptors for
__cxxabiv1::__class_type_info and friends.

http://reviews.llvm.org/D6960

Files:
  lib/Driver/ToolChains.cpp
  test/Driver/darwin-sanitizer-ld.c

Index: lib/Driver/ToolChains.cpp
===================================================================
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -380,6 +380,9 @@
 
       // The Ubsan runtime library requires C++.
       AddCXXStdlibLibArgs(Args, CmdArgs);
+      // Vptr sanitizer needs RTTI descriptors from c++abi.
+      if (Sanitize.sanitizesVptr())
+        CmdArgs.push_back("-lc++abi");
     }
   }
 
Index: test/Driver/darwin-sanitizer-ld.c
===================================================================
--- test/Driver/darwin-sanitizer-ld.c
+++ test/Driver/darwin-sanitizer-ld.c
@@ -37,6 +37,7 @@
 // CHECK-UBSAN: "{{.*}}ld{{(.exe)?}}"
 // CHECK-UBSAN: libclang_rt.ubsan_osx.a"
 // CHECK-UBSAN: stdc++
+// CHECK-UBSAN: "-lc++abi"
 
 // RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
 // RUN:   -fsanitize=bounds -fsanitize-undefined-trap-on-error \

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6960.18121.patch
Type: text/x-patch
Size: 900 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150114/ca63ba4e/attachment.bin>


More information about the cfe-commits mailing list