1
0
mirror of https://github.com/golang/go synced 2024-11-08 03:46:10 -07:00
go/misc/cgo/testsanitizers/testdata/asan_linkerx/main.go
Cherry Mui 9fe17a0340 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>
2022-10-13 18:47:30 +00:00

29 lines
463 B
Go

package main
import "misc/cgo/testsanitizers/testdata/asan_linkerx/p"
func pstring(s *string) {
println(*s)
}
func main() {
all := []*string{
&S1, &S2, &S3, &S4, &S5, &S6, &S7, &S8, &S9, &S10,
&p.S1, &p.S2, &p.S3, &p.S4, &p.S5, &p.S6, &p.S7, &p.S8, &p.S9, &p.S10,
}
for _, ps := range all {
pstring(ps)
}
}
var S1 string
var S2 string
var S3 string
var S4 string
var S5 string
var S6 string
var S7 string
var S8 string
var S9 string
var S10 string