]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: demote DWARF line symbols to anonymous aux
authorThan McIntosh <thanm@google.com>
Wed, 11 Mar 2020 15:16:19 +0000 (11:16 -0400)
committerThan McIntosh <thanm@google.com>
Thu, 12 Mar 2020 18:56:25 +0000 (18:56 +0000)
Convert DWARF .debug_line symbols to anonymous aux syms, so as
to save space in object files and reduce the number of symbols
that have to be added to the linker's lookup tables.

Change-Id: I5b350f036e21a7a7128cb08148ab7c243aaf0d0b
Reviewed-on: https://go-review.googlesource.com/c/go/+/223018
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/internal/dwarf/dwarf.go
src/cmd/internal/obj/objfile.go
src/cmd/internal/obj/objfile2.go
src/cmd/internal/obj/plist.go
src/cmd/internal/obj/sym.go

index 3ba0623c8cd2e29995cfd3d8ab470732f1385e8e..62036aee2add6cb89d59453d24517e641b63cea4 100644 (file)
@@ -21,9 +21,6 @@ import (
 // InfoPrefix is the prefix for all the symbols containing DWARF info entries.
 const InfoPrefix = "go.info."
 
-// DebugLinesPrefix is the prefix for all the symbols containing DWARF debug_line information from the compiler.
-const DebugLinesPrefix = "go.debuglines."
-
 // ConstInfoPrefix is the prefix for all symbols containing DWARF info
 // entries that contain constants.
 const ConstInfoPrefix = "go.constinfo."
index 0f73e48b05ce21183812dec10863174fa991b0dd..717d471569c0e1bed8b29001161e29573bc16e56 100644 (file)
@@ -219,7 +219,9 @@ func (ctxt *Link) dwarfSym(s *LSym) (dwarfInfoSym, dwarfLocSym, dwarfRangesSym,
                if s.WasInlined() {
                        s.Func.dwarfAbsFnSym = ctxt.DwFixups.AbsFuncDwarfSym(s)
                }
-               s.Func.dwarfDebugLinesSym = ctxt.LookupDerived(s, dwarf.DebugLinesPrefix+s.Name)
+               s.Func.dwarfDebugLinesSym = &LSym{
+                       Type: objabi.SDWARFLINES,
+               }
        }
        return s.Func.dwarfInfoSym, s.Func.dwarfLocSym, s.Func.dwarfRangesSym, s.Func.dwarfAbsFnSym, s.Func.dwarfDebugLinesSym
 }
index 9ccbcd5352af02e139a43d2b9860fee2bf799966..359e82e1382ce2f1e381031dcfe0663034b9e509 100644 (file)
@@ -320,7 +320,7 @@ func (w *writer) Aux(s *LSym) {
                        }
                        o.Write(w.Writer)
                }
-               if s.Func.dwarfDebugLinesSym != nil {
+               if s.Func.dwarfDebugLinesSym != nil && s.Func.dwarfDebugLinesSym.Size != 0 {
                        o := goobj2.Aux{
                                Type: goobj2.AuxDwarfLines,
                                Sym:  makeSymRef(s.Func.dwarfDebugLinesSym),
@@ -348,7 +348,7 @@ func nAuxSym(s *LSym) int {
                if s.Func.dwarfRangesSym != nil && s.Func.dwarfRangesSym.Size != 0 {
                        n++
                }
-               if s.Func.dwarfDebugLinesSym != nil {
+               if s.Func.dwarfDebugLinesSym != nil && s.Func.dwarfDebugLinesSym.Size != 0 {
                        n++
                }
        }
@@ -419,7 +419,7 @@ func genFuncInfoSyms(ctxt *Link) {
                s.Func.FuncInfoSym = isym
                b.Reset()
 
-               dwsyms := []*LSym{s.Func.dwarfRangesSym, s.Func.dwarfLocSym}
+               dwsyms := []*LSym{s.Func.dwarfRangesSym, s.Func.dwarfLocSym, s.Func.dwarfDebugLinesSym}
                for _, s := range dwsyms {
                        if s == nil || s.Size == 0 {
                                continue
index fdb549025515a1d9cb709abfe561f60948a9e3a6..917343ea576d97a4937585799f89851f2a831269 100644 (file)
@@ -139,13 +139,10 @@ func (ctxt *Link) InitTextSym(s *LSym, flag int) {
        ctxt.Text = append(ctxt.Text, s)
 
        // Set up DWARF entries for s.
-       info, _, _, _, lines := ctxt.dwarfSym(s)
+       info, _, _, _, _ := ctxt.dwarfSym(s)
        info.Type = objabi.SDWARFINFO
        info.Set(AttrDuplicateOK, s.DuplicateOK())
        ctxt.Data = append(ctxt.Data, info)
-       lines.Type = objabi.SDWARFLINES
-       lines.Set(AttrDuplicateOK, s.DuplicateOK())
-       ctxt.Data = append(ctxt.Data, lines)
 }
 
 func (ctxt *Link) Globl(s *LSym, size int64, flag int) {
index 818d464c91eade60557c57340e5d5392a2020d0b..9cd1786f67c1cd0c049767ce27cc7cd1b1a4b37f 100644 (file)
@@ -325,7 +325,7 @@ func (ctxt *Link) traverseFuncAux(fsym *LSym, fn func(parent *LSym, aux *LSym))
                        fn(fsym, filesym)
                }
        }
-       dwsyms := []*LSym{fsym.Func.dwarfRangesSym, fsym.Func.dwarfLocSym}
+       dwsyms := []*LSym{fsym.Func.dwarfRangesSym, fsym.Func.dwarfLocSym, fsym.Func.dwarfDebugLinesSym}
        for _, dws := range dwsyms {
                if dws == nil || dws.Size == 0 {
                        continue