// Collect data symbols by type into data.
state := dodataState{ctxt: ctxt}
- for _, s := range ctxt.Syms.Allsym {
+ for _, s := range ctxt.loader.Syms {
+ if s == nil {
+ continue
+ }
if !s.Attr.Reachable() || s.Attr.Special() || s.Attr.SubSymbol() {
continue
}
chain := make([]uint32, nsym)
buckets := make([]uint32, nbucket)
- for _, sy := range ctxt.Syms.Allsym {
+ for _, sy := range ctxt.loader.Syms {
+ if sy == nil {
+ continue
+ }
if sy.Dynid <= 0 {
continue
}
return true
}
- for _, s := range ctxt.Syms.Allsym {
+ for _, s := range ctxt.loader.Syms {
+ if s == nil {
+ continue
+ }
if !shouldBeInSymbolTable(s) {
continue
}
}
func (ctxt *Link) dumpsyms() {
- for _, s := range ctxt.Syms.Allsym {
+ for _, s := range ctxt.loader.Syms {
+ if s == nil {
+ continue
+ }
fmt.Printf("%s %s reachable=%v onlist=%v outer=%v sub=%v\n", s, s.Type, s.Attr.Reachable(), s.Attr.OnList(), s.Outer, s.Sub)
for i := range s.R {
fmt.Println("\t", s.R[i].Type, s.R[i].Sym)
bench.Start("hostlink")
ctxt.hostlink()
if ctxt.Debugvlog != 0 {
- ctxt.Logf("%d symbols\n", len(ctxt.Syms.Allsym))
+ ctxt.Logf("%d symbols, %d reachable\n", len(ctxt.loader.Syms), ctxt.loader.NReachableSym())
ctxt.Logf("%d liveness data\n", liveness)
}
bench.Start("Flush")
fname = filepath.Join(*flagTmpdir, "export_file.exp")
var buf bytes.Buffer
- for _, s := range ctxt.Syms.Allsym {
+ for _, s := range ctxt.loader.Syms {
+ if s == nil {
+ continue
+ }
if !s.Attr.CgoExport() {
continue
}
func (bm Bitmap) Len() int {
return len(bm) * 32
}
+
+// return the number of bits set.
+func (bm Bitmap) Count() int {
+ s := 0
+ for _, x := range bm {
+ s += bits.OnesCount32(x)
+ }
+ return s
+}
+
func MakeBitmap(n int) Bitmap {
return make(Bitmap, (n+31)/32)
}
return int(l.extStart)
}
+// Number of reachable symbols.
+func (l *Loader) NReachableSym() int {
+ return l.attrReachable.Count()
+}
+
// Returns the raw (unpatched) name of the i-th symbol.
func (l *Loader) RawSymName(i Sym) string {
if l.IsExternal(i) {
if s == nil {
continue
}
- syms.Allsym = append(syms.Allsym, s) // XXX still add to Allsym for now, as there are code looping through Allsym
if s.Version < 0 {
s.Version = int16(anonVerReplacement)
}
}
s := l.allocSym(name, ver)
l.installSym(i, s)
- syms.Allsym = append(syms.Allsym, s) // XXX see above
return s
}
syms.Lookup = l.SymLookup
i := l.newExtSym(name, ver)
s := l.allocSym(name, ver)
l.installSym(i, s)
- syms.Allsym = append(syms.Allsym, s) // XXX see above
return s
}
}
// Symbol lookup based on name and indexed by version.
versions int
- Allsym []*Symbol
-
// Provided by the loader
// Look up the symbol with the given name and version, creating the
func NewSymbols() *Symbols {
return &Symbols{
versions: SymVerStatic,
- Allsym: make([]*Symbol, 0, 100000),
}
}