1
0
mirror of https://github.com/golang/go synced 2024-09-28 18:04:28 -06:00
go/misc
fanzha02 f52b4ec63d cmd/compile: enable Asan check for global variables
With this patch, -asan option can detect the error memory
access to global variables.

So this patch makes a few changes:

1. Add the asanregisterglobals runtime support function,
which calls asan runtime function _asan_register_globals
to register global variables.

2. Create a new initialization function for the package
being compiled. This function initializes an array of
instrumented global variables and pass it to function
runtime.asanregisterglobals. An instrumented global
variable has trailing redzone.

3. Writes the new size of instrumented global variables
that have trailing redzones into object file.

4. Notice that the current implementation is only compatible with
the ASan library from version v7 to v9. Therefore, using the
-asan option requires that the gcc version is not less than 7
and the clang version is less than 4, otherwise a segmentation
fault will occur. So this patch adds a check on whether the compiler
being used is a supported version in cmd/go.

Updates #44853.

Change-Id: Ib877a817209ab2be68a8e22c418fe4a4a20880fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/401775
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-04 16:13:20 +00:00
..
android all: gofmt more (but vendor, testdata, and top-level test directories) 2021-08-13 20:45:17 +00:00
arm
cgo cmd/compile: enable Asan check for global variables 2022-05-04 16:13:20 +00:00
chrome/gophertool docs: fix case of GitHub 2021-03-05 02:35:21 +00:00
ios all: gofmt main repo 2022-04-11 16:34:30 +00:00
linkcheck all: use bytes.Cut, strings.Cut 2021-10-06 15:53:04 +00:00
reboot misc/reboot: don't use symlinks when copying GOROOT/src 2022-02-08 15:30:12 +00:00
swig cmd/go: fix swig support and run swig tests during run.bash 2017-11-16 17:19:19 +00:00
wasm cmd/link: increase reserved space for passing env on wasm 2021-10-25 20:08:25 +00:00
editors
go.mod cmd/cgo: update to handle ast.IndexListExpr 2021-10-07 18:02:14 +00:00