From: Cherry Zhang Date: Mon, 12 Oct 2020 19:37:21 +0000 (-0400) Subject: cmd/link: always mark runtime.buildVersion and runtime.modinfo reachable X-Git-Tag: go1.16beta1~772 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3a34395363ffe1e95748fbabff2917c908f2670c;p=gostls13.git 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 --- 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")