aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/msan.go
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.go
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.go')
-rw-r--r--src/runtime/msan.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/runtime/msan.go b/src/runtime/msan.go
new file mode 100644
index 0000000000..7457fe1150
--- /dev/null
+++ b/src/runtime/msan.go
@@ -0,0 +1,42 @@
+// 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
+
+package runtime
+
+import (
+ "unsafe"
+)
+
+// Public memory sanitizer API.
+
+func MSanRead(addr unsafe.Pointer, len int) {
+ msanread(addr, uintptr(len))
+}
+
+func MSanWrite(addr unsafe.Pointer, len int) {
+ msanwrite(addr, uintptr(len))
+}
+
+// Private interface for the runtime.
+const msanenabled = true
+
+//go:noescape
+func msanread(addr unsafe.Pointer, sz uintptr)
+
+//go:noescape
+func msanwrite(addr unsafe.Pointer, sz uintptr)
+
+//go:noescape
+func msanmalloc(addr unsafe.Pointer, sz uintptr)
+
+//go:noescape
+func msanfree(addr unsafe.Pointer, sz uintptr)
+
+// These are called from msan_amd64.s
+//go:cgo_import_static __msan_read_go
+//go:cgo_import_static __msan_write_go
+//go:cgo_import_static __msan_malloc_go
+//go:cgo_import_static __msan_free_go