diff options
author | Cherry Mui <cherryyz@google.com> | 2022-03-16 13:07:57 -0400 |
---|---|---|
committer | Cherry Mui <cherryyz@google.com> | 2022-04-04 18:02:38 +0000 |
commit | eb75219438e3c3d8947373c1f27c3ac4abf7ee8b (patch) | |
tree | 46ca701a6dbba62af4f76191f5017ed5b30b145d /misc/cgo/testplugin/testdata/method3/main.go | |
parent | 4e69fddc640c727865490706633833870408e6ff (diff) | |
download | go-eb75219438e3c3d8947373c1f27c3ac4abf7ee8b.tar.gz go-eb75219438e3c3d8947373c1f27c3ac4abf7ee8b.zip |
[release-branch.go1.17] cmd/link: mark unexported methods for plugins
When plugin is used, we already mark all exported methods
reachable. However, when the plugin and the host program share
a common package, an unexported method could also be reachable
from both the plugin and the host via interfaces. We need to mark
them as well.
Fixes #51736.
Updates #51621.
Change-Id: I1a70d3f96b66b803f2d0ab14d00ed0df276ea500
Reviewed-on: https://go-review.googlesource.com/c/go/+/393365
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
(cherry picked from commit 91631bc7e0131367eb051b581cf34573399ac592)
Reviewed-on: https://go-review.googlesource.com/c/go/+/397484
Diffstat (limited to 'misc/cgo/testplugin/testdata/method3/main.go')
-rw-r--r-- | misc/cgo/testplugin/testdata/method3/main.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/misc/cgo/testplugin/testdata/method3/main.go b/misc/cgo/testplugin/testdata/method3/main.go new file mode 100644 index 0000000000..a3a51711cd --- /dev/null +++ b/misc/cgo/testplugin/testdata/method3/main.go @@ -0,0 +1,32 @@ +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// An unexported method can be reachable from the plugin via interface +// when a package is shared. So it need to be live. + +package main + +import ( + "plugin" + + "testplugin/method3/p" +) + +var i p.I + +func main() { + pl, err := plugin.Open("method3.so") + if err != nil { + panic(err) + } + + f, err := pl.Lookup("F") + if err != nil { + panic(err) + } + + f.(func())() + + i = p.T(123) +} |