]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/{compile,link}: fix bug in map.zero handling
authorThan McIntosh <thanm@google.com>
Thu, 15 Jul 2021 20:29:36 +0000 (16:29 -0400)
committerThan McIntosh <thanm@google.com>
Mon, 19 Jul 2021 13:27:46 +0000 (13:27 +0000)
commit49402bee36fd3d5cee9f4b2d2e1e8560ead0203b
tree94d1d05e1e3e3d0807549be3f3726f3ebb13492c
parenta66190eceeea63aab0b5410ae3222454e5e0cd96
cmd/{compile,link}: fix bug in map.zero handling

In CL 326211 a change was made to switch "go.map.zero" symbols from
non-pkg DUPOK symbols to hashed symbols. The intent of this change was
ensure that in cases where there are multiple competing go.map.zero
symbols feeding into a link, the largest map.zero symbol is selected.
The change was buggy, however, and resulted in duplicate symbols in
the final binary (see bug cited below for details). This duplication
was relatively benign for linux/ELF, but causes duplicate definition
errors on Windows.

This patch switches "go.map.zero" symbols back from hashed symbols to
non-pkg DUPOK symbols, and updates the relevant code in the loader to
ensure that we do the right thing when there are multiple competing
DUPOK symbols with different sizes.

Fixes #47185.

Change-Id: I8aeb910c65827f5380144d07646006ba553c9251
Reviewed-on: https://go-review.googlesource.com/c/go/+/334930
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/compile/internal/gc/obj.go
src/cmd/link/internal/loader/loader.go
test/fixedbugs/issue47185.dir/bad/bad.go [new file with mode: 0644]
test/fixedbugs/issue47185.dir/main.go [new file with mode: 0644]
test/fixedbugs/issue47185.go [new file with mode: 0644]