]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: hoist dwarfGenerateDebugSyms out of dodata()
authorThan McIntosh <thanm@google.com>
Mon, 13 Apr 2020 19:38:03 +0000 (15:38 -0400)
committerThan McIntosh <thanm@google.com>
Tue, 14 Apr 2020 19:36:56 +0000 (19:36 +0000)
Hoist dwarfGenerateDebugSyms call up out of dodata to before
loadlibfull. This required a couple of small tweaks to the
loader and to loadlibfull.

Change-Id: I48ffb450d2e48b9e55775b73a6debcd27dbb7b9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/228221
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/link/internal/ld/data.go
src/cmd/link/internal/ld/dwarf.go
src/cmd/link/internal/ld/lib.go
src/cmd/link/internal/ld/main.go
src/cmd/link/internal/loader/loader.go

index d8c11fa4c00a545a923adf0e4a3f5889d5f91244..aea643fb5ff568b688212f40e3f1d5850a28ba9b 100644 (file)
@@ -1923,8 +1923,6 @@ func (ctxt *Link) dodata() {
                ctxt.datap = append(ctxt.datap, data[symn]...)
        }
 
-       dwarfGenerateDebugSyms(ctxt)
-
        var i int
        for ; i < len(dwarfp); i++ {
                s := dwarfp[i]
index 3ee945c7a0291613858dd15090daf8b7b51f335b..7bb425332515294ccd4cde3ea04f27a3653f6086 100644 (file)
@@ -1970,17 +1970,6 @@ func dwarfGenerateDebugSyms(ctxt *Link) {
 }
 
 func (d *dwctxt2) dwarfGenerateDebugSyms() {
-
-       // Hack: because the "wavefront" hasn't been pushed all the way
-       // up to dodata(), there will have been changes made to the sym.Symbol's
-       // that are not yet reflected in the loader. Call a temporary
-       // loader routine that copies any changes back.
-       // WARNING: changing a symbol's content will usually require
-       // calling the loader cloneToExternal method, meaning that there
-       // can be an increase in memory, so this is likely to mess up any
-       // benchmarking runs.
-       d.ldr.PropagateSymbolChangesBackToLoader()
-
        abbrev := d.writeabbrev()
        syms := []loader.Sym{abbrev}
 
@@ -2036,8 +2025,6 @@ func (d *dwctxt2) dwarfGenerateDebugSyms() {
                }
        }
        dwarfp2 = syms
-       anonVerReplacement := d.linkctxt.Syms.IncVersion()
-       dwarfp = d.ldr.PropagateLoaderChangesToSymbols(dwarfp2, anonVerReplacement)
 }
 
 func (d *dwctxt2) collectlocs(syms []loader.Sym, units []*sym.CompilationUnit) []loader.Sym {
index 727cb056fc0c4c592c4d26bd57e8bb8acaf79d33..108171aaf8a41d21eeff016bf163ea5ae7efae79 100644 (file)
@@ -2801,6 +2801,16 @@ func (ctxt *Link) loadlibfull() {
        // Convert special symbols created by pcln.
        pclntabFirstFunc = ctxt.loader.Syms[pclntabFirstFunc2]
        pclntabLastFunc = ctxt.loader.Syms[pclntabLastFunc2]
+
+       // Populate dwarfp from dwarfp2. If we see a symbol index on dwarfp2
+       // whose loader.Syms entry is nil, something went wrong.
+       for _, symIdx := range dwarfp2 {
+               s := ctxt.loader.Syms[symIdx]
+               if s == nil {
+                       panic(fmt.Sprintf("nil sym for dwarfp2 element %d", symIdx))
+               }
+               dwarfp = append(dwarfp, s)
+       }
 }
 
 func (ctxt *Link) dumpsyms() {
index 182ebdf9d711a83bb45a20bf0f9251f5724a9b1d..2f2700652f5e28bfe00e224c42ce00f6d0b73172 100644 (file)
@@ -298,6 +298,8 @@ func Main(arch *sys.Arch, theArch Arch) {
        container := ctxt.pclntab()
        bench.Start("findfunctab")
        ctxt.findfunctab(container)
+       bench.Start("dwarfGenerateDebugSyms")
+       dwarfGenerateDebugSyms(ctxt)
        bench.Start("loadlibfull")
        ctxt.loadlibfull() // XXX do it here for now
        bench.Start("symtab")
index ff5d8ed32275e6794254a52d7e1669e8ef55e999..3b77aa70e121cd848a809d1a3dbe93c9eb9ee06e 100644 (file)
@@ -2204,13 +2204,15 @@ func loadObjSyms(l *Loader, syms *sym.Symbols, r *oReader) int {
                name := strings.Replace(osym.Name(r.Reader), "\"\".", r.pkgprefix, -1)
                t := sym.AbiSymKindToSymKind[objabi.SymKind(osym.Type())]
                // NB: for the test below, we can skip most anonymous symbols
-               // since they will never be turned into sym.Symbols (ex:
-               // funcdata), however DWARF subprogram DIE symbols (which are
-               // nameless) will eventually need to be turned into
-               // sym.Symbols (with relocations), so the simplest thing to do
-               // is include them as part of this loop.
-               if name == "" && t != sym.SDWARFINFO {
-                       continue
+               // since they will never be turned into sym.Symbols (eg:
+               // funcdata). DWARF symbols are an exception however -- we
+               // want to include all reachable but nameless DWARF symbols.
+               if name == "" {
+                       switch t {
+                       case sym.SDWARFINFO, sym.SDWARFRANGE, sym.SDWARFLOC, sym.SDWARFLINES:
+                       default:
+                               continue
+                       }
                }
                ver := abiToVer(osym.ABI(), r.version)
                if t == sym.SXREF {