]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/link/internal/loadpe: allocate comdat definitions map lazily
authorThan McIntosh <thanm@google.com>
Mon, 6 Nov 2023 19:18:43 +0000 (14:18 -0500)
committerThan McIntosh <thanm@google.com>
Mon, 6 Nov 2023 20:59:48 +0000 (20:59 +0000)
Switch the "comdatDefinitions" map to lazy allocation; we only need it
for loading PE objects, no point doing an allocation during package
init if we don't need it.

Change-Id: Ie33f2c56e964f35ac2e137840ac021cfaaa897c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/540255
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
src/cmd/link/internal/loadpe/ldpe.go

index 81c28415a2c21d2d70dbdb9821234a1dd70f82fb..2e9880bd6fc3299c5242a40ba6eb92cdef2ec7d1 100644 (file)
@@ -219,7 +219,7 @@ type peLoaderState struct {
 // comdatDefinitions records the names of symbols for which we've
 // previously seen a definition in COMDAT. Key is symbol name, value
 // is symbol size (or -1 if we're using the "any" strategy).
-var comdatDefinitions = make(map[string]int64)
+var comdatDefinitions map[string]int64
 
 // Load loads the PE file pn from input.
 // Symbols from the object file are created via the loader 'l',
@@ -236,6 +236,9 @@ func Load(l *loader.Loader, arch *sys.Arch, localSymVersion int, input *bio.Read
                pn:              pn,
        }
        createImportSymsState(state.l, state.arch)
+       if comdatDefinitions == nil {
+               comdatDefinitions = make(map[string]int64)
+       }
 
        // Some input files are archives containing multiple of
        // object files, and pe.NewFile seeks to the start of