]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: fix some unintentional symbol creation
authorAustin Clements <austin@google.com>
Tue, 10 Oct 2017 15:58:31 +0000 (11:58 -0400)
committerAustin Clements <austin@google.com>
Wed, 11 Oct 2017 20:06:41 +0000 (20:06 +0000)
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: Heschi Kreinick <heschi@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/link/internal/ld/dwarf.go

index 4fcd86f45c60f92e4ee86488f9564be2f68f3b85..dd6d983f56d48220803f1de66861365ddc23facd 100644 (file)
@@ -1273,8 +1273,8 @@ func writeframes(ctxt *Link, syms []*sym.Symbol) []*sym.Symbol {
 func writeranges(ctxt *Link, syms []*sym.Symbol) []*sym.Symbol {
        empty := true
        for _, s := range ctxt.Textp {
-               rangeSym := ctxt.Syms.Lookup(dwarf.RangePrefix+s.Name, int(s.Version))
-               if rangeSym.Size == 0 {
+               rangeSym := ctxt.Syms.ROLookup(dwarf.RangePrefix+s.Name, int(s.Version))
+               if rangeSym == nil || rangeSym.Size == 0 {
                        continue
                }
                rangeSym.Attr |= sym.AttrReachable | sym.AttrNotInSymbolTable
@@ -1555,7 +1555,7 @@ func dwarfgeneratedebugsyms(ctxt *Link) {
 
        var consts []*sym.Symbol
        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)
                        consts = append(consts, s)
                }