Skip to content

Commit 7624197

Browse files
Reapply "[compiler-rt] Remove %T from shared object substitutions (#155302)"
This reverts commit 1d3c302. There were three test failures: odr-violation.cpp - Attempted to fix by keeping everything in the same folder. interception-in-shared-lib-test.cpp - Tried folding comments to preserve line numberings. Almost seems like a debug info issue on PPC. odr_c_test.c - Attempted to fix by keeping everything in the same folder.
1 parent a997d45 commit 7624197

25 files changed

+58
-44
lines changed

compiler-rt/test/asan/TestCases/Linux/coverage-missing.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
// Test for "sancov.py missing ...".
22

33
// First case: coverage from executable. main() is called on every code path.
4+
// RUN: rm -rf %t.dir && mkdir -p %t.dir && cd %t.dir
45
// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard %s -o %t -DFOOBAR -DMAIN
5-
// RUN: rm -rf %t-dir
6-
// RUN: mkdir -p %t-dir
7-
// RUN: cd %t-dir
8-
// RUN: %env_asan_opts=coverage=1:coverage_dir=%t-dir %run %t
6+
// RUN: %env_asan_opts=coverage=1:coverage_dir=%t.dir %run %t
97
// RUN: %sancov print *.sancov > main.txt
108
// RUN: rm *.sancov
119
// RUN: count 1 < main.txt
12-
// RUN: %env_asan_opts=coverage=1:coverage_dir=%t-dir %run %t x
10+
// RUN: %env_asan_opts=coverage=1:coverage_dir=%t.dir %run %t x
1311
// RUN: %sancov print *.sancov > foo.txt
1412
// RUN: rm *.sancov
1513
// RUN: count 3 < foo.txt
16-
// RUN: %env_asan_opts=coverage=1:coverage_dir=%t-dir %run %t x x
14+
// RUN: %env_asan_opts=coverage=1:coverage_dir=%t.dir %run %t x x
1715
// RUN: %sancov print *.sancov > bar.txt
1816
// RUN: rm *.sancov
1917
// RUN: count 4 < bar.txt
@@ -26,18 +24,15 @@
2624
// RUN: not grep "^<" %t.log
2725

2826
// Second case: coverage from DSO.
29-
// cd %t-dir
27+
// RUN: cd ..
28+
// RUN: rm -rf %t.dir && mkdir -p %t.dir && cd %t.dir
3029
// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard %s -o %dynamiclib -DFOOBAR -shared -fPIC
3130
// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard %s %dynamiclib -o %t -DMAIN
32-
// RUN: cd ..
33-
// RUN: rm -rf %t-dir
34-
// RUN: mkdir -p %t-dir
35-
// RUN: cd %t-dir
36-
// RUN: %env_asan_opts=coverage=1:coverage_dir=%t-dir %run %t x
31+
// RUN: %env_asan_opts=coverage=1:coverage_dir=%t.dir %run %t x
3732
// RUN: %sancov print %xdynamiclib_filename.*.sancov > foo.txt
3833
// RUN: rm *.sancov
3934
// RUN: count 2 < foo.txt
40-
// RUN: %env_asan_opts=coverage=1:coverage_dir=%t-dir %run %t x x
35+
// RUN: %env_asan_opts=coverage=1:coverage_dir=%t.dir %run %t x x
4136
// RUN: %sancov print %xdynamiclib_filename.*.sancov > bar.txt
4237
// RUN: rm *.sancov
4338
// RUN: count 3 < bar.txt

compiler-rt/test/asan/TestCases/Linux/local_alias.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// false positive global-buffer-overflow due to sanitized library poisons
55
// globals from non-sanitized one.
66
//
7+
// RUN: mkdir -p %t.dir && cd %t.dir
78
// RUN: %clangxx_asan -DBUILD_INSTRUMENTED_DSO=1 -fPIC -shared -mllvm -asan-use-private-alias %s -o %dynamiclib1
89
// RUN: %clangxx -DBUILD_UNINSTRUMENTED_DSO=1 -fPIC -shared %s -o %dynamiclib2
910
// RUN: %clangxx %s -c -mllvm -asan-use-private-alias -o %t.o

compiler-rt/test/asan/TestCases/Linux/odr-violation.cpp

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,39 @@
1010
// -fno-sanitize-address-use-odr-indicator turns off both.
1111
//
1212
// Different size: detect a bug if detect_odr_violation>=1
13+
// RUN: mkdir -p %t.dir && cd %t.dir
1314
// RUN: %clangxx_asan -g -DBUILD_SO=1 -fPIC -shared -fno-sanitize-address-use-odr-indicator %s -o %dynamiclib
14-
// RUN: %clangxx_asan -g -fno-sanitize-address-use-odr-indicator %s %ld_flags_rpath_exe -o %t-ODR-EXE
15-
// RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=1 not %run %t-ODR-EXE 2>&1 | FileCheck %s
16-
// RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2 not %run %t-ODR-EXE 2>&1 | FileCheck %s
17-
// RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=0 %run %t-ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED
18-
// RUN: %env_asan_opts=fast_unwind_on_malloc=0 not %run %t-ODR-EXE 2>&1 | FileCheck %s
15+
// RUN: %clangxx_asan -g -fno-sanitize-address-use-odr-indicator %s %ld_flags_rpath_exe -o %t.dir/ODR-EXE
16+
// RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=1 not %run %t.dir/ODR-EXE 2>&1 | FileCheck %s
17+
// RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2 not %run %t.dir/ODR-EXE 2>&1 | FileCheck %s
18+
// RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=0 %run %t.dir/ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED
19+
// RUN: %env_asan_opts=fast_unwind_on_malloc=0 not %run %t.dir/ODR-EXE 2>&1 | FileCheck %s
1920
//
2021
// Same size: report a bug only if detect_odr_violation>=2.
2122
// RUN: %clangxx_asan -g -DBUILD_SO=1 -fPIC -shared -fno-sanitize-address-use-odr-indicator %s -o %dynamiclib -DSZ=100
22-
// RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=1 %run %t-ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED
23-
// RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2 not %run %t-ODR-EXE 2>&1 | FileCheck %s
24-
// RUN: %env_asan_opts=fast_unwind_on_malloc=0 not %run %t-ODR-EXE 2>&1 | FileCheck %s
25-
// RUN: echo "odr_violation:foo::ZZZ" > %t.supp
26-
// RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2:suppressions=%t.supp not %run %t-ODR-EXE 2>&1 | FileCheck %s
27-
// RUN: echo "odr_violation:foo::G" > %t.supp
28-
// RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2:suppressions=%t.supp %run %t-ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED
29-
// RUN: rm -f %t.supp
23+
// RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=1 %run %t.dir/ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED
24+
// RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2 not %run %t.dir/ODR-EXE 2>&1 | FileCheck %s
25+
// RUN: %env_asan_opts=fast_unwind_on_malloc=0 not %run %t.dir/ODR-EXE 2>&1 | FileCheck %s
26+
// RUN: echo "odr_violation:foo::ZZZ" > %t.dir/supp
27+
// RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2:suppressions=%t.dir/supp not %run %t.dir/ODR-EXE 2>&1 | FileCheck %s
28+
// RUN: echo "odr_violation:foo::G" > %t.dir/supp
29+
// RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2:suppressions=%t.dir/supp %run %t.dir/ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED
30+
// RUN: rm -f %t.dir/supp
3031
//
3132
// Use private aliases for global variables without indicator symbol.
3233
// RUN: %clangxx_asan -g -DBUILD_SO=1 -fPIC -shared -mllvm -asan-use-odr-indicator=0 %s -o %dynamiclib -DSZ=100
33-
// RUN: %clangxx_asan -g -mllvm -asan-use-odr-indicator=0 %s %ld_flags_rpath_exe -o %t-ODR-EXE
34-
// RUN: %env_asan_opts=fast_unwind_on_malloc=0 %run %t-ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED
34+
// RUN: %clangxx_asan -g -mllvm -asan-use-odr-indicator=0 %s %ld_flags_rpath_exe -o %t.dir/ODR-EXE
35+
// RUN: %env_asan_opts=fast_unwind_on_malloc=0 %run %t.dir/ODR-EXE 2>&1 | FileCheck %s --check-prefix=DISABLED
3536

3637
// Use private aliases for global variables: use indicator symbol to detect ODR violation.
3738
// RUN: %clangxx_asan -g -DBUILD_SO=1 -fPIC -shared %s -o %dynamiclib -DSZ=100
38-
// RUN: %clangxx_asan -g %s %ld_flags_rpath_exe -o %t-ODR-EXE
39-
// RUN: %env_asan_opts=fast_unwind_on_malloc=0 not %run %t-ODR-EXE 2>&1 | FileCheck %s
39+
// RUN: %clangxx_asan -g %s %ld_flags_rpath_exe -o %t.dir/ODR-EXE
40+
// RUN: %env_asan_opts=fast_unwind_on_malloc=0 not %run %t.dir/ODR-EXE 2>&1 | FileCheck %s
4041

4142
// Same as above but with clang switches.
4243
// RUN: %clangxx_asan -g -DBUILD_SO=1 -fPIC -shared -fsanitize-address-use-odr-indicator %s -o %dynamiclib -DSZ=100
43-
// RUN: %clangxx_asan -g -fsanitize-address-use-odr-indicator %s %ld_flags_rpath_exe -o %t-ODR-EXE
44-
// RUN: %env_asan_opts=fast_unwind_on_malloc=0 not %run %t-ODR-EXE 2>&1 | FileCheck %s
44+
// RUN: %clangxx_asan -g -fsanitize-address-use-odr-indicator %s %ld_flags_rpath_exe -o %t.dir/ODR-EXE
45+
// RUN: %env_asan_opts=fast_unwind_on_malloc=0 not %run %t.dir/ODR-EXE 2>&1 | FileCheck %s
4546

4647
// GNU driver doesn't handle .so files properly.
4748
// REQUIRES: Clang
@@ -58,7 +59,7 @@ namespace foo { char G[SZ]; }
5859
#include <stdio.h>
5960
namespace foo { char G[100]; }
6061
// CHECK: ERROR: AddressSanitizer: odr-violation
61-
// CHECK: size=100 'foo::G' {{.*}}odr-violation.cpp:[[@LINE-2]] in {{.*}}.tmp-ODR-EXE
62+
// CHECK: size=100 'foo::G' {{.*}}odr-violation.cpp:[[@LINE-2]] in {{.*}}/ODR-EXE
6263
// CHECK: size={{4|100}} 'foo::G'
6364
int main(int argc, char **argv) {
6465
printf("PASS: %p\n", &foo::G);

compiler-rt/test/asan/TestCases/Linux/odr-vtable.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// REQUIRES: shared_cxxabi
55

66
/// Not using private alias or enabling ODR indicator can detect ODR issues.
7+
// RUN: mkdir -p %t.dir && cd %t.dir
78
// RUN: %clangxx_asan -fno-rtti -DBUILD_SO1 -fPIC -shared -mllvm -asan-use-private-alias=0 %s -o %dynamiclib1
89
// RUN: %clangxx_asan -fno-rtti -DBUILD_SO2 -fPIC -shared -mllvm -asan-use-private-alias=0 %s -o %dynamiclib2
910
// RUN: %clangxx_asan -fno-rtti %s %ld_flags_rpath_exe1 %ld_flags_rpath_exe2 -o %t

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
// Test that we can properly report an ODR violation between an instrumented
22
// global and a non-instrumented global if not using private aliases.
33

4+
// RUN: mkdir -p %t.dir && cd %t.dir
45
// RUN: %clang_asan -fcommon %s -fPIC -shared -mllvm -asan-use-private-alias=0 -o %dynamiclib1 -DFILE1
56
// RUN: %clang_asan -fcommon %s -fPIC -shared -mllvm -asan-use-private-alias=0 -o %dynamiclib2 -DFILE2
6-
// RUN: %clang_asan -fcommon %s -fPIE %ld_flags_rpath_exe1 %ld_flags_rpath_exe2 -o %t
7-
// RUN: not %run %t 2>&1 | FileCheck %s
7+
// RUN: %clang_asan -fcommon %s -fPIE %ld_flags_rpath_exe1 %ld_flags_rpath_exe2 -o %t.dir/exe
8+
// RUN: not %run %t.dir/exe 2>&1 | FileCheck %s
89

910
// RUN: %clang_asan -fcommon %s -fPIC -shared -mllvm -asan-use-private-alias=1 -o %dynamiclib1 -DFILE1
1011
// RUN: %clang_asan -fcommon %s -fPIC -shared -mllvm -asan-use-private-alias=1 -o %dynamiclib2 -DFILE2
11-
// RUN: %run %t 2>&1 | count 0
12+
// RUN: %run %t.dir/exe 2>&1 | count 0
1213

1314
// Unaligned accesses don't work on strict-alignment targets like SPARC.
1415
// UNSUPPORTED: sparc-target-arch

compiler-rt/test/asan/TestCases/Linux/preinit_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// RUN: mkdir -p %t.dir && cd %t.dir
12
// RUN: %clangxx -DFUNC=zzzz %s -shared -o %dynamiclib -fPIC
23
// RUN: %clangxx_asan -DFUNC=main %s -o %t %ld_flags_rpath_exe
34
// RUN: %run %t

compiler-rt/test/asan/TestCases/Posix/coverage-module-unloaded.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Check that unloading a module doesn't break coverage dumping for remaining
22
// modules.
3+
// RUN: mkdir -p %t.dir && cd %t.dir
34
// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard -DSHARED %s -shared -o %dynamiclib1 -fPIC
45
// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard -DSHARED %s -shared -o %dynamiclib2 -fPIC
56
// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard %s %libdl -o %t.exe

compiler-rt/test/asan/TestCases/Posix/coverage-reset.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
// RUN: rm -rf %t.dir && mkdir -p %t.dir && cd %t.dir
12
// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard -DSHARED %s -shared -o %dynamiclib -fPIC %ld_flags_rpath_so
23
// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard %s %ld_flags_rpath_exe -o %t
3-
// RUN: rm -rf %t-dir && mkdir -p %t-dir && cd %t-dir
44
// RUN: %env_asan_opts=coverage=1:verbosity=1 %run %t 2>&1 | FileCheck %s
55
//
66
// UNSUPPORTED: ios

compiler-rt/test/asan/TestCases/Posix/coverage.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
// RUN:rm -rf %t.dir && mkdir -p %t.dir && cd %t.dir
12
// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard -DSHARED %s -shared -o %dynamiclib -fPIC %ld_flags_rpath_so
23
// RUN: %clangxx_asan -fsanitize-coverage=func,trace-pc-guard %s %ld_flags_rpath_exe -o %t
3-
// RUN: rm -rf %t-dir && mkdir -p %t-dir && cd %t-dir
44
// RUN: %env_asan_opts=coverage=1:verbosity=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-main
55
// RUN: %sancov print coverage.*sancov 2>&1 | FileCheck %s --check-prefix=CHECK-SANCOV1
66
// RUN: %env_asan_opts=coverage=1:verbosity=1 %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-foo
@@ -14,7 +14,6 @@
1414
// RUN: %sancov print merged-cov 2>&1 | FileCheck %s --check-prefix=CHECK-SANCOV2
1515
// RUN: %env_asan_opts=coverage=1:verbosity=1 not %run %t foo bar 4 2>&1 | FileCheck %s --check-prefix=CHECK-report
1616
// RUN: %env_asan_opts=coverage=1:verbosity=1 not %run %t foo bar 4 5 2>&1 | FileCheck %s --check-prefix=CHECK-segv
17-
// RUN: cd .. && rm -rf %t-dir
1817
//
1918
// https://code.google.com/p/address-sanitizer/issues/detail?id=263
2019
// XFAIL: android

compiler-rt/test/asan/TestCases/Posix/interception-in-shared-lib-test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Check that memset() call from a shared library gets intercepted.
2-
2+
// RUN: mkdir -p %t.dir && cd %t.dir
33
// RUN: %clangxx_asan -O0 %s -DSHARED_LIB \
44
// RUN: -shared -o %dynamiclib -fPIC %ld_flags_rpath_so
55
// RUN: %clangxx_asan -O0 %s -o %t %ld_flags_rpath_exe && \

0 commit comments

Comments
 (0)