From: Alexey Samsonov Date: Wed, 17 Dec 2014 23:46:49 +0000 (+0000) Subject: [ASan] Add -ldl to linker invocation to lit tests that require it. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=658e2d274d98d44d2736da9fc77da7b9494e877a;p=platform%2Fupstream%2Fllvm.git [ASan] Add -ldl to linker invocation to lit tests that require it. This fixes these tests under dynamic ASan runtime. llvm-svn: 224473 --- diff --git a/compiler-rt/test/asan/TestCases/Linux/coverage-direct.cc b/compiler-rt/test/asan/TestCases/Linux/coverage-direct.cc index 2cc1aed..770ff90 100644 --- a/compiler-rt/test/asan/TestCases/Linux/coverage-direct.cc +++ b/compiler-rt/test/asan/TestCases/Linux/coverage-direct.cc @@ -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 diff --git a/compiler-rt/test/asan/TestCases/Linux/coverage-module-unloaded.cc b/compiler-rt/test/asan/TestCases/Linux/coverage-module-unloaded.cc index 449841e..f8d9c57 100644 --- a/compiler-rt/test/asan/TestCases/Linux/coverage-module-unloaded.cc +++ b/compiler-rt/test/asan/TestCases/Linux/coverage-module-unloaded.cc @@ -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 diff --git a/compiler-rt/test/asan/TestCases/Linux/stack-trace-dlclose.cc b/compiler-rt/test/asan/TestCases/Linux/stack-trace-dlclose.cc index e494e56..b3bd9f7 100644 --- a/compiler-rt/test/asan/TestCases/Linux/stack-trace-dlclose.cc +++ b/compiler-rt/test/asan/TestCases/Linux/stack-trace-dlclose.cc @@ -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 diff --git a/compiler-rt/test/asan/TestCases/Posix/asan-symbolize-sanity-test.cc b/compiler-rt/test/asan/TestCases/Posix/asan-symbolize-sanity-test.cc index 6ed02f4..3ce6446 100644 --- a/compiler-rt/test/asan/TestCases/Posix/asan-symbolize-sanity-test.cc +++ b/compiler-rt/test/asan/TestCases/Posix/asan-symbolize-sanity-test.cc @@ -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 diff --git a/compiler-rt/test/asan/TestCases/Posix/init-order-dlopen.cc b/compiler-rt/test/asan/TestCases/Posix/init-order-dlopen.cc index 6f20477..3c6f093 100644 --- a/compiler-rt/test/asan/TestCases/Posix/init-order-dlopen.cc +++ b/compiler-rt/test/asan/TestCases/Posix/init-order-dlopen.cc @@ -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 diff --git a/compiler-rt/test/asan/TestCases/Posix/shared-lib-test.cc b/compiler-rt/test/asan/TestCases/Posix/shared-lib-test.cc index a0827b5..305942a 100644 --- a/compiler-rt/test/asan/TestCases/Posix/shared-lib-test.cc +++ b/compiler-rt/test/asan/TestCases/Posix/shared-lib-test.cc @@ -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) diff --git a/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cc b/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cc index d60677a..2280e2a 100644 --- a/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cc +++ b/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cc @@ -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 diff --git a/compiler-rt/test/asan/TestCases/dlclose-test.cc b/compiler-rt/test/asan/TestCases/dlclose-test.cc index 094453f..2d31aee 100644 --- a/compiler-rt/test/asan/TestCases/dlclose-test.cc +++ b/compiler-rt/test/asan/TestCases/dlclose-test.cc @@ -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 diff --git a/compiler-rt/test/asan/lit.cfg b/compiler-rt/test/asan/lit.cfg index 82a36de..a2899ea 100644 --- a/compiler-rt/test/asan/lit.cfg +++ b/compiler-rt/test/asan/lit.cfg @@ -28,17 +28,19 @@ config.name = 'AddressSanitizer' + config.name_suffix # 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