]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/cmd/link/internal/ld/deadcode2.go
[dev.link] all: merge branch 'master' into dev.link
[gostls13.git] / src / cmd / link / internal / ld / deadcode2.go
index 9197c700f586d41b96812ae83c4996be56b63d93..3d3a03215e50f67bc85e25ef5830986f443fbb82 100644 (file)
@@ -195,9 +195,9 @@ func (d *deadcodePass2) flood() {
 }
 
 func (d *deadcodePass2) mark(symIdx, parent loader.Sym) {
-       if symIdx != 0 && !d.ldr.Reachable.Has(symIdx) {
+       if symIdx != 0 && !d.ldr.AttrReachable(symIdx) {
                d.wq.push(symIdx)
-               d.ldr.Reachable.Set(symIdx)
+               d.ldr.SetAttrReachable(symIdx, true)
                if d.ctxt.Reachparent != nil {
                        d.ldr.Reachparent[symIdx] = parent
                }
@@ -239,7 +239,7 @@ func deadcode2(ctxt *Link) {
                // Methods might be called via reflection. Give up on
                // static analysis, mark all exported methods of
                // all reachable types as reachable.
-               d.reflectSeen = d.reflectSeen || (callSym != 0 && ldr.Reachable.Has(callSym)) || (methSym != 0 && ldr.Reachable.Has(methSym))
+               d.reflectSeen = d.reflectSeen || (callSym != 0 && ldr.AttrReachable(callSym)) || (methSym != 0 && ldr.AttrReachable(methSym))
 
                // Mark all methods that could satisfy a discovered
                // interface as reachable. We recheck old marked interfaces
@@ -271,8 +271,8 @@ func deadcode2(ctxt *Link) {
                        s := loader.Sym(i)
                        if ldr.IsItabLink(s) {
                                relocs := ldr.Relocs(s)
-                               if relocs.Count > 0 && ldr.Reachable.Has(relocs.At(0).Sym) {
-                                       ldr.Reachable.Set(s)
+                               if relocs.Count > 0 && ldr.AttrReachable(relocs.At(0).Sym) {
+                                       ldr.SetAttrReachable(s, true)
                                }
                        }
                }
@@ -318,7 +318,7 @@ func (d *deadcodePass2) decodeMethodSig2(ldr *loader.Loader, arch *sys.Arch, sym
                        if i > 0 {
                                buf.WriteString(", ")
                        }
-                       a := d.decodetypeFuncInType2(ldr, arch, mtypSym, d.rtmp, i)
+                       a := decodetypeFuncInType2(ldr, arch, mtypSym, d.rtmp, i)
                        buf.WriteString(ldr.SymName(a))
                }
                buf.WriteString(") (")
@@ -327,7 +327,7 @@ func (d *deadcodePass2) decodeMethodSig2(ldr *loader.Loader, arch *sys.Arch, sym
                        if i > 0 {
                                buf.WriteString(", ")
                        }
-                       a := d.decodetypeFuncOutType2(ldr, arch, mtypSym, d.rtmp, i)
+                       a := decodetypeFuncOutType2(ldr, arch, mtypSym, d.rtmp, i)
                        buf.WriteString(ldr.SymName(a))
                }
                buf.WriteRune(')')
@@ -391,47 +391,6 @@ func (d *deadcodePass2) decodetypeMethods2(ldr *loader.Loader, arch *sys.Arch, s
        return d.decodeMethodSig2(ldr, arch, symIdx, symRelocs, off, sizeofMethod, mcount)
 }
 
-func decodeReloc2(ldr *loader.Loader, symIdx loader.Sym, symRelocs []loader.Reloc, off int32) loader.Reloc {
-       for j := 0; j < len(symRelocs); j++ {
-               rel := symRelocs[j]
-               if rel.Off == off {
-                       return rel
-               }
-       }
-       return loader.Reloc{}
-}
-
-func decodeRelocSym2(ldr *loader.Loader, symIdx loader.Sym, symRelocs []loader.Reloc, off int32) loader.Sym {
-       return decodeReloc2(ldr, symIdx, symRelocs, off).Sym
-}
-
-// decodetypeName2 decodes the name from a reflect.name.
-func decodetypeName2(ldr *loader.Loader, symIdx loader.Sym, symRelocs []loader.Reloc, off int) string {
-       r := decodeRelocSym2(ldr, symIdx, symRelocs, int32(off))
-       if r == 0 {
-               return ""
-       }
-
-       data := ldr.Data(r)
-       namelen := int(uint16(data[1])<<8 | uint16(data[2]))
-       return string(data[3 : 3+namelen])
-}
-
-func (d *deadcodePass2) decodetypeFuncInType2(ldr *loader.Loader, arch *sys.Arch, symIdx loader.Sym, symRelocs []loader.Reloc, i int) loader.Sym {
-       uadd := commonsize(arch) + 4
-       if arch.PtrSize == 8 {
-               uadd += 4
-       }
-       if decodetypeHasUncommon(arch, ldr.Data(symIdx)) {
-               uadd += uncommonSize()
-       }
-       return decodeRelocSym2(ldr, symIdx, symRelocs, int32(uadd+i*arch.PtrSize))
-}
-
-func (d *deadcodePass2) decodetypeFuncOutType2(ldr *loader.Loader, arch *sys.Arch, symIdx loader.Sym, symRelocs []loader.Reloc, i int) loader.Sym {
-       return d.decodetypeFuncInType2(ldr, arch, symIdx, symRelocs, i+decodetypeFuncInCount(arch, ldr.Data(symIdx)))
-}
-
 // readRelocs reads the relocations for the specified symbol into the
 // deadcode relocs work array. Use with care, since the work array
 // is a singleton.