]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/link: don't reset variable size when handling -X flag
authorCherry Mui <cherryyz@google.com>
Wed, 12 Oct 2022 20:24:34 +0000 (16:24 -0400)
committerCherry Mui <cherryyz@google.com>
Thu, 13 Oct 2022 18:47:30 +0000 (18:47 +0000)
commit9fe17a0340b1609355aa5ce1828a0cf39e0a8092
tree73f366e6a5047c2d43cc0e71e3a81aeb3c8a465e
parent36ca37f3a04aac4b67aa7fe3cfe480c891d0d53f
cmd/link: don't reset variable size when handling -X flag

The linker's -X flag allows setting/changing a string variable's
content at link time. Currently it resets its size then write a
new string header pointing to the new content. This mostly works.
But under ASAN build the string variable can have larger size
than the usual 2 words, due to the red zone. Resetting the size
can cause the variable to "overlap" (in ASAN's view) with other
variables. Don't reset the size.

Fixes #56175.

Change-Id: Ib364208201a7a2fd7f44f9b1797834198736a405
Reviewed-on: https://go-review.googlesource.com/c/go/+/442635
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
misc/cgo/testsanitizers/asan_test.go
misc/cgo/testsanitizers/testdata/asan_linkerx/main.go [new file with mode: 0644]
misc/cgo/testsanitizers/testdata/asan_linkerx/p/p.go [new file with mode: 0644]
src/cmd/link/internal/ld/data.go