]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: separate out DWARF processing from dodata's allocateSections
authorThan McIntosh <thanm@google.com>
Mon, 20 Apr 2020 11:47:43 +0000 (07:47 -0400)
committerThan McIntosh <thanm@google.com>
Tue, 21 Apr 2020 16:30:47 +0000 (16:30 +0000)
Split out DWARF symbol-to-section assignment into its own separate
helper routine, to improve readability. No change in functionality.

Change-Id: Ic2e4f4d99afbff65161cbb8bd63e866ea555f322
Reviewed-on: https://go-review.googlesource.com/c/go/+/228957
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
src/cmd/link/internal/ld/data.go

index 49f5505f57d1075c07c92af1a1f43853ce1db04e..18cc54c2cc9efd13b27e21441bcc2d7ccbb4d8d0 100644 (file)
@@ -1480,7 +1480,13 @@ func (ctxt *Link) dodata() {
                ctxt.Syms.ROLookup("runtime.bss", 0).Align = state.dataMaxAlign[sym.SBSS]
        }
 
-       state.allocateSections(ctxt)
+       // Create *sym.Section objects and assign symbols to sections for
+       // data/rodata (and related) symbols.
+       state.allocateDataSections(ctxt)
+
+       // Create *sym.Section objects and assign symbols to sections for
+       // DWARF symbols.
+       state.allocateDwarfSections(ctxt)
 
        /* number the sections */
        n := int16(1)
@@ -1599,9 +1605,9 @@ func (state *dodataState) allocateNamedSectionAndAssignSyms(seg *sym.Segment, se
        return sect
 }
 
-// allocateSections allocates sym.Section objects for data sections
-// of interest and assigns symbols into the sections.
-func (state *dodataState) allocateSections(ctxt *Link) {
+// allocateDataSections allocates sym.Section objects for data/rodata
+// (and related) symbols, and then assigns symbols to those sections.
+func (state *dodataState) allocateDataSections(ctxt *Link) {
        // Allocate sections.
        // Data is processed before segtext, because we need
        // to see all symbols in the .data and .bss sections in order
@@ -1899,6 +1905,11 @@ func (state *dodataState) allocateSections(ctxt *Link) {
        for symn := sym.SELFRXSECT; symn < sym.SXREF; symn++ {
                ctxt.datap = append(ctxt.datap, state.data[symn]...)
        }
+}
+
+// allocateDwarfSections allocates sym.Section objects for DWARF
+// symbols, and assigns symbols to sections.
+func (state *dodataState) allocateDwarfSections(ctxt *Link) {
 
        alignOne := func(datsize int64, s *sym.Symbol) int64 { return datsize }