mirror of
https://github.com/golang/go
synced 2024-11-06 16:36:20 -07:00
[dev.link] cmd/link: keep loader symbol info in sym.CompilationUnit
In sym.Library and sym.CompilationUnit there are slices of *sym.Symbol pointer that hold text symbols contained in the unit lib. To support DWARF generation with new loader, add equivalent slices that hold loader.Sym values for functions in scope. This will be needed if at some point we push the sym.Symbol creation "wavefront" beyond dwarf gen. This patch also insures that live host object symbols are added to the context Textp2 slice, since they would not make it on otherwise. [NB: not sure if this is the best way to do this.] Change-Id: I4f440e12cebc525b1e37082ad39cf7338aeb6b99 Reviewed-on: https://go-review.googlesource.com/c/go/+/208231 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
This commit is contained in:
parent
6b0b7aca8a
commit
186e783730
@ -54,6 +54,18 @@ func addToTextp(ctxt *Link) {
|
||||
}
|
||||
}
|
||||
|
||||
// Append the sym.Symbol's that correspond to the reachable
|
||||
// loader.Sym's created by the new host object loader.
|
||||
// FIXME: is this the right way to do this? Or should there be
|
||||
// some way to associated a given host object symbol with the Go
|
||||
// package that refers to it?
|
||||
for _, s := range ctxt.Textp2 {
|
||||
if !ctxt.loader.AttrReachable(s) {
|
||||
continue
|
||||
}
|
||||
textp = append(textp, ctxt.loader.Syms[s])
|
||||
}
|
||||
|
||||
// Put reachable text symbols into Textp.
|
||||
// do it in postorder so that packages are laid down in dependency order
|
||||
// internal first, then everything else
|
||||
@ -64,21 +76,23 @@ func addToTextp(ctxt *Link) {
|
||||
continue
|
||||
}
|
||||
libtextp := lib.Textp[:0]
|
||||
for _, s := range lib.Textp {
|
||||
for idx, s := range lib.Textp {
|
||||
if s.Attr.Reachable() {
|
||||
textp = append(textp, s)
|
||||
libtextp = append(libtextp, s)
|
||||
if s.Unit != nil {
|
||||
s.Unit.Textp = append(s.Unit.Textp, s)
|
||||
s.Unit.Textp2 = append(s.Unit.Textp2, lib.Textp2[idx])
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, s := range lib.DupTextSyms {
|
||||
for idx, s := range lib.DupTextSyms {
|
||||
if s.Attr.Reachable() && !s.Attr.OnList() {
|
||||
textp = append(textp, s)
|
||||
libtextp = append(libtextp, s)
|
||||
if s.Unit != nil {
|
||||
s.Unit.Textp = append(s.Unit.Textp, s)
|
||||
s.Unit.Textp2 = append(s.Unit.Textp2, lib.DupTextSyms2[idx])
|
||||
}
|
||||
s.Attr |= sym.AttrOnList
|
||||
// dupok symbols may be defined in multiple packages. its
|
||||
|
@ -78,6 +78,7 @@ type Link struct {
|
||||
Shlibs []Shlib
|
||||
Tlsoffset int
|
||||
Textp []*sym.Symbol
|
||||
Textp2 []loader.Sym
|
||||
Filesyms []*sym.Symbol
|
||||
Moduledata *sym.Symbol
|
||||
|
||||
|
@ -1775,6 +1775,7 @@ func loadObjFull(l *Loader, r *oReader) {
|
||||
s := l.Syms[dupsym]
|
||||
if s.Type == sym.STEXT {
|
||||
lib.DupTextSyms = append(lib.DupTextSyms, s)
|
||||
lib.DupTextSyms2 = append(lib.DupTextSyms2, sym.LoaderSym(dupsym))
|
||||
}
|
||||
}
|
||||
continue
|
||||
@ -1996,10 +1997,12 @@ func loadObjFull(l *Loader, r *oReader) {
|
||||
}
|
||||
s.Attr.Set(sym.AttrOnList, true)
|
||||
lib.Textp = append(lib.Textp, s)
|
||||
lib.Textp2 = append(lib.Textp2, sym.LoaderSym(isym))
|
||||
} else {
|
||||
// there may be a dup in another package
|
||||
// put into a temp list and add to text later
|
||||
lib.DupTextSyms = append(lib.DupTextSyms, s)
|
||||
lib.DupTextSyms2 = append(lib.DupTextSyms2, sym.LoaderSym(isym))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ package sym
|
||||
|
||||
import "cmd/internal/dwarf"
|
||||
|
||||
type LoaderSym int
|
||||
|
||||
// CompilationUnit is an abstraction used by DWARF to represent a chunk of
|
||||
// debug-related data. We create a CompilationUnit per Object file in a
|
||||
// library (so, one for all the Go code, one for each assembly file, etc.).
|
||||
@ -20,4 +22,10 @@ type CompilationUnit struct {
|
||||
RangeSyms []*Symbol // Symbols for debug_range
|
||||
Textp []*Symbol // Text symbols in this CU
|
||||
DWARFFileTable []string // The file table used to generate the .debug_lines
|
||||
|
||||
Consts2 LoaderSym // Package constants DIEs (loader)
|
||||
FuncDIEs2 []LoaderSym // Function DIE subtrees (loader)
|
||||
AbsFnDIEs2 []LoaderSym // Abstract function DIE subtrees (loader)
|
||||
RangeSyms2 []LoaderSym // Symbols for debug_range (loader)
|
||||
Textp2 []LoaderSym // Text symbols in this CU (loader)
|
||||
}
|
||||
|
@ -18,6 +18,9 @@ type Library struct {
|
||||
Main bool
|
||||
Safe bool
|
||||
Units []*CompilationUnit
|
||||
|
||||
Textp2 []LoaderSym // text syms defined in this library
|
||||
DupTextSyms2 []LoaderSym // dupok text syms defined in this library
|
||||
}
|
||||
|
||||
func (l Library) String() string {
|
||||
|
Loading…
Reference in New Issue
Block a user