1
0
mirror of https://github.com/golang/go synced 2024-09-28 20:24:29 -06:00
go/misc/cgo
fanzha02 1b0f9fbb67 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.

(This is a redo of CL 401775 with a fix for a build break due to an
intervening commit that removed the internal/execabs package.)

Updates #44853.

Change-Id: I719d4ef2b22cb2d5516e1494cd453c3efb47d6c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/403851
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-04 18:51:19 +00:00
..
errors misc/cgo: fix aliasing bugs in parallel tests that append to shared slices 2022-02-07 17:51:57 +00:00
fortran misc/cgo/fortran: avoid writing to $PWD 2019-11-20 22:37:23 +00:00
gmp all: gofmt main repo 2022-04-11 16:34:30 +00:00
life all: update references to symbols moved from io/ioutil to io 2021-04-05 17:51:15 +00:00
nocgo cmd/ld: really import runtime/cgo for external link 2014-05-20 21:36:50 -07:00
stdio all: update references to symbols moved from io/ioutil to io 2021-04-05 17:51:15 +00:00
test misc/cgo/test: remove timing dependency from TestParallelSleep 2022-04-21 18:43:55 +00:00
testasan misc: log 'ok' from 'go run' tests on success 2019-11-25 16:43:27 +00:00
testcarchive misc/cgo: fix aliasing bugs in parallel tests that append to shared slices 2022-02-07 17:51:57 +00:00
testcshared cmd/go: cgo export header to be compatible with MSVC complex types 2022-04-08 14:13:32 +00:00
testgodefs cmd/cgo: retain original file paths in godefs generated comment 2022-04-03 07:18:10 +00:00
testplugin cmd/link: mark unexported methods for plugins 2022-03-16 20:10:07 +00:00
testsanitizers cmd/compile: enable Asan check for global variables 2022-05-04 18:51:19 +00:00
testshared [dev.boringcrypto] all: add boringcrypto build tags 2022-04-29 14:23:22 +00:00
testsigfwd misc: log 'ok' from 'go run' tests on success 2019-11-25 16:43:27 +00:00
testso all: gofmt more (but vendor, testdata, and top-level test directories) 2021-08-13 20:45:17 +00:00
testsovar all: gofmt more (but vendor, testdata, and top-level test directories) 2021-08-13 20:45:17 +00:00
testtls all: gofmt more (but vendor, testdata, and top-level test directories) 2021-08-13 20:45:17 +00:00