diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2012-11-06 16:00:16 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2012-11-06 16:00:16 +0000 |
commit | a05fcc1e3e045097f2f1a20798cbe038bbb1d6a9 (patch) | |
tree | a462b98e33571277b0ea0f576fefdb144510affe /lib/tsan/go | |
parent | be1a4c4be86f7960dbeb7b44d3b13ce5b9b13b4e (diff) | |
download | compiler-rt-a05fcc1e3e045097f2f1a20798cbe038bbb1d6a9.tar.gz compiler-rt-a05fcc1e3e045097f2f1a20798cbe038bbb1d6a9.tar.bz2 compiler-rt-a05fcc1e3e045097f2f1a20798cbe038bbb1d6a9.tar.xz |
tsan: lazily allocate shadow for Go
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@167464 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan/go')
-rwxr-xr-x | lib/tsan/go/buildgo.sh | 7 | ||||
-rw-r--r-- | lib/tsan/go/test.c | 2 | ||||
-rw-r--r-- | lib/tsan/go/tsan_go.cc | 4 |
3 files changed, 10 insertions, 3 deletions
diff --git a/lib/tsan/go/buildgo.sh b/lib/tsan/go/buildgo.sh index e7e27c8a..86f468a4 100755 --- a/lib/tsan/go/buildgo.sh +++ b/lib/tsan/go/buildgo.sh @@ -1,5 +1,6 @@ #!/bin/bash set -e +set -x SRCS=" tsan_go.cc @@ -25,7 +26,7 @@ SRCS=" if [ "`uname -a | grep Linux`" != "" ]; then SUFFIX="linux_amd64" OSCFLAGS="-fPIC -ffreestanding" - OSLDFLAGS="-lpthread" + OSLDFLAGS="-lpthread -fPIC -fpie" SRCS+=" ../rtl/tsan_platform_linux.cc ../../sanitizer_common/sanitizer_posix.cc @@ -34,7 +35,7 @@ if [ "`uname -a | grep Linux`" != "" ]; then elif [ "`uname -a | grep Darwin`" != "" ]; then SUFFIX="darwin_amd64" OSCFLAGS="-fPIC" - OSLDFLAGS="-lpthread" + OSLDFLAGS="-lpthread -fPIC -fpie" SRCS+=" ../rtl/tsan_platform_mac.cc ../../sanitizer_common/sanitizer_posix.cc @@ -74,4 +75,4 @@ echo as gotsan.s -o race_$SUFFIX.syso as gotsan.s -o race_$SUFFIX.syso gcc test.c race_$SUFFIX.syso -m64 -o test $OSLDFLAGS -TSAN_OPTIONS="exitcode=0" ./test +TSAN_OPTIONS="exitcode=0 atexit_sleep_ms=0" ./test diff --git a/lib/tsan/go/test.c b/lib/tsan/go/test.c index a9a5b3db..865da4ef 100644 --- a/lib/tsan/go/test.c +++ b/lib/tsan/go/test.c @@ -15,6 +15,7 @@ void __tsan_init(); void __tsan_fini(); +void __tsan_map_shadow(void *addr, unsigned long size); void __tsan_go_start(int pgoid, int chgoid, void *pc); void __tsan_go_end(int goid); void __tsan_read(int goid, void *addr, void *pc); @@ -35,6 +36,7 @@ char buf[10]; int main(void) { __tsan_init(); + __tsan_map_shadow((unsigned long)buf & ~(4096-1), 4096); __tsan_func_enter(0, &main); __tsan_malloc(0, buf, 10, 0); __tsan_release(0, buf); diff --git a/lib/tsan/go/tsan_go.cc b/lib/tsan/go/tsan_go.cc index ccedc64c..a7e8d967 100644 --- a/lib/tsan/go/tsan_go.cc +++ b/lib/tsan/go/tsan_go.cc @@ -108,6 +108,10 @@ void __tsan_fini() { exit(res); } +void __tsan_map_shadow(uptr addr, uptr size) { + MapShadow(addr, size); +} + void __tsan_read(int goid, void *addr, void *pc) { ThreadState *thr = goroutines[goid]; MemoryAccess(thr, (uptr)pc, (uptr)addr, 0, false); |