]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: remove silly sym.R[:0] truncation
authorAustin Clements <austin@google.com>
Wed, 11 Oct 2017 19:57:58 +0000 (15:57 -0400)
committerAustin Clements <austin@google.com>
Thu, 12 Oct 2017 18:56:20 +0000 (18:56 +0000)
The DWARF code currently clears all section relocations every time it
creates a section. This is unnecessary and confusing, so don't do it.

This dates back to
https://codereview.appspot.com/7891044/diff/26001/src/cmd/ld/dwarf.c.
At the time, this was only done for one symbol and that symbol was
used solely for collecting relocations (which is why it made sense to
clear the relocations but not the actual data). Furthermore, DWARF
generation potentially required two passes, so it was important to
clear the state from the first pass. None of this is true now, but
this pattern had been cargo-culted all over the dwarf.go.

Change-Id: I87d4ff8ccd5c807796241559be46168ce3ccb49a
Reviewed-on: https://go-review.googlesource.com/70312
Run-TryBot: Austin Clements <austin@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/link/internal/ld/dwarf.go

index 02eea54435dfef29cf7af559de8d608306f6f52f..68fef583a21b7234e55136c9f89e66b08827f049 100644 (file)
@@ -993,7 +993,6 @@ func writelines(ctxt *Link, syms []*sym.Symbol) ([]*sym.Symbol, []*sym.Symbol) {
        var dwarfctxt dwarf.Context = dwctxt{ctxt}
        ls := ctxt.Syms.Lookup(".debug_line", 0)
        ls.Type = sym.SDWARFSECT
-       ls.R = ls.R[:0]
 
        syms = append(syms, ls)
        var funcs []*sym.Symbol
@@ -1162,7 +1161,6 @@ func writeframes(ctxt *Link, syms []*sym.Symbol) []*sym.Symbol {
        var dwarfctxt dwarf.Context = dwctxt{ctxt}
        fs := ctxt.Syms.Lookup(".debug_frame", 0)
        fs.Type = sym.SDWARFSECT
-       fs.R = fs.R[:0]
        syms = append(syms, fs)
 
        // Emit the CIE, Section 6.4.1
@@ -1287,7 +1285,6 @@ func writeranges(ctxt *Link, syms []*sym.Symbol) []*sym.Symbol {
                rangesec := ctxt.Syms.Lookup(".debug_ranges", 0)
                rangesec.Type = sym.SDWARFRANGE
                rangesec.Attr |= sym.AttrReachable
-               rangesec.R = rangesec.R[:0]
 
                syms = append(syms, rangesec)
        }
@@ -1303,7 +1300,6 @@ const (
 
 func writeinfo(ctxt *Link, syms []*sym.Symbol, funcs, consts []*sym.Symbol, abbrevsym *sym.Symbol) []*sym.Symbol {
        infosec := ctxt.Syms.Lookup(".debug_info", 0)
-       infosec.R = infosec.R[:0]
        infosec.Type = sym.SDWARFINFO
        infosec.Attr |= sym.AttrReachable
        syms = append(syms, infosec)
@@ -1558,7 +1554,6 @@ func collectlocs(ctxt *Link, syms []*sym.Symbol, funcs []*sym.Symbol) []*sym.Sym
        // Don't emit .debug_loc if it's empty -- it makes the ARM linker mad.
        if !empty {
                locsym := ctxt.Syms.Lookup(".debug_loc", 0)
-               locsym.R = locsym.R[:0]
                locsym.Type = sym.SDWARFLOC
                locsym.Attr |= sym.AttrReachable
                syms = append(syms, locsym)