From 7a22f11e962a88813f945e227d3d67d94f3dc094 Mon Sep 17 00:00:00 2001 From: Than McIntosh Date: Mon, 20 Apr 2020 07:47:43 -0400 Subject: [PATCH] [dev.link] cmd/link: separate out DWARF processing from dodata's allocateSections 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 Reviewed-by: Jeremy Faller --- src/cmd/link/internal/ld/data.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go index 49f5505f57..18cc54c2cc 100644 --- a/src/cmd/link/internal/ld/data.go +++ b/src/cmd/link/internal/ld/data.go @@ -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 } -- 2.48.1