diff options
Diffstat (limited to 'src/cmd/link/internal')
| -rw-r--r-- | src/cmd/link/internal/ld/deadcode.go | 8 | ||||
| -rw-r--r-- | src/cmd/link/internal/ld/decodesym.go | 6 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/cmd/link/internal/ld/deadcode.go b/src/cmd/link/internal/ld/deadcode.go index c0969b25b0..c687565878 100644 --- a/src/cmd/link/internal/ld/deadcode.go +++ b/src/cmd/link/internal/ld/deadcode.go @@ -180,6 +180,14 @@ func (d *deadcodePass) flood() { // converted to an interface, i.e. should have UsedInIface set. See the // comment below for why we need to unset the Reachable bit and re-mark it. rs := r.Sym() + if d.ldr.IsItab(rs) { + // This relocation can also point at an itab, in which case it + // means "the _type field of that itab". + rs = decodeItabType(d.ldr, d.ctxt.Arch, rs) + } + if !d.ldr.IsGoType(rs) && !d.ctxt.linkShared { + panic(fmt.Sprintf("R_USEIFACE in %s references %s which is not a type or itab", d.ldr.SymName(symIdx), d.ldr.SymName(rs))) + } if !d.ldr.AttrUsedInIface(rs) { d.ldr.SetAttrUsedInIface(rs, true) if d.ldr.AttrReachable(rs) { diff --git a/src/cmd/link/internal/ld/decodesym.go b/src/cmd/link/internal/ld/decodesym.go index c01d6c1163..05da11ec1e 100644 --- a/src/cmd/link/internal/ld/decodesym.go +++ b/src/cmd/link/internal/ld/decodesym.go @@ -300,3 +300,9 @@ func findShlibSection(ctxt *Link, path string, addr uint64) *elf.Section { func decodetypeGcprogShlib(ctxt *Link, data []byte) uint64 { return decodeInuxi(ctxt.Arch, data[2*int32(ctxt.Arch.PtrSize)+8+1*int32(ctxt.Arch.PtrSize):], ctxt.Arch.PtrSize) } + +// decodeItabType returns the itab._type field from an itab. +func decodeItabType(ldr *loader.Loader, arch *sys.Arch, symIdx loader.Sym) loader.Sym { + relocs := ldr.Relocs(symIdx) + return decodeRelocSym(ldr, symIdx, &relocs, int32(arch.PtrSize)) +} |
