-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The internal/asan package contains helper functions for manually instrumenting code for the address sanitizer. It reexports the asan routines in runtime uncoditionally, making the functions a no-op if the build flag "asan" is disabled. For [reserved]
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2023 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 | ||
|
||
package asan | ||
|
||
import ( | ||
"runtime" | ||
"unsafe" | ||
) | ||
|
||
const Enabled = true | ||
|
||
func Read(addr unsafe.Pointer, len int) { | ||
runtime.ASanRead(addr, len) | ||
} | ||
|
||
func Write(addr unsafe.Pointer, len int) { | ||
runtime.ASanWrite(addr, len) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright 2023 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. | ||
|
||
/* | ||
Package asan contains helper functions for manually instrumenting code for the address sanitizer. | ||
The runtime package intentionally exports these functions only in the asan build; | ||
this package exports them unconditionally but without the "asan" build tag they are no-ops. | ||
*/ | ||
package asan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2023 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 | ||
|
||
package asan | ||
|
||
import ( | ||
"unsafe" | ||
) | ||
|
||
const Enabled = false | ||
|
||
func Read(addr unsafe.Pointer, len int) { | ||
} | ||
|
||
func Write(addr unsafe.Pointer, len int) { | ||
} |