]> granicus.if.org Git - clang/commitdiff
[UBSan] Don't link UBSan runtime into shared libraries.
authorAlexey Samsonov <vonosmas@gmail.com>
Mon, 30 Jun 2014 20:27:16 +0000 (20:27 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Mon, 30 Jun 2014 20:27:16 +0000 (20:27 +0000)
It used to be a feature of UBSan (it could sanitize a standalone
shared object instead of the whole program), but now it causes
more problems, like PR20165.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212064 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp
test/Driver/sanitizer-ld.c

index f5d79941363ae13d9774388c971a6803a5795b9d..093c936fe5b11c6bd57a44088555bdc82ac15f31 100644 (file)
@@ -2039,23 +2039,21 @@ static void addLsanRT(const ToolChain &TC, const ArgList &Args,
 static void addUbsanRT(const ToolChain &TC, const ArgList &Args,
                        ArgStringList &CmdArgs, bool IsCXX,
                        bool HasOtherSanitizerRt) {
-  // Export symbols if we're not building a shared library. This allows two
-  // models: either every DSO containing ubsan-sanitized code contains the
-  // ubsan runtime, or the main executable does (or both).
-  const bool ExportSymbols = !Args.hasArg(options::OPT_shared);
+  // Do not link runtime into shared libraries.
+  if (Args.hasArg(options::OPT_shared))
+    return;
 
   // Need a copy of sanitizer_common. This could come from another sanitizer
   // runtime; if we're not including one, include our own copy.
   if (!HasOtherSanitizerRt)
     addSanitizerRTLinkFlags(TC, Args, CmdArgs, "san", true, false);
 
-  addSanitizerRTLinkFlags(TC, Args, CmdArgs, "ubsan", false, ExportSymbols);
+  addSanitizerRTLinkFlags(TC, Args, CmdArgs, "ubsan", false, true);
 
   // Only include the bits of the runtime which need a C++ ABI library if
   // we're linking in C++ mode.
   if (IsCXX)
-    addSanitizerRTLinkFlags(TC, Args, CmdArgs, "ubsan_cxx", false,
-                            ExportSymbols);
+    addSanitizerRTLinkFlags(TC, Args, CmdArgs, "ubsan_cxx", false, true);
 }
 
 static void addDfsanRT(const ToolChain &TC, const ArgList &Args,
index 14b14b2453aece77548abbe522c73e34a810d1ba..786262c68b84128e1e4ed5d76197af768ab667fc 100644 (file)
 // CHECK-UBSAN-LINUX-SHARED: "{{.*}}ld{{(.exe)?}}"
 // CHECK-UBSAN-LINUX-SHARED-NOT: --export-dynamic
 // CHECK-UBSAN-LINUX-SHARED-NOT: --dynamic-list
-// CHECK-UBSAN-LINUX-SHARED: libclang_rt.ubsan-i386.a"
+// CHECK-UBSAN-LINUX-SHARED-NOT: libclang_rt.ubsan-i386.a"
 // CHECK-UBSAN-LINUX-SHARED-NOT: --export-dynamic
 // CHECK-UBSAN-LINUX-SHARED-NOT: --dynamic-list