mirror of
https://github.com/golang/go
synced 2024-11-17 18:44:44 -07:00
cmd/link: don't mark a symbol's GoType reachable when -linkshared
In CL 231397, we stopped marking symbols' GoType reachable in general, but not when -linkshared. It was left as a TODO. This CL addresses it. The problem was that the type names are mangled in the shared library, so we need to mangle the name consistently in the executable as well (regardless of whether the symbol is reachable or not), so that the GCProg generation code can find the corresponding symbol from the shared library. Change-Id: I1040747402929a983ec581109f1681a77893682e Reviewed-on: https://go-review.googlesource.com/c/go/+/255964 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
d91d0762c7
commit
7e54aa2c25
@ -174,13 +174,9 @@ func (d *deadcodePass) flood() {
|
||||
naux := d.ldr.NAux(symIdx)
|
||||
for i := 0; i < naux; i++ {
|
||||
a := d.ldr.Aux(symIdx, i)
|
||||
if a.Type() == goobj.AuxGotype && !d.ctxt.linkShared {
|
||||
if a.Type() == goobj.AuxGotype {
|
||||
// A symbol being reachable doesn't imply we need its
|
||||
// type descriptor. Don't mark it.
|
||||
// TODO: when -linkshared, the GCProg generation code
|
||||
// seems to need it. I'm not sure why. I think it could
|
||||
// just reach to the type descriptor's data without
|
||||
// requiring to mark it reachable.
|
||||
continue
|
||||
}
|
||||
d.mark(a.Sym(), symIdx)
|
||||
|
@ -831,7 +831,12 @@ func (ctxt *Link) mangleTypeSym() {
|
||||
|
||||
ldr := ctxt.loader
|
||||
for s := loader.Sym(1); s < loader.Sym(ldr.NSym()); s++ {
|
||||
if !ldr.AttrReachable(s) {
|
||||
if !ldr.AttrReachable(s) && !ctxt.linkShared {
|
||||
// If -linkshared, the GCProg generation code may need to reach
|
||||
// out to the shared library for the type descriptor's data, even
|
||||
// the type descriptor itself is not actually needed at run time
|
||||
// (therefore not reachable). We still need to mangle its name,
|
||||
// so it is consistent with the one stored in the shared library.
|
||||
continue
|
||||
}
|
||||
name := ldr.SymName(s)
|
||||
|
Loading…
Reference in New Issue
Block a user