[PATCH] D54905: [AddressSanitizer] Add flag to disable linking with CXX runtime
Eugene Leviant via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 26 09:11:04 PST 2018
evgeny777 created this revision.
evgeny777 added reviewers: kcc, samsonov.
This prevents link errors when operators new/delete are overridden by application.
https://reviews.llvm.org/D54905
Files:
include/clang/Driver/Options.td
lib/Driver/SanitizerArgs.cpp
test/Driver/sanitizer-ld.c
Index: test/Driver/sanitizer-ld.c
===================================================================
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -115,6 +115,12 @@
// CHECK-ASAN-LINUX-CXX-STATIC: "--whole-archive" "{{.*}}libclang_rt.asan-i386.a" "--no-whole-archive"
// CHECK-ASAN-LINUX-CXX-STATIC: stdc++
+// RUN: %clangxx -x c++ %s -### -o /dev/null -fsanitize=address -fno-sanitize-link-c++-runtime \
+// RUN: -target i386-unknown-linux -fuse-ld=ld 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-CXX-RUNTIME %s
+//
+// CHECK-ASAN-NO-LINK-CXX-RUNTIME-NOT: asan_cxx
+
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
// RUN: -target arm-linux-gnueabi -fuse-ld=ld -fsanitize=address \
// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
Index: lib/Driver/SanitizerArgs.cpp
===================================================================
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -743,7 +743,8 @@
// Parse -link-cxx-sanitizer flag.
LinkCXXRuntimes =
- Args.hasArg(options::OPT_fsanitize_link_cxx_runtime) || D.CCCIsCXX();
+ Args.hasFlag(options::OPT_fsanitize_link_cxx_runtime,
+ options::OPT_fno_sanitize_link_cxx_runtime, D.CCCIsCXX());
// Finally, initialize the set of available and recoverable sanitizers.
Sanitizers.Mask |= Kinds;
Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1015,6 +1015,8 @@
Group<f_clang_Group>;
def fsanitize_link_cxx_runtime : Flag<["-"], "fsanitize-link-c++-runtime">,
Group<f_clang_Group>;
+def fno_sanitize_link_cxx_runtime : Flag<["-"], "fno-sanitize-link-c++-runtime">,
+ Group<f_clang_Group>;
def fsanitize_cfi_cross_dso : Flag<["-"], "fsanitize-cfi-cross-dso">,
Group<f_clang_Group>,
HelpText<"Enable control flow integrity (CFI) checks for cross-DSO calls.">;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54905.175282.patch
Type: text/x-patch
Size: 2153 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181126/2c06e602/attachment.bin>
More information about the cfe-commits
mailing list