Skip to content

Commit 7dc3c0f

Browse files
author
Alexey Samsonov
committed
[ASan] Explicitly specify -ldl/-lpthread in RUN-lines where needed
llvm-svn: 205623
1 parent 3f1fa3d commit 7dc3c0f

15 files changed

+51
-66
lines changed

compiler-rt/test/asan/TestCases/Linux/function-sections-are-bad.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Check that --gc-sections does not throw away (or localize) parts of sanitizer
22
// interface.
3-
// RUN: %clang_asan %s -Wl,--gc-sections -o %t
3+
// RUN: %clang_asan %s -Wl,--gc-sections -ldl -o %t
44
// RUN: %clang_asan %s -DBUILD_SO -fPIC -o %t-so.so -shared
55
// RUN: %t 2>&1
66

compiler-rt/test/asan/TestCases/Linux/stress_dtls.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// RUN: %clangxx_asan -x c -DSO_NAME=f0 %s -shared -o %t-f0.so -fPIC
1010
// RUN: %clangxx_asan -x c -DSO_NAME=f1 %s -shared -o %t-f1.so -fPIC
1111
// RUN: %clangxx_asan -x c -DSO_NAME=f2 %s -shared -o %t-f2.so -fPIC
12-
// RUN: %clangxx_asan %s -o %t
12+
// RUN: %clangxx_asan %s -ldl -lpthread -o %t
1313
// RUN: %t 0 3
1414
// RUN: %t 2 3
1515
// RUN: ASAN_OPTIONS=verbosity=2 %t 10 2 2>&1 | FileCheck %s

compiler-rt/test/asan/TestCases/Linux/tsd_dtor_leak.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Regression test for a leak in tsd:
22
// https://code.google.com/p/address-sanitizer/issues/detail?id=233
3-
// RUN: %clangxx_asan -O1 %s -o %t
3+
// RUN: %clangxx_asan -O1 %s -lpthread -o %t
44
// RUN: ASAN_OPTIONS=quarantine_size=1 %t
55
#include <pthread.h>
66
#include <stdio.h>

compiler-rt/test/asan/TestCases/Linux/unpoison_tls.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Test that TLS is unpoisoned on thread death.
22
// REQUIRES: x86_64-supported-target,i386-supported-target
33

4-
// RUN: %clangxx_asan -O1 %s -o %t && %t 2>&1
4+
// RUN: %clangxx_asan -O1 %s -lpthread -o %t && %t 2>&1
55

66
#include <assert.h>
77
#include <pthread.h>

compiler-rt/test/asan/TestCases/asan-symbolize-sanity-test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// shared object files.
33

44
// RUN: %clangxx_asan -O0 %p/SharedLibs/shared-lib-test-so.cc -fPIC -shared -o %t-so.so
5-
// RUN: %clangxx_asan -O0 %s -o %t
5+
// RUN: %clangxx_asan -O0 %s -ldl -o %t
66
// RUN: ASAN_OPTIONS=symbolize=0 not %t 2>&1 | %asan_symbolize | FileCheck %s
77
#include <dlfcn.h>
88
#include <stdio.h>

compiler-rt/test/asan/TestCases/current_allocated_bytes.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clangxx_asan -O0 %s -o %t && %t
2-
// RUN: %clangxx_asan -O2 %s -o %t && %t
1+
// RUN: %clangxx_asan -O0 %s -lpthread -o %t && %t
2+
// RUN: %clangxx_asan -O2 %s -lpthread -o %t && %t
33

44
#include <assert.h>
55
#include <pthread.h>

compiler-rt/test/asan/TestCases/deep_thread_stack.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %clangxx_asan -O0 %s -o %t && not %t 2>&1 | FileCheck %s
2-
// RUN: %clangxx_asan -O1 %s -o %t && not %t 2>&1 | FileCheck %s
3-
// RUN: %clangxx_asan -O2 %s -o %t && not %t 2>&1 | FileCheck %s
4-
// RUN: %clangxx_asan -O3 %s -o %t && not %t 2>&1 | FileCheck %s
1+
// RUN: %clangxx_asan -O0 %s -lpthread -o %t && not %t 2>&1 | FileCheck %s
2+
// RUN: %clangxx_asan -O1 %s -lpthread -o %t && not %t 2>&1 | FileCheck %s
3+
// RUN: %clangxx_asan -O2 %s -lpthread -o %t && not %t 2>&1 | FileCheck %s
4+
// RUN: %clangxx_asan -O3 %s -lpthread -o %t && not %t 2>&1 | FileCheck %s
55

66
#include <pthread.h>
77

compiler-rt/test/asan/TestCases/dlclose-test.cc

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,14 @@
1414
// It works on i368/x86_64 Linux, but not necessary anywhere else.
1515
// REQUIRES: x86_64-supported-target,i386-supported-target
1616

17-
// RUN: %clangxx_asan -O0 %p/SharedLibs/dlclose-test-so.cc \
18-
// RUN: -fPIC -shared -o %t-so.so
19-
// RUN: %clangxx_asan -O0 %s -o %t && %t 2>&1 | FileCheck %s
20-
// RUN: %clangxx_asan -O1 %p/SharedLibs/dlclose-test-so.cc \
21-
// RUN: -fPIC -shared -o %t-so.so
22-
// RUN: %clangxx_asan -O1 %s -o %t && %t 2>&1 | FileCheck %s
23-
// RUN: %clangxx_asan -O2 %p/SharedLibs/dlclose-test-so.cc \
24-
// RUN: -fPIC -shared -o %t-so.so
25-
// RUN: %clangxx_asan -O2 %s -o %t && %t 2>&1 | FileCheck %s
26-
// RUN: %clangxx_asan -O3 %p/SharedLibs/dlclose-test-so.cc \
27-
// RUN: -fPIC -shared -o %t-so.so
28-
// RUN: %clangxx_asan -O3 %s -o %t && %t 2>&1 | FileCheck %s
17+
// RUN: %clangxx_asan -O0 %p/SharedLibs/dlclose-test-so.cc -fPIC -shared -o %t-so.so
18+
// RUN: %clangxx_asan -O0 %s -ldl -o %t && %t 2>&1 | FileCheck %s
19+
// RUN: %clangxx_asan -O1 %p/SharedLibs/dlclose-test-so.cc -fPIC -shared -o %t-so.so
20+
// RUN: %clangxx_asan -O1 %s -ldl -o %t && %t 2>&1 | FileCheck %s
21+
// RUN: %clangxx_asan -O2 %p/SharedLibs/dlclose-test-so.cc -fPIC -shared -o %t-so.so
22+
// RUN: %clangxx_asan -O2 %s -ldl -o %t && %t 2>&1 | FileCheck %s
23+
// RUN: %clangxx_asan -O3 %p/SharedLibs/dlclose-test-so.cc -fPIC -shared -o %t-so.so
24+
// RUN: %clangxx_asan -O3 %s -ldl -o %t && %t 2>&1 | FileCheck %s
2925

3026
#include <assert.h>
3127
#include <dlfcn.h>

compiler-rt/test/asan/TestCases/gc-test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx_asan %s -o %t
1+
// RUN: %clangxx_asan %s -lpthread -o %t
22
// RUN: ASAN_OPTIONS=detect_stack_use_after_return=1 %t 2>&1 | FileCheck %s --check-prefix=CHECK1
33
// RUN: ASAN_OPTIONS=detect_stack_use_after_return=0 %t 2>&1 | FileCheck %s --check-prefix=CHECK0
44

compiler-rt/test/asan/TestCases/init-order-dlopen.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
// If the linker doesn't support --export-dynamic (which is ELF-specific),
1111
// try to link without that option.
1212
// FIXME: find a better solution.
13-
// RUN: %clangxx_asan -O0 %s -o %t -Wl,--export-dynamic || \
14-
// RUN: %clangxx_asan -O0 %s -o %t
13+
// RUN: %clangxx_asan -O0 %s -lpthread -ldl -o %t -Wl,--export-dynamic || \
14+
// RUN: %clangxx_asan -O0 %s -lpthread -ldl -o %t
1515
// RUN: ASAN_OPTIONS=strict_init_order=true %t 2>&1 | FileCheck %s
1616
#include <dlfcn.h>
1717
#include <pthread.h>

compiler-rt/test/asan/TestCases/init-order-pthread-create.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Check that init-order checking is properly disabled if pthread_create is
22
// called.
33

4-
// RUN: %clangxx_asan %s %p/Helpers/init-order-pthread-create-extra.cc -o %t
4+
// RUN: %clangxx_asan %s %p/Helpers/init-order-pthread-create-extra.cc -lpthread -o %t
55
// RUN: ASAN_OPTIONS=strict_init_order=true %t
66

77
#include <stdio.h>

compiler-rt/test/asan/TestCases/shared-lib-test.cc

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
// RUN: %clangxx_asan -O0 %p/SharedLibs/shared-lib-test-so.cc \
2-
// RUN: -fPIC -shared -o %t-so.so
3-
// RUN: %clangxx_asan -O0 %s -o %t && not %t 2>&1 | FileCheck %s
4-
// RUN: %clangxx_asan -O1 %p/SharedLibs/shared-lib-test-so.cc \
5-
// RUN: -fPIC -shared -o %t-so.so
6-
// RUN: %clangxx_asan -O1 %s -o %t && not %t 2>&1 | FileCheck %s
7-
// RUN: %clangxx_asan -O2 %p/SharedLibs/shared-lib-test-so.cc \
8-
// RUN: -fPIC -shared -o %t-so.so
9-
// RUN: %clangxx_asan -O2 %s -o %t && not %t 2>&1 | FileCheck %s
10-
// RUN: %clangxx_asan -O3 %p/SharedLibs/shared-lib-test-so.cc \
11-
// RUN: -fPIC -shared -o %t-so.so
12-
// RUN: %clangxx_asan -O3 %s -o %t && not %t 2>&1 | FileCheck %s
1+
// RUN: %clangxx_asan -O0 %p/SharedLibs/shared-lib-test-so.cc -fPIC -shared -o %t-so.so
2+
// RUN: %clangxx_asan -O0 %s -ldl -o %t && not %t 2>&1 | FileCheck %s
3+
// RUN: %clangxx_asan -O1 %p/SharedLibs/shared-lib-test-so.cc -fPIC -shared -o %t-so.so
4+
// RUN: %clangxx_asan -O1 %s -ldl -o %t && not %t 2>&1 | FileCheck %s
5+
// RUN: %clangxx_asan -O2 %p/SharedLibs/shared-lib-test-so.cc -fPIC -shared -o %t-so.so
6+
// RUN: %clangxx_asan -O2 %s -ldl -o %t && not %t 2>&1 | FileCheck %s
7+
// RUN: %clangxx_asan -O3 %p/SharedLibs/shared-lib-test-so.cc -fPIC -shared -o %t-so.so
8+
// RUN: %clangxx_asan -O3 %s -ldl -o %t && not %t 2>&1 | FileCheck %s
139

1410
#include <dlfcn.h>
1511
#include <stdio.h>

compiler-rt/test/asan/TestCases/stack-overflow.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
// Test ASan detection of stack-overflow condition.
22

3-
// RUN: %clangxx_asan -O0 %s -DSMALL_FRAME -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
4-
// RUN: %clangxx_asan -O3 %s -DSMALL_FRAME -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
5-
// RUN: %clangxx_asan -O0 %s -DSAVE_ALL_THE_REGISTERS -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
6-
// RUN: %clangxx_asan -O3 %s -DSAVE_ALL_THE_REGISTERS -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
7-
// RUN: %clangxx_asan -O0 %s -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
8-
// RUN: %clangxx_asan -O3 %s -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
3+
// RUN: %clangxx_asan -O0 %s -DSMALL_FRAME -lpthread -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
4+
// RUN: %clangxx_asan -O3 %s -DSMALL_FRAME -lpthread -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
5+
// RUN: %clangxx_asan -O0 %s -DSAVE_ALL_THE_REGISTERS -lpthread -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
6+
// RUN: %clangxx_asan -O3 %s -DSAVE_ALL_THE_REGISTERS -lpthread -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
7+
// RUN: %clangxx_asan -O0 %s -lpthread -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
8+
// RUN: %clangxx_asan -O3 %s -lpthread -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
99

10-
// RUN: %clangxx_asan -O0 %s -DTHREAD -DSMALL_FRAME -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
11-
// RUN: %clangxx_asan -O3 %s -DTHREAD -DSMALL_FRAME -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
12-
// RUN: %clangxx_asan -O0 %s -DTHREAD -DSAVE_ALL_THE_REGISTERS -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
13-
// RUN: %clangxx_asan -O3 %s -DTHREAD -DSAVE_ALL_THE_REGISTERS -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
14-
// RUN: %clangxx_asan -O0 %s -DTHREAD -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
15-
// RUN: %clangxx_asan -O3 %s -DTHREAD -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
10+
// RUN: %clangxx_asan -O0 %s -DTHREAD -DSMALL_FRAME -lpthread -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
11+
// RUN: %clangxx_asan -O3 %s -DTHREAD -DSMALL_FRAME -lpthread -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
12+
// RUN: %clangxx_asan -O0 %s -DTHREAD -DSAVE_ALL_THE_REGISTERS -lpthread -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
13+
// RUN: %clangxx_asan -O3 %s -DTHREAD -DSAVE_ALL_THE_REGISTERS -lpthread -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
14+
// RUN: %clangxx_asan -O0 %s -DTHREAD -lpthread -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
15+
// RUN: %clangxx_asan -O3 %s -DTHREAD -lpthread -o %t && ASAN_OPTIONS=use_sigaltstack=1 not %t 2>&1 | FileCheck %s
1616

1717
#include <assert.h>
1818
#include <stdlib.h>

compiler-rt/test/asan/TestCases/stack-use-after-return.cc

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
// RUN: export ASAN_OPTIONS=detect_stack_use_after_return=1
2-
// RUN: %clangxx_asan -O0 %s -o %t && \
3-
// RUN: not %t 2>&1 | FileCheck %s
4-
// RUN: %clangxx_asan -O1 %s -o %t && \
5-
// RUN: not %t 2>&1 | FileCheck %s
6-
// RUN: %clangxx_asan -O2 %s -o %t && \
7-
// RUN: not %t 2>&1 | FileCheck %s
8-
// RUN: %clangxx_asan -O3 %s -o %t && \
9-
// RUN: not %t 2>&1 | FileCheck %s
2+
// RUN: %clangxx_asan -O0 %s -lpthread -o %t && not %t 2>&1 | FileCheck %s
3+
// RUN: %clangxx_asan -O1 %s -lpthread -o %t && not %t 2>&1 | FileCheck %s
4+
// RUN: %clangxx_asan -O2 %s -lpthread -o %t && not %t 2>&1 | FileCheck %s
5+
// RUN: %clangxx_asan -O3 %s -lpthread -o %t && not %t 2>&1 | FileCheck %s
106
// RUN: ASAN_OPTIONS=detect_stack_use_after_return=0 %t
117
// Regression test for a CHECK failure with small stack size and large frame.
12-
// RUN: %clangxx_asan -O3 %s -o %t -DkSize=10000 -DUseThread -DkStackSize=65536 && \
13-
// RUN: not %t 2>&1 | FileCheck --check-prefix=THREAD %s
8+
// RUN: %clangxx_asan -O3 %s -lpthread -o %t -DkSize=10000 -DUseThread -DkStackSize=65536 && not %t 2>&1 | FileCheck --check-prefix=THREAD %s
149
//
1510
// Test that we can find UAR in a thread other than main:
16-
// RUN: %clangxx_asan -DUseThread -O2 %s -o %t && \
17-
// RUN: not %t 2>&1 | FileCheck --check-prefix=THREAD %s
11+
// RUN: %clangxx_asan -DUseThread -O2 %s -lpthread -o %t && not %t 2>&1 | FileCheck --check-prefix=THREAD %s
1812
//
1913
// Test the max_uar_stack_size_log/min_uar_stack_size_log flag.
2014
//

compiler-rt/test/asan/TestCases/start-deactivated.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
// Main executable is uninstrumented, but linked to ASan runtime. The shared
33
// library is instrumented. Memory errors before dlopen are not detected.
44

5-
// RUN: %clangxx_asan -O0 %p/SharedLibs/start-deactivated-so.cc \
6-
// RUN: -fPIC -shared -o %t-so.so
5+
// RUN: %clangxx_asan -O0 %p/SharedLibs/start-deactivated-so.cc -fPIC -shared -o %t-so.so
76
// RUN: %clangxx -O0 %s -c -o %t.o
8-
// RUN: %clangxx_asan -O0 %t.o -o %t
7+
// RUN: %clangxx_asan -O0 %t.o -ldl -o %t
98
// RUN: ASAN_OPTIONS=start_deactivated=1 not %t 2>&1 | FileCheck %s
109

1110
#include <dlfcn.h>

0 commit comments

Comments
 (0)