summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan
diff options
context:
space:
mode:
Diffstat (limited to 'compiler-rt/lib/asan')
-rw-r--r--compiler-rt/lib/asan/output_tests/clone_test.cc2
-rw-r--r--compiler-rt/lib/asan/output_tests/deep_tail_call.cc12
-rw-r--r--compiler-rt/lib/asan/output_tests/dlclose-test.cc2
-rw-r--r--compiler-rt/lib/asan/output_tests/global-overflow.cc6
-rw-r--r--compiler-rt/lib/asan/output_tests/heap-overflow.cc25
-rw-r--r--compiler-rt/lib/asan/output_tests/large_func_test.cc16
-rwxr-xr-xcompiler-rt/lib/asan/output_tests/match_output.py35
-rw-r--r--compiler-rt/lib/asan/output_tests/null_deref.cc16
-rw-r--r--compiler-rt/lib/asan/output_tests/shared-lib-test.cc8
-rw-r--r--compiler-rt/lib/asan/output_tests/stack-overflow.cc6
-rw-r--r--compiler-rt/lib/asan/output_tests/stack-use-after-return.cc.disabled6
-rw-r--r--compiler-rt/lib/asan/output_tests/strncpy-overflow.cc29
-rwxr-xr-xcompiler-rt/lib/asan/output_tests/test_output.sh34
-rw-r--r--compiler-rt/lib/asan/output_tests/use-after-free.cc44
14 files changed, 97 insertions, 144 deletions
diff --git a/compiler-rt/lib/asan/output_tests/clone_test.cc b/compiler-rt/lib/asan/output_tests/clone_test.cc
index aba9c24dca7..b18d2550bc7 100644
--- a/compiler-rt/lib/asan/output_tests/clone_test.cc
+++ b/compiler-rt/lib/asan/output_tests/clone_test.cc
@@ -29,6 +29,6 @@ int main(int argc, char **argv) {
#include <stdio.h>
int main() {
printf("PASSED\n");
- // CHECK: PASSED
+ // Check-Common: PASSED
}
#endif
diff --git a/compiler-rt/lib/asan/output_tests/deep_tail_call.cc b/compiler-rt/lib/asan/output_tests/deep_tail_call.cc
index 96009508aa9..cb69e892519 100644
--- a/compiler-rt/lib/asan/output_tests/deep_tail_call.cc
+++ b/compiler-rt/lib/asan/output_tests/deep_tail_call.cc
@@ -1,14 +1,14 @@
-// CHECK: AddressSanitizer global-buffer-overflow
+// Check-Common: AddressSanitizer global-buffer-overflow
int global[10];
-// CHECK: {{#0.*call4}}
+// Check-Common: {{#0.*call4}}
void __attribute__((noinline)) call4(int i) { global[i+10]++; }
-// CHECK: {{#1.*call3}}
+// Check-Common: {{#1.*call3}}
void __attribute__((noinline)) call3(int i) { call4(i); }
-// CHECK: {{#2.*call2}}
+// Check-Common: {{#2.*call2}}
void __attribute__((noinline)) call2(int i) { call3(i); }
-// CHECK: {{#3.*call1}}
+// Check-Common: {{#3.*call1}}
void __attribute__((noinline)) call1(int i) { call2(i); }
-// CHECK: {{#4.*main}}
+// Check-Common: {{#4.*main}}
int main(int argc, char **argv) {
call1(argc);
return global[0];
diff --git a/compiler-rt/lib/asan/output_tests/dlclose-test.cc b/compiler-rt/lib/asan/output_tests/dlclose-test.cc
index 3c398500326..5cfc35668d9 100644
--- a/compiler-rt/lib/asan/output_tests/dlclose-test.cc
+++ b/compiler-rt/lib/asan/output_tests/dlclose-test.cc
@@ -69,6 +69,6 @@ int main(int argc, char *argv[]) {
}
addr[1] = 2; // BOOM (if the bug is not fixed).
printf("PASS\n");
- // CHECK: PASS
+ // Check-Common: PASS
return 0;
}
diff --git a/compiler-rt/lib/asan/output_tests/global-overflow.cc b/compiler-rt/lib/asan/output_tests/global-overflow.cc
index 0869da05efb..bd835946688 100644
--- a/compiler-rt/lib/asan/output_tests/global-overflow.cc
+++ b/compiler-rt/lib/asan/output_tests/global-overflow.cc
@@ -7,9 +7,9 @@ int main(int argc, char **argv) {
memset(YYY, 0, 10);
memset(ZZZ, 0, 10);
int res = YYY[argc * 10]; // BOOOM
- // CHECK: {{READ of size 1 at 0x.* thread T0}}
- // CHECK: {{ #0 0x.* in main .*global-overflow.cc:9}}
- // CHECK: {{0x.* is located 0 bytes to the right of global variable .*YYY.* of size 10}}
+ // Check-Common: {{READ of size 1 at 0x.* thread T0}}
+ // Check-Common: {{ #0 0x.* in main .*global-overflow.cc:9}}
+ // Check-Common: {{0x.* is located 0 bytes to the right of global variable .*YYY.* of size 10}}
res += XXX[argc] + ZZZ[argc];
return res;
}
diff --git a/compiler-rt/lib/asan/output_tests/heap-overflow.cc b/compiler-rt/lib/asan/output_tests/heap-overflow.cc
index ffc50bede7b..a8656c6126d 100644
--- a/compiler-rt/lib/asan/output_tests/heap-overflow.cc
+++ b/compiler-rt/lib/asan/output_tests/heap-overflow.cc
@@ -8,18 +8,15 @@ int main(int argc, char **argv) {
return res;
}
-// CHECK: {{READ of size 1 at 0x.* thread T0}}
-// CHECK: {{ #0 0x.* in main .*heap-overflow.cc:6}}
-// CHECK: {{0x.* is located 0 bytes to the right of 10-byte region}}
-// CHECK: {{allocated by thread T0 here:}}
-// CHECK: {{ #0 0x.* in malloc}}
-// CHECK: {{ #1 0x.* in main .*heap-overflow.cc:[45]}}
+// Check-Common: {{READ of size 1 at 0x.* thread T0}}
+// Check-Common: {{ #0 0x.* in main .*heap-overflow.cc:6}}
+// Check-Common: {{0x.* is located 0 bytes to the right of 10-byte region}}
+// Check-Common: {{allocated by thread T0 here:}}
-// Darwin: {{READ of size 1 at 0x.* thread T0}}
-// Darwin: {{ #0 0x.* in main .*heap-overflow.cc:6}}
-// Darwin: {{0x.* is located 0 bytes to the right of 10-byte region}}
-// Darwin: {{allocated by thread T0 here:}}
-// Darwin: {{ #0 0x.* in .*mz_malloc.*}}
-// Darwin: {{ #1 0x.* in malloc_zone_malloc.*}}
-// Darwin: {{ #2 0x.* in malloc.*}}
-// Darwin: {{ #3 0x.* in main heap-overflow.cc:[45]}}
+// Check-Linux: {{ #0 0x.* in malloc}}
+// Check-Linux: {{ #1 0x.* in main .*heap-overflow.cc:[45]}}
+
+// Check-Darwin: {{ #0 0x.* in .*mz_malloc.*}}
+// Check-Darwin: {{ #1 0x.* in malloc_zone_malloc.*}}
+// Check-Darwin: {{ #2 0x.* in malloc.*}}
+// Check-Darwin: {{ #3 0x.* in main heap-overflow.cc:[45]}}
diff --git a/compiler-rt/lib/asan/output_tests/large_func_test.cc b/compiler-rt/lib/asan/output_tests/large_func_test.cc
index 3de025f8905..de450e9b92a 100644
--- a/compiler-rt/lib/asan/output_tests/large_func_test.cc
+++ b/compiler-rt/lib/asan/output_tests/large_func_test.cc
@@ -32,11 +32,11 @@ int main(int argc, char **argv) {
delete x;
}
-// CHECK: {{.*ERROR: AddressSanitizer heap-buffer-overflow on address 0x.* at pc 0x.* bp 0x.* sp 0x.*}}
-// CHECK: {{READ of size 4 at 0x.* thread T0}}
-// CHECK: {{ #0 0x.* in LargeFunction .*large_func_test.cc:15}}
-// CHECK: {{ #1 0x.* in main .*large_func_test.cc:3[012]}}
-// CHECK: {{0x.* is located 44 bytes to the right of 400-byte region}}
-// CHECK: {{allocated by thread T0 here:}}
-// CHECK: {{ #0 0x.* in operator new.*}}
-// CHECK: {{ #1 0x.* in main .*large_func_test.cc:30}}
+// Check-Common: {{.*ERROR: AddressSanitizer heap-buffer-overflow on address 0x.* at pc 0x.* bp 0x.* sp 0x.*}}
+// Check-Common: {{READ of size 4 at 0x.* thread T0}}
+// Check-Common: {{ #0 0x.* in LargeFunction .*large_func_test.cc:15}}
+// Check-Common: {{ #1 0x.* in main .*large_func_test.cc:3[012]}}
+// Check-Common: {{0x.* is located 44 bytes to the right of 400-byte region}}
+// Check-Common: {{allocated by thread T0 here:}}
+// Check-Common: {{ #0 0x.* in operator new.*}}
+// Check-Common: {{ #1 0x.* in main .*large_func_test.cc:30}}
diff --git a/compiler-rt/lib/asan/output_tests/match_output.py b/compiler-rt/lib/asan/output_tests/match_output.py
deleted file mode 100755
index 31095f3f62f..00000000000
--- a/compiler-rt/lib/asan/output_tests/match_output.py
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/usr/bin/python
-
-import re
-import sys
-
-def matchFile(f, f_re):
- for line_re in f_re:
- line_re = line_re.rstrip()
- if not line_re:
- continue
- if line_re[0] == '#':
- continue
- match = False
- for line in f:
- line = line.rstrip()
- # print line
- if re.search(line_re, line):
- match = True
- #print 'match: %s =~ %s' % (line, line_re)
- break
- if not match:
- print 'no match for: %s' % (line_re)
- return False
- return True
-
-if len(sys.argv) != 2:
- print >>sys.stderr, 'Usage: %s <template file>'
- sys.exit(1)
-
-f = sys.stdin
-f_re = open(sys.argv[1])
-
-if not matchFile(f, f_re):
- print >>sys.stderr, 'File does not match the template'
- sys.exit(1)
diff --git a/compiler-rt/lib/asan/output_tests/null_deref.cc b/compiler-rt/lib/asan/output_tests/null_deref.cc
index a44604d4f36..82e5e569dcd 100644
--- a/compiler-rt/lib/asan/output_tests/null_deref.cc
+++ b/compiler-rt/lib/asan/output_tests/null_deref.cc
@@ -6,13 +6,11 @@ int main() {
NullDeref((int*)0);
}
-// CHECK: {{.*ERROR: AddressSanitizer crashed on unknown address 0x0*00028 .*pc 0x.*}}
-// CHECK: {{AddressSanitizer can not provide additional info. ABORTING}}
-// CHECK: {{ #0 0x.* in NullDeref.*null_deref.cc:3}}
-// CHECK: {{ #1 0x.* in main.*null_deref.cc:[67]}}
+// Check-Common: {{.*ERROR: AddressSanitizer crashed on unknown address 0x0*00028 .*pc 0x.*}}
+// Check-Common: {{AddressSanitizer can not provide additional info. ABORTING}}
-// Darwin: {{.*ERROR: AddressSanitizer crashed on unknown address 0x0*00028 .*pc 0x.*}}
-// Darwin: {{AddressSanitizer can not provide additional info. ABORTING}}
-// atos cannot resolve the file:line info for frame 0 on the O1 level
-// Darwin: {{ #0 0x.* in NullDeref.*}}
-// Darwin: {{ #1 0x.* in main.*null_deref.cc:[67]}}
+// atos on Mac cannot resolve the file:line info for frame 0 on the O1 level
+// Check-Linux: {{ #0 0x.* in NullDeref.*null_deref.cc:3}}
+// Check-Darwin: {{ #0 0x.* in NullDeref.*}}
+
+// Check-Common: {{ #1 0x.* in main.*null_deref.cc:[67]}}
diff --git a/compiler-rt/lib/asan/output_tests/shared-lib-test.cc b/compiler-rt/lib/asan/output_tests/shared-lib-test.cc
index d0f90d0a7ba..ee8f14cac64 100644
--- a/compiler-rt/lib/asan/output_tests/shared-lib-test.cc
+++ b/compiler-rt/lib/asan/output_tests/shared-lib-test.cc
@@ -36,7 +36,7 @@ int main(int argc, char *argv[]) {
return 0;
}
-// CHECK: {{.*ERROR: AddressSanitizer global-buffer-overflow}}
-// CHECK: {{READ of size 4 at 0x.* thread T0}}
-// CHECK: {{ #0 0x.*}}
-// CHECK: {{ #1 0x.* in main .*shared-lib-test.cc:3[567]}}
+// Check-Common: {{.*ERROR: AddressSanitizer global-buffer-overflow}}
+// Check-Common: {{READ of size 4 at 0x.* thread T0}}
+// Check-Common: {{ #0 0x.*}}
+// Check-Common: {{ #1 0x.* in main .*shared-lib-test.cc:3[567]}}
diff --git a/compiler-rt/lib/asan/output_tests/stack-overflow.cc b/compiler-rt/lib/asan/output_tests/stack-overflow.cc
index 2a0a1383e49..35fa8a66c34 100644
--- a/compiler-rt/lib/asan/output_tests/stack-overflow.cc
+++ b/compiler-rt/lib/asan/output_tests/stack-overflow.cc
@@ -6,6 +6,6 @@ int main(int argc, char **argv) {
return res;
}
-// CHECK: {{READ of size 1 at 0x.* thread T0}}
-// CHECK: {{ #0 0x.* in main .*stack-overflow.cc:5}}
-// CHECK: {{Address 0x.* is .* frame <main>}}
+// Check-Common: {{READ of size 1 at 0x.* thread T0}}
+// Check-Common: {{ #0 0x.* in main .*stack-overflow.cc:5}}
+// Check-Common: {{Address 0x.* is .* frame <main>}}
diff --git a/compiler-rt/lib/asan/output_tests/stack-use-after-return.cc.disabled b/compiler-rt/lib/asan/output_tests/stack-use-after-return.cc.disabled
index 97a37bc04f0..f4971573743 100644
--- a/compiler-rt/lib/asan/output_tests/stack-use-after-return.cc.disabled
+++ b/compiler-rt/lib/asan/output_tests/stack-use-after-return.cc.disabled
@@ -16,9 +16,9 @@ __attribute__((noinline))
void Func2(char *x) {
fprintf(stderr, "2: %p\n", x);
*x = 1;
- // CHECK: {{WRITE of size 1 .* thread T0}}
- // CHECK: {{ #0.*Func2.*stack-use-after-return.cc:18}}
- // CHECK: {{is located in frame <.*Func1.*> of T0's stack}}
+ // Check-Common: {{WRITE of size 1 .* thread T0}}
+ // Check-Common: {{ #0.*Func2.*stack-use-after-return.cc:18}}
+ // Check-Common: {{is located in frame <.*Func1.*> of T0's stack}}
}
int main(int argc, char **argv) {
diff --git a/compiler-rt/lib/asan/output_tests/strncpy-overflow.cc b/compiler-rt/lib/asan/output_tests/strncpy-overflow.cc
index cc202aedb50..2346188bf3b 100644
--- a/compiler-rt/lib/asan/output_tests/strncpy-overflow.cc
+++ b/compiler-rt/lib/asan/output_tests/strncpy-overflow.cc
@@ -8,20 +8,17 @@ int main(int argc, char **argv) {
return short_buffer[8];
}
-// CHECK: {{WRITE of size 1 at 0x.* thread T0}}
-// CHECK: {{ #0 0x.* in strncpy}}
-// CHECK: {{ #1 0x.* in main .*strncpy-overflow.cc:[78]}}
-// CHECK: {{0x.* is located 0 bytes to the right of 9-byte region}}
-// CHECK: {{allocated by thread T0 here:}}
-// CHECK: {{ #0 0x.* in malloc}}
-// CHECK: {{ #1 0x.* in main .*strncpy-overflow.cc:6}}
+// Check-Common: {{WRITE of size 1 at 0x.* thread T0}}
+// Check-Linux: {{ #0 0x.* in strncpy}}
+// Check-Darwin: {{ #0 0x.* in wrap_strncpy}}
+// Check-Common: {{ #1 0x.* in main .*strncpy-overflow.cc:[78]}}
+// Check-Common: {{0x.* is located 0 bytes to the right of 9-byte region}}
+// Check-Common: {{allocated by thread T0 here:}}
-// Darwin: {{WRITE of size 1 at 0x.* thread T0}}
-// Darwin: {{ #0 0x.* in wrap_strncpy}}
-// Darwin: {{ #1 0x.* in main .*strncpy-overflow.cc:[78]}}
-// Darwin: {{0x.* is located 0 bytes to the right of 9-byte region}}
-// Darwin: {{allocated by thread T0 here:}}
-// Darwin: {{ #0 0x.* in .*mz_malloc.*}}
-// Darwin: {{ #1 0x.* in malloc_zone_malloc.*}}
-// Darwin: {{ #2 0x.* in malloc.*}}
-// Darwin: {{ #3 0x.* in main .*strncpy-overflow.cc:6}}
+// Check-Linux: {{ #0 0x.* in malloc}}
+// Check-Linux: {{ #1 0x.* in main .*strncpy-overflow.cc:6}}
+
+// Check-Darwin: {{ #0 0x.* in .*mz_malloc.*}}
+// Check-Darwin: {{ #1 0x.* in malloc_zone_malloc.*}}
+// Check-Darwin: {{ #2 0x.* in malloc.*}}
+// Check-Darwin: {{ #3 0x.* in main .*strncpy-overflow.cc:6}}
diff --git a/compiler-rt/lib/asan/output_tests/test_output.sh b/compiler-rt/lib/asan/output_tests/test_output.sh
index 112d71c6a21..fbafa254b6c 100755
--- a/compiler-rt/lib/asan/output_tests/test_output.sh
+++ b/compiler-rt/lib/asan/output_tests/test_output.sh
@@ -8,28 +8,27 @@ CC=$2
FILE_CHECK=$3
CXXFLAGS="-mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls"
SYMBOLIZER=../scripts/asan_symbolize.py
+TMP_ASAN_REPORT=/tmp/asan_report
-# check_program exe_file src_file [check_prefix]
+run_program() {
+ ./$1 2>&1 | $SYMBOLIZER 2> /dev/null | c++filt > $TMP_ASAN_REPORT
+}
+
+# check_program exe_file source_file check_prefix
check_program() {
- exe=$1
- src=$2
- prefix="CHECK"
- if [ "z$3" != "z" ] ; then
- prefix=$3
- fi
- ./$exe 2>&1 | $SYMBOLIZER 2> /dev/null | c++filt | \
- $FILE_CHECK $src --check-prefix=$prefix
+ run_program $1
+ $FILE_CHECK $2 --check-prefix=$3 < $TMP_ASAN_REPORT
}
C_TEST=use-after-free
echo "Sanity checking a test in pure C"
$CC -g -faddress-sanitizer -O2 $C_TEST.c
-check_program a.out $C_TEST.c
+check_program a.out $C_TEST.c CHECK
rm ./a.out
echo "Sanity checking a test in pure C with -pie"
$CC -g -faddress-sanitizer -O2 $C_TEST.c -pie
-check_program a.out $C_TEST.c
+check_program a.out $C_TEST.c CHECK
rm ./a.out
echo "Testing sleep_before_dying"
@@ -55,15 +54,14 @@ for t in *.cc; do
[ "$DEBUG" == "1" ] && echo $build_command
$build_command
[ -e "$c_so.cc" ] && $CXX $CXXFLAGS -g -m$b -faddress-sanitizer -O$O $c_so.cc -fPIC -shared -o $so
- # If there's an OS-specific template, use it.
- # Otherwise use default template.
- if [ `grep -c "$OS" $c.cc` -gt 0 ]
+ run_program $exe
+ # Check common expected lines for OS.
+ $FILE_CHECK $c.cc --check-prefix="Check-Common" < $TMP_ASAN_REPORT
+ # Check OS-specific lines.
+ if [ `grep -c "Check-$OS" $c.cc` -gt 0 ]
then
- check_prefix="$OS"
- else
- check_prefix="CHECK"
+ $FILE_CHECK $c.cc --check-prefix="Check-$OS" < $TMP_ASAN_REPORT
fi
- check_program $exe $c.cc $check_prefix
rm ./$exe
[ -e "$so" ] && rm ./$so
done
diff --git a/compiler-rt/lib/asan/output_tests/use-after-free.cc b/compiler-rt/lib/asan/output_tests/use-after-free.cc
index fbf2ab46d52..6fa829fab5f 100644
--- a/compiler-rt/lib/asan/output_tests/use-after-free.cc
+++ b/compiler-rt/lib/asan/output_tests/use-after-free.cc
@@ -5,28 +5,26 @@ int main() {
return x[5];
}
-// CHECK: {{.*ERROR: AddressSanitizer heap-use-after-free on address 0x.* at pc 0x.* bp 0x.* sp 0x.*}}
-// CHECK: {{READ of size 1 at 0x.* thread T0}}
-// CHECK: {{ #0 0x.* in main .*use-after-free.cc:5}}
-// CHECK: {{0x.* is located 5 bytes inside of 10-byte region .0x.*,0x.*}}
-// CHECK: {{freed by thread T0 here:}}
-// CHECK: {{ #0 0x.* in free}}
-// CHECK: {{ #1 0x.* in main .*use-after-free.cc:[45]}}
-// CHECK: {{previously allocated by thread T0 here:}}
-// CHECK: {{ #0 0x.* in malloc}}
-// CHECK: {{ #1 0x.* in main .*use-after-free.cc:3}}
+// Check-Common: {{.*ERROR: AddressSanitizer heap-use-after-free on address 0x.* at pc 0x.* bp 0x.* sp 0x.*}}
+// Check-Common: {{READ of size 1 at 0x.* thread T0}}
+// Check-Common: {{ #0 0x.* in main .*use-after-free.cc:5}}
+// Check-Common: {{0x.* is located 5 bytes inside of 10-byte region .0x.*,0x.*}}
+// Check-Common: {{freed by thread T0 here:}}
-// Darwin: {{.*ERROR: AddressSanitizer heap-use-after-free on address 0x.* at pc 0x.* bp 0x.* sp 0x.*}}
-// Darwin: {{READ of size 1 at 0x.* thread T0}}
-// Darwin: {{ #0 0x.* in main .*use-after-free.cc:5}}
-// Darwin: {{0x.* is located 5 bytes inside of 10-byte region .0x.*,0x.*}}
-// Darwin: {{freed by thread T0 here:}}
-// Darwin: {{ #0 0x.* in .*mz_free.*}}
+// Check-Linux: {{ #0 0x.* in free}}
+// Check-Linux: {{ #1 0x.* in main .*use-after-free.cc:[45]}}
+
+// Check-Darwin: {{ #0 0x.* in .*mz_free.*}}
// We override free() on Darwin, thus no malloc_zone_free
-// Darwin: {{ #1 0x.* in free}}
-// Darwin: {{ #2 0x.* in main .*use-after-free.cc:[45]}}
-// Darwin: {{previously allocated by thread T0 here:}}
-// Darwin: {{ #0 0x.* in .*mz_malloc.*}}
-// Darwin: {{ #1 0x.* in malloc_zone_malloc.*}}
-// Darwin: {{ #2 0x.* in malloc.*}}
-// Darwin: {{ #3 0x.* in main .*use-after-free.cc:3}}
+// Check-Darwin: {{ #1 0x.* in free}}
+// Check-Darwin: {{ #2 0x.* in main .*use-after-free.cc:[45]}}
+
+// Check-Common: {{previously allocated by thread T0 here:}}
+
+// Check-Linux: {{ #0 0x.* in malloc}}
+// Check-Linux: {{ #1 0x.* in main .*use-after-free.cc:3}}
+
+// Check-Darwin: {{ #0 0x.* in .*mz_malloc.*}}
+// Check-Darwin: {{ #1 0x.* in malloc_zone_malloc.*}}
+// Check-Darwin: {{ #2 0x.* in malloc.*}}
+// Check-Darwin: {{ #3 0x.* in main .*use-after-free.cc:3}}
OpenPOWER on IntegriCloud