1
0
mirror of https://github.com/golang/go synced 2024-11-19 08:54:47 -07:00

cmd/compile: refactor Linksym

Extract a helper function, linksymname.
This simplifies Linksym,
and linksymname will be useful in future work.

Change-Id: Ic5ff8b704a16d5020f6931e008e2f630f687cbd3
Reviewed-on: https://go-review.googlesource.com/40550
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Josh Bleecher Snyder 2017-04-13 06:31:05 -07:00
parent 4e4e51c5c5
commit adc80c0665

View File

@ -227,25 +227,24 @@ func dumpglobls() {
funcsyms = nil
}
func linksymname(s *types.Sym) string {
if isblanksym(s) {
return "_"
}
if s.Linkname != "" {
return s.Linkname
}
return s.Pkg.Prefix + "." + s.Name
}
func Linksym(s *types.Sym) *obj.LSym {
if s == nil {
return nil
}
if s.Lsym != nil {
return s.Lsym
if s.Lsym == nil {
s.Lsym = Ctxt.Lookup(linksymname(s), 0)
}
var name string
if isblanksym(s) {
name = "_"
} else if s.Linkname != "" {
name = s.Linkname
} else {
name = s.Pkg.Prefix + "." + s.Name
}
ls := Ctxt.Lookup(name, 0)
s.Lsym = ls
return ls
return s.Lsym
}
func duintxx(s *types.Sym, off int, v uint64, wid int) int {