Source file src/runtime/asan/asan.go

     1  // Copyright 2021 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 asan && linux && (arm64 || amd64)
     6  
     7  package asan
     8  
     9  /*
    10  #cgo CFLAGS: -fsanitize=address
    11  #cgo LDFLAGS: -fsanitize=address
    12  
    13  #include <stdbool.h>
    14  #include <stdint.h>
    15  #include <sanitizer/asan_interface.h>
    16  
    17  void __asan_read_go(void *addr, uintptr_t sz, void *sp, void *pc) {
    18  	if (__asan_region_is_poisoned(addr, sz)) {
    19  		__asan_report_error(pc, 0, sp, addr, false, sz);
    20  	}
    21  }
    22  
    23  void __asan_write_go(void *addr, uintptr_t sz, void *sp, void *pc) {
    24  	if (__asan_region_is_poisoned(addr, sz)) {
    25  		__asan_report_error(pc, 0, sp, addr, true, sz);
    26  	}
    27  }
    28  
    29  void __asan_unpoison_go(void *addr, uintptr_t sz) {
    30  	__asan_unpoison_memory_region(addr, sz);
    31  }
    32  
    33  void __asan_poison_go(void *addr, uintptr_t sz) {
    34  	__asan_poison_memory_region(addr, sz);
    35  }
    36  
    37  */
    38  import "C"
    39  

View as plain text