diff options
| author | David Crawshaw <crawshaw@golang.org> | 2016-11-12 06:50:24 -0500 |
|---|---|---|
| committer | David Crawshaw <crawshaw@golang.org> | 2016-11-15 16:17:07 +0000 |
| commit | fab3fcaf750445c0016a44376aa81c720133e02c (patch) | |
| tree | 883206d965c8b3e7162f44697ffabd84f721c32c /misc/cgo/testplugin/src | |
| parent | 03da2690c9fefdbaff613f9ccc224b5f0abfbe16 (diff) | |
| download | go-fab3fcaf750445c0016a44376aa81c720133e02c.tar.xz | |
cmd/go: use build ID as plugin symbol prefix
Updates #17821
Change-Id: Iebd2e88b2d4f3d757ffad72456f4bfc0607d8110
Reviewed-on: https://go-review.googlesource.com/33162
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'misc/cgo/testplugin/src')
| -rw-r--r-- | misc/cgo/testplugin/src/host/host.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/misc/cgo/testplugin/src/host/host.go b/misc/cgo/testplugin/src/host/host.go index b3b4df3d58..898f44efa1 100644 --- a/misc/cgo/testplugin/src/host/host.go +++ b/misc/cgo/testplugin/src/host/host.go @@ -18,6 +18,35 @@ func init() { common.X *= 5 } +// testUnnamed tests that two plugins built with .go files passed on +// the command line do not have overlapping symbols. That is, +// unnamed1.so/FuncInt and unnamed2.so/FuncInt should be distinct functions. +func testUnnamed() { + p, err := plugin.Open("unnamed1.so") + if err != nil { + log.Fatalf(`plugin.Open("unnamed1.so"): %v`, err) + } + fn, err := p.Lookup("FuncInt") + if err != nil { + log.Fatalf(`unnamed1.so: Lookup("FuncInt") failed: %v`, err) + } + if got, want := fn.(func() int)(), 1; got != want { + log.Fatalf("unnamed1.so: FuncInt()=%d, want %d", got, want) + } + + p, err = plugin.Open("unnamed2.so") + if err != nil { + log.Fatalf(`plugin.Open("unnamed2.so"): %v`, err) + } + fn, err = p.Lookup("FuncInt") + if err != nil { + log.Fatalf(`unnamed2.so: Lookup("FuncInt") failed: %v`, err) + } + if got, want := fn.(func() int)(), 2; got != want { + log.Fatalf("unnamed2.so: FuncInt()=%d, want %d", got, want) + } +} + func main() { if got, want := common.X, 3*5; got != want { log.Fatalf("before plugin load common.X=%d, want %d", got, want) @@ -113,5 +142,7 @@ func main() { log.Fatalf(`plugin.Open("plugin-mismatch.so"): error does not mention "different version": %v`, s) } + testUnnamed() + fmt.Println("PASS") } |
