diff options
author | Cherry Zhang <cherryyz@google.com> | 2020-10-12 15:37:21 -0400 |
---|---|---|
committer | Cherry Zhang <cherryyz@google.com> | 2020-10-12 20:51:51 +0000 |
commit | 3a34395363ffe1e95748fbabff2917c908f2670c (patch) | |
tree | 5eb0a6241b5e71f8a29f327d688b825cdab14e56 /src/cmd/link/internal/ld/deadcode.go | |
parent | 8994607f828e46272bae5e7959997dea8cb1a19a (diff) | |
download | go-3a34395363ffe1e95748fbabff2917c908f2670c.tar.gz go-3a34395363ffe1e95748fbabff2917c908f2670c.zip |
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 <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>
Diffstat (limited to 'src/cmd/link/internal/ld/deadcode.go')
-rw-r--r-- | src/cmd/link/internal/ld/deadcode.go | 6 |
1 files changed, 6 insertions, 0 deletions
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") |