Commit ce6e0b08 authored by Austin Clements's avatar Austin Clements

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 <austin@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: 's avatarHeschi Kreinick <heschi@google.com>
Reviewed-by: 's avatarThan McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 77c27c31
...@@ -993,7 +993,6 @@ func writelines(ctxt *Link, syms []*sym.Symbol) ([]*sym.Symbol, []*sym.Symbol) { ...@@ -993,7 +993,6 @@ func writelines(ctxt *Link, syms []*sym.Symbol) ([]*sym.Symbol, []*sym.Symbol) {
var dwarfctxt dwarf.Context = dwctxt{ctxt} var dwarfctxt dwarf.Context = dwctxt{ctxt}
ls := ctxt.Syms.Lookup(".debug_line", 0) ls := ctxt.Syms.Lookup(".debug_line", 0)
ls.Type = sym.SDWARFSECT ls.Type = sym.SDWARFSECT
ls.R = ls.R[:0]
syms = append(syms, ls) syms = append(syms, ls)
var funcs []*sym.Symbol var funcs []*sym.Symbol
...@@ -1162,7 +1161,6 @@ func writeframes(ctxt *Link, syms []*sym.Symbol) []*sym.Symbol { ...@@ -1162,7 +1161,6 @@ func writeframes(ctxt *Link, syms []*sym.Symbol) []*sym.Symbol {
var dwarfctxt dwarf.Context = dwctxt{ctxt} var dwarfctxt dwarf.Context = dwctxt{ctxt}
fs := ctxt.Syms.Lookup(".debug_frame", 0) fs := ctxt.Syms.Lookup(".debug_frame", 0)
fs.Type = sym.SDWARFSECT fs.Type = sym.SDWARFSECT
fs.R = fs.R[:0]
syms = append(syms, fs) syms = append(syms, fs)
// Emit the CIE, Section 6.4.1 // Emit the CIE, Section 6.4.1
...@@ -1287,7 +1285,6 @@ func writeranges(ctxt *Link, syms []*sym.Symbol) []*sym.Symbol { ...@@ -1287,7 +1285,6 @@ func writeranges(ctxt *Link, syms []*sym.Symbol) []*sym.Symbol {
rangesec := ctxt.Syms.Lookup(".debug_ranges", 0) rangesec := ctxt.Syms.Lookup(".debug_ranges", 0)
rangesec.Type = sym.SDWARFRANGE rangesec.Type = sym.SDWARFRANGE
rangesec.Attr |= sym.AttrReachable rangesec.Attr |= sym.AttrReachable
rangesec.R = rangesec.R[:0]
syms = append(syms, rangesec) syms = append(syms, rangesec)
} }
...@@ -1303,7 +1300,6 @@ const ( ...@@ -1303,7 +1300,6 @@ const (
func writeinfo(ctxt *Link, syms []*sym.Symbol, funcs, consts []*sym.Symbol, abbrevsym *sym.Symbol) []*sym.Symbol { func writeinfo(ctxt *Link, syms []*sym.Symbol, funcs, consts []*sym.Symbol, abbrevsym *sym.Symbol) []*sym.Symbol {
infosec := ctxt.Syms.Lookup(".debug_info", 0) infosec := ctxt.Syms.Lookup(".debug_info", 0)
infosec.R = infosec.R[:0]
infosec.Type = sym.SDWARFINFO infosec.Type = sym.SDWARFINFO
infosec.Attr |= sym.AttrReachable infosec.Attr |= sym.AttrReachable
syms = append(syms, infosec) syms = append(syms, infosec)
...@@ -1558,7 +1554,6 @@ func collectlocs(ctxt *Link, syms []*sym.Symbol, funcs []*sym.Symbol) []*sym.Sym ...@@ -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. // Don't emit .debug_loc if it's empty -- it makes the ARM linker mad.
if !empty { if !empty {
locsym := ctxt.Syms.Lookup(".debug_loc", 0) locsym := ctxt.Syms.Lookup(".debug_loc", 0)
locsym.R = locsym.R[:0]
locsym.Type = sym.SDWARFLOC locsym.Type = sym.SDWARFLOC
locsym.Attr |= sym.AttrReachable locsym.Attr |= sym.AttrReachable
syms = append(syms, locsym) syms = append(syms, locsym)
......
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