From: Than McIntosh Date: Mon, 6 Nov 2023 19:18:43 +0000 (-0500) Subject: cmd/link/internal/loadpe: allocate comdat definitions map lazily X-Git-Tag: go1.22rc1~419 X-Git-Url: http://www.git.cypherpunks.ru/?a=commitdiff_plain;h=17211b64b6a601ff14cb714362c054434aa86f5a;p=gostls13.git cmd/link/internal/loadpe: allocate comdat definitions map lazily 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 LUCI-TryBot-Result: Go LUCI Reviewed-by: Quim Muntal --- diff --git a/src/cmd/link/internal/loadpe/ldpe.go b/src/cmd/link/internal/loadpe/ldpe.go index 81c28415a2..2e9880bd6f 100644 --- a/src/cmd/link/internal/loadpe/ldpe.go +++ b/src/cmd/link/internal/loadpe/ldpe.go @@ -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