aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/msan
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2015-10-21 09:45:27 -0700
committerIan Lance Taylor <iant@golang.org>2015-10-21 17:50:39 +0000
commit5174df908738ee7c6b5d27e94be4151f1fd56cf5 (patch)
tree4a4375401d3211ebfd59e7ac9d666e55a24de624 /src/runtime/msan
parenta42f668654103ebfb56e64ebc9b6ba131d5b3831 (diff)
downloadgo-5174df908738ee7c6b5d27e94be4151f1fd56cf5.tar.gz
go-5174df908738ee7c6b5d27e94be4151f1fd56cf5.zip
runtime, runtime/msan: add msan runtime support
These are the runtime support functions for letting Go code interoperate with the C/C++ memory sanitizer. Calls to msanread/msanwrite are now inserted by the compiler with the -msan option. Calls to msanmalloc/msanfree will be from other runtime functions in a subsequent CL. Change-Id: I64fb061b38cc6519153face242eccd291c07d1f2 Reviewed-on: https://go-review.googlesource.com/16162 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/msan')
-rw-r--r--src/runtime/msan/msan.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/runtime/msan/msan.go b/src/runtime/msan/msan.go
new file mode 100644
index 0000000000..b6ea3f0d16
--- /dev/null
+++ b/src/runtime/msan/msan.go
@@ -0,0 +1,32 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build msan,linux,amd64
+
+package msan
+
+/*
+#cgo CFLAGS: -fsanitize=memory
+#cgo LDFLAGS: -fsanitize=memory
+
+#include <stdint.h>
+#include <sanitizer/msan_interface.h>
+
+void __msan_read_go(void *addr, uintptr_t sz) {
+ __msan_check_mem_is_initialized(addr, sz);
+}
+
+void __msan_write_go(void *addr, uintptr_t sz) {
+ __msan_unpoison(addr, sz);
+}
+
+void __msan_malloc_go(void *addr, uintptr_t sz) {
+ __msan_unpoison(addr, sz);
+}
+
+void __msan_free_go(void *addr, uintptr_t sz) {
+ __msan_poison(addr, sz);
+}
+*/
+import "C"