From 3a34395363ffe1e95748fbabff2917c908f2670c Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Mon, 12 Oct 2020 15:37:21 -0400 Subject: [PATCH] cmd/link: always mark runtime.buildVersion and runtime.modinfo reachable runtime.buildVersion and runtime.modinfo are referenced in the .go.buildinfo section, therefore reachable. They should normally be reachable from the runtime. Just make it explicit, in case. Change-Id: I60ff3132e0bbb690f4a3cba8bb18735921fbe951 Reviewed-on: https://go-review.googlesource.com/c/go/+/261637 Trust: Cherry Zhang Run-TryBot: Cherry Zhang Reviewed-by: Than McIntosh Reviewed-by: Jeremy Faller TryBot-Result: Go Bot --- src/cmd/link/internal/ld/deadcode.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cmd/link/internal/ld/deadcode.go b/src/cmd/link/internal/ld/deadcode.go index 74d61fa495..d8813fa936 100644 --- a/src/cmd/link/internal/ld/deadcode.go +++ b/src/cmd/link/internal/ld/deadcode.go @@ -62,6 +62,12 @@ func (d *deadcodePass) init() { } } names = append(names, *flagEntrySymbol) + if !d.ctxt.linkShared && d.ctxt.BuildMode != BuildModePlugin { + // runtime.buildVersion and runtime.modinfo are referenced in .go.buildinfo section + // (see function buildinfo in data.go). They should normally be reachable from the + // runtime. Just make it explicit, in case. + names = append(names, "runtime.buildVersion", "runtime.modinfo") + } if d.ctxt.BuildMode == BuildModePlugin { names = append(names, objabi.PathToPrefix(*flagPluginPath)+"..inittask", objabi.PathToPrefix(*flagPluginPath)+".main", "go.plugin.tabs") -- 2.50.0