aboutsummaryrefslogtreecommitdiff
path: root/lib/tsan/go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tsan/go')
-rwxr-xr-xlib/tsan/go/buildgo.sh25
-rw-r--r--lib/tsan/go/test.c19
-rw-r--r--lib/tsan/go/tsan_go.cc8
3 files changed, 36 insertions, 16 deletions
diff --git a/lib/tsan/go/buildgo.sh b/lib/tsan/go/buildgo.sh
index 62ff0fc38ba9..7f570ca81139 100755
--- a/lib/tsan/go/buildgo.sh
+++ b/lib/tsan/go/buildgo.sh
@@ -35,12 +35,12 @@ SRCS="
../../sanitizer_common/sanitizer_stackdepot.cc
../../sanitizer_common/sanitizer_stacktrace.cc
../../sanitizer_common/sanitizer_symbolizer.cc
+ ../../sanitizer_common/sanitizer_symbolizer_report.cc
../../sanitizer_common/sanitizer_termination.cc
"
if [ "`uname -a | grep Linux`" != "" ]; then
- SUFFIX="linux_amd64"
- OSCFLAGS="-fPIC -ffreestanding -Wno-maybe-uninitialized -Wno-unused-const-variable -Werror -Wno-unknown-warning-option"
+ OSCFLAGS="-fPIC -Wno-maybe-uninitialized"
OSLDFLAGS="-lpthread -fPIC -fpie"
SRCS="
$SRCS
@@ -52,7 +52,13 @@ if [ "`uname -a | grep Linux`" != "" ]; then
../../sanitizer_common/sanitizer_linux.cc
../../sanitizer_common/sanitizer_linux_libcdep.cc
../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
- "
+ "
+ if [ "`uname -a | grep ppc64le`" != "" ]; then
+ SUFFIX="linux_ppc64le"
+ elif [ "`uname -a | grep x86_64`" != "" ]; then
+ SUFFIX="linux_amd64"
+ OSCFLAGS="$OSCFLAGS -ffreestanding -Wno-unused-const-variable -Werror -Wno-unknown-warning-option"
+ fi
elif [ "`uname -a | grep FreeBSD`" != "" ]; then
SUFFIX="freebsd_amd64"
OSCFLAGS="-fno-strict-aliasing -fPIC -Werror"
@@ -62,8 +68,8 @@ elif [ "`uname -a | grep FreeBSD`" != "" ]; then
../rtl/tsan_platform_linux.cc
../../sanitizer_common/sanitizer_posix.cc
../../sanitizer_common/sanitizer_posix_libcdep.cc
+ ../../sanitizer_common/sanitizer_procmaps_bsd.cc
../../sanitizer_common/sanitizer_procmaps_common.cc
- ../../sanitizer_common/sanitizer_procmaps_freebsd.cc
../../sanitizer_common/sanitizer_linux.cc
../../sanitizer_common/sanitizer_linux_libcdep.cc
../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
@@ -77,15 +83,15 @@ elif [ "`uname -a | grep NetBSD`" != "" ]; then
../rtl/tsan_platform_linux.cc
../../sanitizer_common/sanitizer_posix.cc
../../sanitizer_common/sanitizer_posix_libcdep.cc
+ ../../sanitizer_common/sanitizer_procmaps_bsd.cc
../../sanitizer_common/sanitizer_procmaps_common.cc
- ../../sanitizer_common/sanitizer_procmaps_freebsd.cc
../../sanitizer_common/sanitizer_linux.cc
../../sanitizer_common/sanitizer_linux_libcdep.cc
../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
"
elif [ "`uname -a | grep Darwin`" != "" ]; then
SUFFIX="darwin_amd64"
- OSCFLAGS="-fPIC -Wno-unused-const-variable -Wno-unknown-warning-option -isysroot $(xcodebuild -version -sdk macosx Path) -mmacosx-version-min=10.7"
+ OSCFLAGS="-fPIC -Wno-unused-const-variable -Wno-unknown-warning-option -mmacosx-version-min=10.7"
OSLDFLAGS="-lpthread -fPIC -fpie -mmacosx-version-min=10.7"
SRCS="
$SRCS
@@ -132,7 +138,12 @@ done
FLAGS=" -I../rtl -I../.. -I../../sanitizer_common -I../../../include -std=c++11 -m64 -Wall -fno-exceptions -fno-rtti -DSANITIZER_GO=1 -DSANITIZER_DEADLOCK_DETECTOR_VERSION=2 $OSCFLAGS"
if [ "$DEBUG" = "" ]; then
- FLAGS="$FLAGS -DSANITIZER_DEBUG=0 -O3 -msse3 -fomit-frame-pointer"
+ FLAGS="$FLAGS -DSANITIZER_DEBUG=0 -O3 -fomit-frame-pointer"
+ if [ "$SUFFIX" = "linux_ppc64le" ]; then
+ FLAGS="$FLAGS -mcpu=power8 -fno-function-sections"
+ elif [ "$SUFFIX" = "linux_amd64" ]; then
+ FLAGS="$FLAGS -msse3"
+ fi
else
FLAGS="$FLAGS -DSANITIZER_DEBUG=1 -g"
fi
diff --git a/lib/tsan/go/test.c b/lib/tsan/go/test.c
index b3e31b1feaa7..c484774caeb9 100644
--- a/lib/tsan/go/test.c
+++ b/lib/tsan/go/test.c
@@ -11,6 +11,8 @@
//
//===----------------------------------------------------------------------===//
+#include <sys/mman.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -44,7 +46,13 @@ void symbolize_cb(long cmd, void *ctx) {
}
}
-char buf0[100<<10];
+/*
+ * See lib/tsan/rtl/tsan_platform.h for details of what the memory layout
+ * of Go programs looks like. To prevent running over existing mappings,
+ * we pick an address slightly inside the Go heap region.
+ */
+void *go_heap = (void *)0xC011110000;
+char *buf0;
void foobar() {}
void barfoo() {}
@@ -54,6 +62,15 @@ int main(void) {
void *proc0 = 0;
__tsan_init(&thr0, &proc0, symbolize_cb);
current_proc = proc0;
+
+ // Allocate something resembling a heap in Go.
+ buf0 = mmap(go_heap, 16384, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_FIXED | MAP_ANON, -1, 0);
+ if (buf0 == MAP_FAILED) {
+ fprintf(stderr, "failed to allocate Go-like heap at %p; errno %d\n",
+ go_heap, errno);
+ return 1;
+ }
char *buf = (char*)((unsigned long)buf0 + (64<<10) - 1 & ~((64<<10) - 1));
__tsan_map_shadow(buf, 4096);
__tsan_malloc(thr0, (char*)&barfoo + 1, buf, 10);
diff --git a/lib/tsan/go/tsan_go.cc b/lib/tsan/go/tsan_go.cc
index d7a9e0b67962..5f2507b7df1d 100644
--- a/lib/tsan/go/tsan_go.cc
+++ b/lib/tsan/go/tsan_go.cc
@@ -282,11 +282,3 @@ void __tsan_report_count(u64 *pn) {
} // extern "C"
} // namespace __tsan
-
-namespace __sanitizer {
-
-void SymbolizerPrepareForSandboxing() {
- // Nothing to do here for Go.
-}
-
-} // namespace __sanitizer