diff options
| author | Than McIntosh <thanm@google.com> | 2023-09-06 10:15:37 -0400 |
|---|---|---|
| committer | Than McIntosh <thanm@google.com> | 2023-09-07 13:18:51 +0000 |
| commit | 660620dd45dc11f2d889add79bedf2dc771c7d04 (patch) | |
| tree | 56b5d8b4830866fb6ea5125292e14f836ee37121 /src/cmd/cgo/internal/testplugin/plugin_test.go | |
| parent | 3466e57354974cd2d17ce902df02e0ac58b8ded5 (diff) | |
| download | go-660620dd45dc11f2d889add79bedf2dc771c7d04.tar.xz | |
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>
Diffstat (limited to 'src/cmd/cgo/internal/testplugin/plugin_test.go')
| -rw-r--r-- | src/cmd/cgo/internal/testplugin/plugin_test.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cmd/cgo/internal/testplugin/plugin_test.go b/src/cmd/cgo/internal/testplugin/plugin_test.go index 2950b6c970..1e32ff8a06 100644 --- a/src/cmd/cgo/internal/testplugin/plugin_test.go +++ b/src/cmd/cgo/internal/testplugin/plugin_test.go @@ -388,3 +388,10 @@ func TestSymbolNameMangle(t *testing.T) { globalSkip(t) goCmd(t, "build", "-buildmode=plugin", "-o", "mangle.so", "./mangle/plugin.go") } + +func TestIssue62430(t *testing.T) { + globalSkip(t) + goCmd(t, "build", "-buildmode=plugin", "-o", "issue62430.so", "./issue62430/plugin.go") + goCmd(t, "build", "-o", "issue62430.exe", "./issue62430/main.go") + run(t, "./issue62430.exe") +} |
