]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: always mark runtime.buildVersion and runtime.modinfo reachable
authorCherry Zhang <cherryyz@google.com>
Mon, 12 Oct 2020 19:37:21 +0000 (15:37 -0400)
committerCherry Zhang <cherryyz@google.com>
Mon, 12 Oct 2020 20:51:51 +0000 (20:51 +0000)
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 <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

src/cmd/link/internal/ld/deadcode.go

index 74d61fa49512ac3ac46e3445ad3aa3ece9916e60..d8813fa9361c67a3ec8668f1509a56ffe3c76480 100644 (file)
@@ -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")