]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: mark special symbols reachable
authorCherry Zhang <cherryyz@google.com>
Tue, 30 Jun 2020 22:41:24 +0000 (18:41 -0400)
committerCherry Zhang <cherryyz@google.com>
Wed, 1 Jul 2020 14:41:27 +0000 (14:41 +0000)
The special symbols are linker-created symbols for special
purposes, therefore reachable (otherwise the linker won't create
them). Mark them so, so they get converted to sym.Symbols when we
convert to old symbol representation.

In particular, the failure for building shared library on PPC64
is due to .TOC. symbol not being converted to sym.Symbol, but
referenced in addmoduledata.

Change-Id: Iaf5d145ffa5d15122e86a6e6983514e56dd5d456
Reviewed-on: https://go-review.googlesource.com/c/go/+/240620
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
src/cmd/link/internal/ld/lib.go

index 61ccc28a1d52904daec381805a01c25cc5949068..7b6fd9594df5651cba5f2a34963fe4660c543ea4 100644 (file)
@@ -157,6 +157,7 @@ const AfterLoadlibFull = 2
 func (ctxt *Link) mkArchSym(which int, name string, ver int, ls *loader.Sym, ss **sym.Symbol) {
        if which == BeforeLoadlibFull {
                *ls = ctxt.loader.LookupOrCreateSym(name, ver)
+               ctxt.loader.SetAttrReachable(*ls, true)
        } else {
                *ss = ctxt.loader.Syms[*ls]
        }
@@ -167,6 +168,7 @@ func (ctxt *Link) mkArchSym(which int, name string, ver int, ls *loader.Sym, ss
 func (ctxt *Link) mkArchSymVec(which int, name string, ver int, ls []loader.Sym, ss []*sym.Symbol) {
        if which == BeforeLoadlibFull {
                ls[ver] = ctxt.loader.LookupOrCreateSym(name, ver)
+               ctxt.loader.SetAttrReachable(ls[ver], true)
        } else if ls[ver] != 0 {
                ss[ver] = ctxt.loader.Syms[ls[ver]]
        }