]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: remove unnecessary file processing from writelines
authorThan McIntosh <thanm@google.com>
Thu, 12 Mar 2020 15:04:36 +0000 (11:04 -0400)
committerThan McIntosh <thanm@google.com>
Thu, 12 Mar 2020 18:36:55 +0000 (18:36 +0000)
The linker DWARF-gen's line table writing routine contains a loop that
walks all abstract function DIEs looking for files that aren't
referenced in concrete function DIEs. Turns out this loop is no longer
necessary, most likely because the compiler emits an explicit DWARF
file table into the object file.

This patch removes the offending loop. This is a prelude to some
additional work that will hopefully get rid of file renumbering in
writelines altogether (still WIP).

Change-Id: I3b3a9acce1bae7dda878ab6de2d3436de302712e
Reviewed-on: https://go-review.googlesource.com/c/go/+/223145
Run-TryBot: Than McIntosh <thanm@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/dwarf.go

index 0c31bf8c6f6d5a8e3cc7cd858181ab3d0326af94..8376ea82db21acbbc3a77f9e6793ecc1cc1947ca 100644 (file)
@@ -1211,35 +1211,6 @@ func (d *dwctxt2) writelines(unit *sym.CompilationUnit, ls loader.Sym) {
                }
        }
 
-       // Grab files for inlined functions.
-       // TODO: With difficulty, this could be moved into the compiler.
-       rslice := []loader.Reloc{}
-       for _, s := range unit.Textp2 {
-               fnSym := loader.Sym(s)
-               infosym, _, _, _ := d.ldr.GetFuncDwarfAuxSyms(fnSym)
-               drelocs := d.ldr.Relocs(infosym)
-               rslice = drelocs.ReadSyms(rslice)
-               for ri := 0; ri < len(rslice); ri++ {
-                       r := &rslice[ri]
-                       if r.Type != objabi.R_DWARFFILEREF {
-                               continue
-                       }
-                       fname, ok := expandedFiles[r.Sym]
-                       if !ok {
-                               fname = expandFileSym(d.ldr, r.Sym)
-                               expandedFiles[r.Sym] = fname
-                       }
-                       if _, ok := fileNums[fname]; ok {
-                               continue
-                       }
-                       fileNums[fname] = len(fileNums) + 1
-                       d.AddString(lsDwsym, fname)
-                       lsu.AddUint8(0)
-                       lsu.AddUint8(0)
-                       lsu.AddUint8(0)
-               }
-       }
-
        // 4 zeros: the string termination + 3 fields.
        lsu.AddUint8(0)
        // terminate file_names.
@@ -1247,6 +1218,7 @@ func (d *dwctxt2) writelines(unit *sym.CompilationUnit, ls loader.Sym) {
 
        // Output the state machine for each function remaining.
        var lastAddr int64
+       rslice := []loader.Reloc{}
        for _, s := range unit.Textp2 {
                fnSym := loader.Sym(s)
 
@@ -1318,7 +1290,8 @@ func (d *dwctxt2) writelines(unit *sym.CompilationUnit, ls loader.Sym) {
 
                        fname, ok := expandedFiles[r.Sym]
                        if !ok {
-                               panic("bad")
+                               fname = expandFileSym(d.ldr, r.Sym)
+                               expandedFiles[r.Sym] = fname
                        }
 
                        idx, ok := fileNums[fname]
@@ -1339,7 +1312,6 @@ func (d *dwctxt2) writelines(unit *sym.CompilationUnit, ls loader.Sym) {
 
                                d.ldr.SetAttrReachable(r.Sym, true)
                                d.ldr.SetAttrNotInSymbolTable(r.Sym, true)
-
                                r.Add = int64(idx) // record the index in r.Add, we'll apply it in the reloc phase.
                        } else {
                                sv := d.ldr.SymValue(r.Sym)