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>
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 {