[compiler-rt] r224473 - [ASan] Add -ldl to linker invocation to lit tests that require it.

Alexey Samsonov vonosmas at gmail.com
Wed Dec 17 15:46:49 PST 2014


Author: samsonov
Date: Wed Dec 17 17:46:49 2014
New Revision: 224473

URL: http://llvm.org/viewvc/llvm-project?rev=224473&view=rev
Log:
[ASan] Add -ldl to linker invocation to lit tests that require it.

This fixes these tests under dynamic ASan runtime.

Modified:
    compiler-rt/trunk/test/asan/TestCases/Linux/coverage-direct.cc
    compiler-rt/trunk/test/asan/TestCases/Linux/coverage-module-unloaded.cc
    compiler-rt/trunk/test/asan/TestCases/Linux/stack-trace-dlclose.cc
    compiler-rt/trunk/test/asan/TestCases/Posix/asan-symbolize-sanity-test.cc
    compiler-rt/trunk/test/asan/TestCases/Posix/init-order-dlopen.cc
    compiler-rt/trunk/test/asan/TestCases/Posix/shared-lib-test.cc
    compiler-rt/trunk/test/asan/TestCases/Posix/start-deactivated.cc
    compiler-rt/trunk/test/asan/TestCases/dlclose-test.cc
    compiler-rt/trunk/test/asan/lit.cfg

Modified: compiler-rt/trunk/test/asan/TestCases/Linux/coverage-direct.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/coverage-direct.cc?rev=224473&r1=224472&r2=224473&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/coverage-direct.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/coverage-direct.cc Wed Dec 17 17:46:49 2014
@@ -1,6 +1,6 @@
 // Test for direct coverage writing with dlopen.
 // RUN: %clangxx_asan -fsanitize-coverage=1 -DSHARED %s -shared -o %T/libcoverage_direct_test_1.so -fPIC
-// RUN: %clangxx_asan -fsanitize-coverage=1 -DSO_DIR=\"%T\" %s -o %t
+// RUN: %clangxx_asan -fsanitize-coverage=1 -DSO_DIR=\"%T\" %s %libdl -o %t
 
 // RUN: rm -rf %T/coverage-direct
 

Modified: compiler-rt/trunk/test/asan/TestCases/Linux/coverage-module-unloaded.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/coverage-module-unloaded.cc?rev=224473&r1=224472&r2=224473&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/coverage-module-unloaded.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/coverage-module-unloaded.cc Wed Dec 17 17:46:49 2014
@@ -2,7 +2,7 @@
 // modules.
 // RUN: %clangxx_asan -fsanitize-coverage=1 -DSHARED %s -shared -o %T/libcoverage_module_unloaded_test_1.so -fPIC
 // RUN: %clangxx_asan -fsanitize-coverage=1 -DSHARED %s -shared -o %T/libcoverage_module_unloaded_test_2.so -fPIC
-// RUN: %clangxx_asan -fsanitize-coverage=1 -DSO_DIR=\"%T\" %s -o %t
+// RUN: %clangxx_asan -fsanitize-coverage=1 -DSO_DIR=\"%T\" %s %libdl -o %t
 // RUN: export ASAN_OPTIONS=coverage=1:verbosity=1
 // RUN: mkdir -p %T/coverage-module-unloaded && cd %T/coverage-module-unloaded
 // RUN: %run %t 2>&1         | FileCheck %s

Modified: compiler-rt/trunk/test/asan/TestCases/Linux/stack-trace-dlclose.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/stack-trace-dlclose.cc?rev=224473&r1=224472&r2=224473&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/stack-trace-dlclose.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/stack-trace-dlclose.cc Wed Dec 17 17:46:49 2014
@@ -2,7 +2,7 @@
 // XFAIL: android
 //
 // RUN: %clangxx_asan -DSHARED %s -shared -o %T/stack_trace_dlclose.so -fPIC
-// RUN: %clangxx_asan -DSO_DIR=\"%T\" %s -o %t
+// RUN: %clangxx_asan -DSO_DIR=\"%T\" %s %libdl -o %t
 // RUN: ASAN_OPTIONS=exitcode=0 %run %t 2>&1 | FileCheck %s
 // XFAIL: arm-linux-gnueabi
 // XFAIL: armv7l-unknown-linux-gnueabihf

Modified: compiler-rt/trunk/test/asan/TestCases/Posix/asan-symbolize-sanity-test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/asan-symbolize-sanity-test.cc?rev=224473&r1=224472&r2=224473&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Posix/asan-symbolize-sanity-test.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Posix/asan-symbolize-sanity-test.cc Wed Dec 17 17:46:49 2014
@@ -5,7 +5,7 @@
 // shared object files.
 
 // RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
-// RUN: %clangxx_asan -O0 %s -o %t
+// RUN: %clangxx_asan -O0 %s %libdl -o %t
 // RUN: env ASAN_OPTIONS=symbolize=0 not %run %t 2>&1 | %asan_symbolize | FileCheck %s
 // XFAIL: arm-linux-gnueabi
 // XFAIL: armv7l-unknown-linux-gnueabihf

Modified: compiler-rt/trunk/test/asan/TestCases/Posix/init-order-dlopen.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/init-order-dlopen.cc?rev=224473&r1=224472&r2=224473&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Posix/init-order-dlopen.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Posix/init-order-dlopen.cc Wed Dec 17 17:46:49 2014
@@ -10,8 +10,8 @@
 // If the linker doesn't support --export-dynamic (which is ELF-specific),
 // try to link without that option.
 // FIXME: find a better solution.
-// RUN: %clangxx_asan -O0 %s -pthread -o %t -Wl,--export-dynamic || \
-// RUN:     %clangxx_asan -O0 %s -pthread -o %t
+// RUN: %clangxx_asan -O0 %s -pthread %libdl -o %t -Wl,--export-dynamic || \
+// RUN:     %clangxx_asan -O0 %s -pthread %libdl -o %t
 // RUN: ASAN_OPTIONS=strict_init_order=true %run %t 2>&1 | FileCheck %s
 #if !defined(SHARED_LIB)
 #include <dlfcn.h>

Modified: compiler-rt/trunk/test/asan/TestCases/Posix/shared-lib-test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/shared-lib-test.cc?rev=224473&r1=224472&r2=224473&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Posix/shared-lib-test.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Posix/shared-lib-test.cc Wed Dec 17 17:46:49 2014
@@ -1,11 +1,11 @@
 // RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
-// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan -O0 %s %libdl -o %t && not %run %t 2>&1 | FileCheck %s
 // RUN: %clangxx_asan -O1 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
-// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan -O1 %s %libdl -o %t && not %run %t 2>&1 | FileCheck %s
 // RUN: %clangxx_asan -O2 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
-// RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan -O2 %s %libdl -o %t && not %run %t 2>&1 | FileCheck %s
 // RUN: %clangxx_asan -O3 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
-// RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan -O3 %s %libdl -o %t && not %run %t 2>&1 | FileCheck %s
 // XFAIL: arm-linux-gnueabi
 
 #if !defined(SHARED_LIB)

Modified: compiler-rt/trunk/test/asan/TestCases/Posix/start-deactivated.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/start-deactivated.cc?rev=224473&r1=224472&r2=224473&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Posix/start-deactivated.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Posix/start-deactivated.cc Wed Dec 17 17:46:49 2014
@@ -4,7 +4,7 @@
 
 // RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
 // RUN: %clangxx -O0 %s -c -o %t.o
-// RUN: %clangxx_asan -O0 %t.o -o %t
+// RUN: %clangxx_asan -O0 %t.o %libdl -o %t
 // RUN: ASAN_OPTIONS=start_deactivated=1 not %run %t 2>&1 | FileCheck %s
 // XFAIL: arm-linux-gnueabi
 // XFAIL: armv7l-unknown-linux-gnueabihf

Modified: compiler-rt/trunk/test/asan/TestCases/dlclose-test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/dlclose-test.cc?rev=224473&r1=224472&r2=224473&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/dlclose-test.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/dlclose-test.cc Wed Dec 17 17:46:49 2014
@@ -15,13 +15,13 @@
 // REQUIRES: x86_64-supported-target,i386-supported-target
 
 // RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
-// RUN: %clangxx_asan -O0 %s -o %t && %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan -O0 %s %libdl -o %t && %run %t 2>&1 | FileCheck %s
 // RUN: %clangxx_asan -O1 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
-// RUN: %clangxx_asan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan -O1 %s %libdl -o %t && %run %t 2>&1 | FileCheck %s
 // RUN: %clangxx_asan -O2 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
-// RUN: %clangxx_asan -O2 %s -o %t && %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan -O2 %s %libdl -o %t && %run %t 2>&1 | FileCheck %s
 // RUN: %clangxx_asan -O3 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
-// RUN: %clangxx_asan -O3 %s -o %t && %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan -O3 %s %libdl -o %t && %run %t 2>&1 | FileCheck %s
 
 #if !defined(SHARED_LIB)
 #include <assert.h>

Modified: compiler-rt/trunk/test/asan/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/lit.cfg?rev=224473&r1=224472&r2=224473&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/lit.cfg (original)
+++ compiler-rt/trunk/test/asan/lit.cfg Wed Dec 17 17:46:49 2014
@@ -28,17 +28,19 @@ config.name = 'AddressSanitizer' + confi
 # Setup source root.
 config.test_source_root = os.path.dirname(__file__)
 
+# There is no libdl on FreeBSD.
+if config.host_os != 'FreeBSD':
+  libdl_flag = "-ldl"
+else:
+  libdl_flag = ""
+
 # GCC-ASan doesn't link in all the necessary libraries automatically, so
 # we have to do it ourselves.
 if config.compiler_id == 'GNU':
-  extra_linkflags = ["-pthread", "-lstdc++"]
+  extra_linkflags = ["-pthread", "-lstdc++", libdl_flag]
 else:
   extra_linkflags = []
 
-# There is no libdl on FreeBSD.
-if config.compiler_id == 'GNU' and config.host_os != 'FreeBSD':
-  extra_linkflags += ["-ldl"]
-
 # Setup default compiler flags used with -fsanitize=address option.
 # FIXME: Review the set of required flags and check if it can be reduced.
 target_cflags = [get_required_attr(config, "target_cflags")] + extra_linkflags
@@ -121,6 +123,8 @@ else:
 
 config.substitutions.append( ('CHECK-%kernel_bits', ("CHECK-kernel-" + kernel_bits + "-bits")))
 
+config.substitutions.append( ("%libdl", libdl_flag) )
+
 config.available_features.add("asan-" + config.bits + "-bits")
 
 # Allow tests to use REQUIRES=stable-runtime.  For use when you cannot use XFAIL





More information about the llvm-commits mailing list