Commit e29efbcb authored by Austin Clements's avatar Austin Clements

cmd/link: fix some unintentional symbol creation

There are two places in DWARF generation that create symbols when they
really just want to get the symbol if it exists. writeranges, in
particular, will create a DWARF range symbol for every single textp
symbol (though they won't get linked into any list, so they don't
affect the binary).

Fix these to use ROLookup instead of Lookup.

Change-Id: I401eadf22890e296bd08bccaa6ba2fd8fac800cd
Reviewed-on: https://go-review.googlesource.com/69971
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarHeschi Kreinick <heschi@google.com>
Reviewed-by: default avatarThan McIntosh <thanm@google.com>
parent 371eda45
...@@ -1273,8 +1273,8 @@ func writeframes(ctxt *Link, syms []*sym.Symbol) []*sym.Symbol { ...@@ -1273,8 +1273,8 @@ func writeframes(ctxt *Link, syms []*sym.Symbol) []*sym.Symbol {
func writeranges(ctxt *Link, syms []*sym.Symbol) []*sym.Symbol { func writeranges(ctxt *Link, syms []*sym.Symbol) []*sym.Symbol {
empty := true empty := true
for _, s := range ctxt.Textp { for _, s := range ctxt.Textp {
rangeSym := ctxt.Syms.Lookup(dwarf.RangePrefix+s.Name, int(s.Version)) rangeSym := ctxt.Syms.ROLookup(dwarf.RangePrefix+s.Name, int(s.Version))
if rangeSym.Size == 0 { if rangeSym == nil || rangeSym.Size == 0 {
continue continue
} }
rangeSym.Attr |= sym.AttrReachable | sym.AttrNotInSymbolTable rangeSym.Attr |= sym.AttrReachable | sym.AttrNotInSymbolTable
...@@ -1555,7 +1555,7 @@ func dwarfgeneratedebugsyms(ctxt *Link) { ...@@ -1555,7 +1555,7 @@ func dwarfgeneratedebugsyms(ctxt *Link) {
var consts []*sym.Symbol var consts []*sym.Symbol
for _, lib := range ctxt.Library { for _, lib := range ctxt.Library {
if s := ctxt.Syms.Lookup(dwarf.ConstInfoPrefix+lib.Pkg, 0); s != nil { if s := ctxt.Syms.ROLookup(dwarf.ConstInfoPrefix+lib.Pkg, 0); s != nil {
importInfoSymbol(ctxt, s) importInfoSymbol(ctxt, s)
consts = append(consts, s) consts = append(consts, s)
} }
......
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