]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/tsan/check_memcpy.sh
Use the new insecure-lan-zones option instead of listing each AS112 zone
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / tsan / check_memcpy.sh
1 #!/bin/bash
2
3 # Ensure that tsan runtime does not contain compiler-emitted memcpy and memset calls.
4
5 set -eu
6
7 ROOTDIR=$(dirname $0)
8 TEST_DIR=$ROOTDIR/../../test/tsan
9
10 : ${CXX:=clang++}
11 CFLAGS="-fsanitize=thread -fPIE -O1 -g"
12 LDFLAGS="-pie -lpthread -ldl -lrt -lm -Wl,--whole-archive $ROOTDIR/rtl/libtsan.a -Wl,--no-whole-archive"
13
14 SRC=$TEST_DIR/simple_race.cc
15 OBJ=$SRC.o
16 EXE=$SRC.exe
17 $CXX $SRC $CFLAGS -c -o $OBJ
18 $CXX $OBJ $LDFLAGS -o $EXE
19
20 NCALL=$(objdump -d $EXE | egrep "callq .*<__interceptor_mem(cpy|set)>" | wc -l)
21 if [ "$NCALL" != "0" ]; then
22   echo FAIL: found $NCALL memcpy/memset calls
23   exit 1
24 fi
25
26 # tail calls
27 NCALL=$(objdump -d $EXE | egrep "jmpq .*<__interceptor_mem(cpy|set)>" | wc -l)
28 if [ "$NCALL" != "0" ]; then
29   echo FAIL: found $NCALL memcpy/memset calls
30   exit 1
31 fi