Source file src/runtime/msan/msan.go

     1  // Copyright 2015 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build msan && ((linux && (amd64 || arm64 || loong64)) || (freebsd && amd64))
     6  
     7  package msan
     8  
     9  /*
    10  #cgo CFLAGS: -fsanitize=memory
    11  #cgo LDFLAGS: -fsanitize=memory
    12  
    13  #include <stdint.h>
    14  #include <sanitizer/msan_interface.h>
    15  
    16  void __msan_read_go(void *addr, uintptr_t sz) {
    17  	__msan_check_mem_is_initialized(addr, sz);
    18  }
    19  
    20  void __msan_write_go(void *addr, uintptr_t sz) {
    21  	__msan_unpoison(addr, sz);
    22  }
    23  
    24  void __msan_malloc_go(void *addr, uintptr_t sz) {
    25  	__msan_unpoison(addr, sz);
    26  }
    27  
    28  void __msan_free_go(void *addr, uintptr_t sz) {
    29  	__msan_poison(addr, sz);
    30  }
    31  
    32  void __msan_memmove_go(void *to, const void *from, uintptr_t sz) {
    33  	// Note: don't use msan_memmove, as it actually does
    34  	// the move. We do the move ourselves, so it isn't necessary.
    35  	// Also, it clobbers the target before we issue the write
    36  	// barrier, which causes pointers to get lost. See issue 76138.
    37  	__msan_copy_shadow(to, from, sz);
    38  }
    39  */
    40  import "C"
    41  

View as plain text