diff options
Diffstat (limited to 'libgo/go/runtime/asan/asan.go')
-rw-r--r-- | libgo/go/runtime/asan/asan.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/libgo/go/runtime/asan/asan.go b/libgo/go/runtime/asan/asan.go new file mode 100644 index 0000000..bab2362 --- /dev/null +++ b/libgo/go/runtime/asan/asan.go @@ -0,0 +1,38 @@ +// Copyright 2021 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. + +//go:build asan && linux && (arm64 || amd64) + +package asan + +/* +#cgo CFLAGS: -fsanitize=address +#cgo LDFLAGS: -fsanitize=address + +#include <stdbool.h> +#include <stdint.h> +#include <sanitizer/asan_interface.h> + +void __asan_read_go(void *addr, uintptr_t sz, void *sp, void *pc) { + if (__asan_region_is_poisoned(addr, sz)) { + __asan_report_error(pc, 0, sp, addr, false, sz); + } +} + +void __asan_write_go(void *addr, uintptr_t sz, void *sp, void *pc) { + if (__asan_region_is_poisoned(addr, sz)) { + __asan_report_error(pc, 0, sp, addr, true, sz); + } +} + +void __asan_unpoison_go(void *addr, uintptr_t sz) { + __asan_unpoison_memory_region(addr, sz); +} + +void __asan_poison_go(void *addr, uintptr_t sz) { + __asan_poison_memory_region(addr, sz); +} + +*/ +import "C" |