1 // Copyright 2021 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // Issue 44956: writable static temp is not exported correctly.
6 // In the test below, package base is
12 // X = &stmp // static
13 // stmp = makemap(...) // in init function
15 // plugin1 and plugin2 both import base. plugin1 doesn't use
16 // base.X, so that symbol is deadcoded in plugin1.
18 // plugin1 is loaded first. base.init runs at that point, which
19 // initialize base.stmp.
21 // plugin2 is then loaded. base.init already ran, so it doesn't run
22 // again. When base.stmp is not exported, plugin2's base.X points to
23 // its own private base.stmp, which is not initialized, fail.
30 _, err := plugin.Open("issue44956p1.so")
35 p2, err := plugin.Open("issue44956p2.so")
39 f, err := p2.Lookup("F")
43 x := f.(func() *map[int]int)()
44 if x == nil || (*x)[123] != 456 {