From ce6e0b089f14131889b8e0960f958d07e7bb9108 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Wed, 11 Oct 2017 15:57:58 -0400 Subject: [PATCH] cmd/link: remove silly sym.R[:0] truncation 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 Run-TryBot: Heschi Kreinick Reviewed-by: Heschi Kreinick Reviewed-by: Than McIntosh TryBot-Result: Gobot Gobot --- src/cmd/link/internal/ld/dwarf.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/cmd/link/internal/ld/dwarf.go b/src/cmd/link/internal/ld/dwarf.go index 02eea54435..68fef583a2 100644 --- a/src/cmd/link/internal/ld/dwarf.go +++ b/src/cmd/link/internal/ld/dwarf.go @@ -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) -- 2.48.1