Skip to content

Commit 17211b6

Browse files
committed
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 <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
1 parent 36f3ec5 commit 17211b6

File tree

1 file changed

+4
-1
lines changed
  • src/cmd/link/internal/loadpe

1 file changed

+4
-1
lines changed

src/cmd/link/internal/loadpe/ldpe.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ type peLoaderState struct {
219219
// comdatDefinitions records the names of symbols for which we've
220220
// previously seen a definition in COMDAT. Key is symbol name, value
221221
// is symbol size (or -1 if we're using the "any" strategy).
222-
var comdatDefinitions = make(map[string]int64)
222+
var comdatDefinitions map[string]int64
223223

224224
// Load loads the PE file pn from input.
225225
// 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
236236
pn: pn,
237237
}
238238
createImportSymsState(state.l, state.arch)
239+
if comdatDefinitions == nil {
240+
comdatDefinitions = make(map[string]int64)
241+
}
239242

240243
// Some input files are archives containing multiple of
241244
// object files, and pe.NewFile seeks to the start of

0 commit comments

Comments
 (0)