Commit adc80c06 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

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: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 4e4e51c5
......@@ -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 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment