]> Cypherpunks repositories - gostls13.git/commit
cmd/link: avoid deadcode of global map vars for programs using plugins
authorThan McIntosh <thanm@google.com>
Wed, 6 Sep 2023 14:15:37 +0000 (10:15 -0400)
committerThan McIntosh <thanm@google.com>
Thu, 7 Sep 2023 13:18:51 +0000 (13:18 +0000)
commit660620dd45dc11f2d889add79bedf2dc771c7d04
tree56b5d8b4830866fb6ea5125292e14f836ee37121
parent3466e57354974cd2d17ce902df02e0ac58b8ded5
cmd/link: avoid deadcode of global map vars for programs using plugins

If a program imports the plugin package, the mechanisms in place for
detecting and deleting unused global map variables are no longer safe,
since it's possibly for a given global map var to be unreferenced in
the main program but referenced by a plugin. This patch changes the
linker to test for plugin use and to avoid removing any unused global
map variables if the main program could possibly load up a plugin.

Fixes #62430.

Change-Id: Ie00b18b681cb0d259e3c859ac947ade5778cd6c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/526115
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/cgo/internal/testplugin/plugin_test.go
src/cmd/cgo/internal/testplugin/testdata/issue62430/main.go [new file with mode: 0644]
src/cmd/cgo/internal/testplugin/testdata/issue62430/plugin.go [new file with mode: 0644]
src/cmd/link/internal/ld/deadcode.go