freebsd-dev/contrib/compiler-rt/lib/tsan/check_memcpy.sh
Dimitry Andric f4341a5a66 Update compiler-rt to trunk r224034. This brings a number of new
builtins, and also the various sanitizers.  Support for these will be
added in a later commit.
2015-01-08 19:47:10 +00:00

32 lines
787 B
Bash
Executable File

#!/bin/bash
# Ensure that tsan runtime does not contain compiler-emitted memcpy and memset calls.
set -eu
ROOTDIR=$(dirname $0)
TEST_DIR=$ROOTDIR/../../test/tsan
: ${CXX:=clang++}
CFLAGS="-fsanitize=thread -fPIE -O1 -g"
LDFLAGS="-pie -lpthread -ldl -lrt -lm -Wl,--whole-archive $ROOTDIR/rtl/libtsan.a -Wl,--no-whole-archive"
SRC=$TEST_DIR/simple_race.cc
OBJ=$SRC.o
EXE=$SRC.exe
$CXX $SRC $CFLAGS -c -o $OBJ
$CXX $OBJ $LDFLAGS -o $EXE
NCALL=$(objdump -d $EXE | egrep "callq .*<__interceptor_mem(cpy|set)>" | wc -l)
if [ "$NCALL" != "0" ]; then
echo FAIL: found $NCALL memcpy/memset calls
exit 1
fi
# tail calls
NCALL=$(objdump -d $EXE | egrep "jmpq .*<__interceptor_mem(cpy|set)>" | wc -l)
if [ "$NCALL" != "0" ]; then
echo FAIL: found $NCALL memcpy/memset calls
exit 1
fi