aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/internal/ssagen/abi.go2
-rw-r--r--src/cmd/compile/internal/staticdata/data.go35
2 files changed, 19 insertions, 18 deletions
diff --git a/src/cmd/compile/internal/ssagen/abi.go b/src/cmd/compile/internal/ssagen/abi.go
index 6d391ed9f7..b6137756d4 100644
--- a/src/cmd/compile/internal/ssagen/abi.go
+++ b/src/cmd/compile/internal/ssagen/abi.go
@@ -143,7 +143,7 @@ func InitLSym(f *ir.Func, hasBody bool) {
if f.LSym != nil && objabi.Experiment.RegabiWrappers {
return
}
- staticdata.NeedFuncSym(f.Sym())
+ staticdata.NeedFuncSym(f)
selectLSym(f, hasBody)
if hasBody {
setupTextLSym(f, 0)
diff --git a/src/cmd/compile/internal/staticdata/data.go b/src/cmd/compile/internal/staticdata/data.go
index b06fd7aa4b..fca2a63eb4 100644
--- a/src/cmd/compile/internal/staticdata/data.go
+++ b/src/cmd/compile/internal/staticdata/data.go
@@ -214,11 +214,16 @@ func dstringdata(s *obj.LSym, off int, t string, pos src.XPos, what string) int
var (
funcsymsmu sync.Mutex // protects funcsyms and associated package lookups (see func funcsym)
- funcsyms []*types.Sym
+ funcsyms []*ir.Name // functions that need function value symbols
)
-// FuncSym returns s·f.
-func FuncSym(s *types.Sym) *types.Sym {
+// FuncLinksym returns n·f, the function value symbol for n.
+func FuncLinksym(n *ir.Name) *obj.LSym {
+ if n.Op() != ir.ONAME || n.Class != ir.PFUNC {
+ base.Fatalf("expected func name: %v", n)
+ }
+ s := n.Sym()
+
// funcsymsmu here serves to protect not just mutations of funcsyms (below),
// but also the package lookup of the func sym name,
// since this function gets called concurrently from the backend.
@@ -235,17 +240,11 @@ func FuncSym(s *types.Sym) *types.Sym {
// symbols will be created explicitly with NeedFuncSym.
// See the NeedFuncSym comment for details.
if !base.Ctxt.Flag_dynlink && !existed {
- funcsyms = append(funcsyms, s)
+ funcsyms = append(funcsyms, n)
}
funcsymsmu.Unlock()
- return sf
-}
-func FuncLinksym(n *ir.Name) *obj.LSym {
- if n.Op() != ir.ONAME || n.Class != ir.PFUNC {
- base.Fatalf("expected func name: %v", n)
- }
- return FuncSym(n.Sym()).Linksym()
+ return sf.Linksym()
}
func GlobalLinksym(n *ir.Name) *obj.LSym {
@@ -255,16 +254,16 @@ func GlobalLinksym(n *ir.Name) *obj.LSym {
return n.Linksym()
}
-// NeedFuncSym ensures that s·f is exported, if needed.
+// NeedFuncSym ensures that fn·f is exported, if needed.
// It is only used with -dynlink.
// When not compiling for dynamic linking,
// the funcsyms are created as needed by
// the packages that use them.
-// Normally we emit the s·f stubs as DUPOK syms,
+// Normally we emit the fn·f stubs as DUPOK syms,
// but DUPOK doesn't work across shared library boundaries.
// So instead, when dynamic linking, we only create
-// the s·f stubs in s's package.
-func NeedFuncSym(s *types.Sym) {
+// the fn·f stubs in fn's package.
+func NeedFuncSym(fn *ir.Func) {
if base.Ctxt.InParallel {
// The append below probably just needs to lock
// funcsymsmu, like in FuncSym.
@@ -273,6 +272,7 @@ func NeedFuncSym(s *types.Sym) {
if !base.Ctxt.Flag_dynlink {
return
}
+ s := fn.Nname.Sym()
if s.IsBlank() {
return
}
@@ -282,14 +282,15 @@ func NeedFuncSym(s *types.Sym) {
// get funcsyms.
return
}
- funcsyms = append(funcsyms, s)
+ funcsyms = append(funcsyms, fn.Nname)
}
func WriteFuncSyms() {
sort.Slice(funcsyms, func(i, j int) bool {
return funcsyms[i].Linksym().Name < funcsyms[j].Linksym().Name
})
- for _, s := range funcsyms {
+ for _, nam := range funcsyms {
+ s := nam.Sym()
sf := s.Pkg.Lookup(ir.FuncSymName(s)).Linksym()
objw.SymPtr(sf, 0, s.Linksym(), 0)
objw.Global(sf, int32(types.PtrSize), obj.DUPOK|obj.RODATA)