[dev.link] cmd/link: convert DWARF type generation to use loader

Converts the portion of DWARF generation that deals with creation of
type DIEs and constant DIEs to use the new loader interfaces. Creation
of subprogram DIE and compilation unit DIE content still operates on
sym.Symbols at the moment, and happens much later in the linker.

The new code for type DIE generation is gated/guarded by the linker
flag "-newdw", which currently defaults to true. At some point in the
near future this flag should be removed, but it is handy for triage at
the moment.

This patch also includes shim code designed to run after loadlibfull()
that walks through the DIE chains and to converts loader.Sym
references back into sym.Symbol references for the remainder of the
compilation, since the second phase of DWARF has not yet been
converted.

Change-Id: I681a00fb8a1f3c37884a79b373d86411332e07c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/208230
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
This commit is contained in:
Than McIntosh 2019-11-20 10:43:11 -05:00
parent 6a819b0062
commit 25f1b093fe
7 changed files with 2693 additions and 1188 deletions

View file

@ -68,7 +68,10 @@ func addToTextp(ctxt *Link) {
// Put reachable text symbols into Textp.
// do it in postorder so that packages are laid down in dependency order
// internal first, then everything else
// internal first, then everything else. This also populates lib and
// unit Textp slices, which are needed for DWARF
// FIXME: once DWARF is completely converted to using loader.Sym,
// we can remove the *sym.Symbol Textp slices.
ctxt.Library = postorder(ctxt.Library)
for _, doInternal := range [2]bool{true, false} {
for _, lib := range ctxt.Library {
@ -76,23 +79,21 @@ func addToTextp(ctxt *Link) {
continue
}
libtextp := lib.Textp[:0]
for idx, s := range lib.Textp {
for _, 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 idx, s := range lib.DupTextSyms {
for _, 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