1
0
mirror of https://github.com/golang/go synced 2024-10-01 20:28:33 -06:00

cmd/internal/obj: generate function DWARF symbols early

This removes a concurrent access of ctxt.Data.

Updates #15756

Change-Id: Id017e90e47e093cd8825907f3853bb3d3bf8280d
Reviewed-on: https://go-review.googlesource.com/40507
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Josh Bleecher Snyder 2017-04-13 05:57:59 -07:00
parent 7fa3b79ce5
commit 4e4e51c5c5
2 changed files with 21 additions and 10 deletions

View File

@ -555,19 +555,24 @@ func (c dwCtxt) AddSectionOffset(s dwarf.Sym, size int, t interface{}, ofs int64
r.Type = R_DWARFREF
}
// makeFuncDebugEntry makes a DWARF Debugging Information Entry
// for TEXT symbol s.
func makeFuncDebugEntry(ctxt *Link, curfn interface{}, s *LSym) {
dsym := ctxt.Lookup(dwarf.InfoPrefix+s.Name, int(s.Version))
if dsym.Size != 0 {
return
// dwarfSym returns the DWARF symbol for TEXT symbol.
func (ctxt *Link) dwarfSym(s *LSym) *LSym {
if s.Type != STEXT {
ctxt.Diag("dwarfSym of non-TEXT %v", s)
}
return ctxt.Lookup(dwarf.InfoPrefix+s.Name, int(s.Version))
}
// populateDWARF fills in the DWARF Debugging Information Entry for TEXT symbol s.
// The DWARF symbol must already have been initialized in InitTextSym.
func (ctxt *Link) populateDWARF(curfn interface{}, s *LSym) {
dsym := ctxt.dwarfSym(s)
if dsym.Size != 0 {
ctxt.Diag("makeFuncDebugEntry double process %v", s)
}
dsym.Type = SDWARFINFO
dsym.Set(AttrDuplicateOK, s.DuplicateOK())
var vars []*dwarf.Var
if ctxt.DebugInfo != nil {
vars = ctxt.DebugInfo(s, curfn)
}
dwarf.PutFunc(dwCtxt{ctxt}, dsym, s.Name, s.Version == 0, s, s.Size, vars)
ctxt.Data = append(ctxt.Data, dsym)
}

View File

@ -105,7 +105,7 @@ func Flushplist(ctxt *Link, plist *Plist, newprog ProgAlloc) {
ctxt.Arch.Preprocess(ctxt, s, newprog)
ctxt.Arch.Assemble(ctxt, s, newprog)
linkpcln(ctxt, s)
makeFuncDebugEntry(ctxt, plist.Curfn, s)
ctxt.populateDWARF(plist.Curfn, s)
}
}
@ -133,6 +133,12 @@ func (ctxt *Link) InitTextSym(s *LSym, flag int) {
s.Set(AttrNoFrame, flag&NOFRAME != 0)
s.Type = STEXT
ctxt.Text = append(ctxt.Text, s)
// Set up DWARF entry for s.
dsym := ctxt.dwarfSym(s)
dsym.Type = SDWARFINFO
dsym.Set(AttrDuplicateOK, s.DuplicateOK())
ctxt.Data = append(ctxt.Data, dsym)
}
func (ctxt *Link) Globl(s *LSym, size int64, flag int) {