mirror of
https://github.com/golang/go
synced 2024-11-18 15:54:42 -07:00
[dev.link] cmd/link: remove ctxt.Syms.Allsym
Replace remaining uses with loader.Syms. Reduces some memory usage. Change-Id: I6f295b42b8cd734c6c18f08c61a5473506675075 Reviewed-on: https://go-review.googlesource.com/c/go/+/229992 Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
2a874562bf
commit
a742d0ed5f
@ -28,7 +28,10 @@ func (ctxt *Link) dodata() {
|
||||
|
||||
// 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
|
||||
}
|
||||
|
@ -51,7 +51,10 @@ func elfdynhash(ctxt *Link) {
|
||||
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
|
||||
}
|
||||
|
@ -2555,7 +2555,10 @@ func genasmsym(ctxt *Link, put func(*Link, *sym.Symbol, string, SymbolType, int6
|
||||
return true
|
||||
}
|
||||
|
||||
for _, s := range ctxt.Syms.Allsym {
|
||||
for _, s := range ctxt.loader.Syms {
|
||||
if s == nil {
|
||||
continue
|
||||
}
|
||||
if !shouldBeInSymbolTable(s) {
|
||||
continue
|
||||
}
|
||||
@ -2909,7 +2912,10 @@ func (ctxt *Link) loadlibfull(symGroupType []sym.SymKind) {
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -364,7 +364,7 @@ func Main(arch *sys.Arch, theArch Arch) {
|
||||
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")
|
||||
|
@ -1646,7 +1646,10 @@ func xcoffCreateExportFile(ctxt *Link) (fname string) {
|
||||
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
|
||||
}
|
||||
|
@ -147,6 +147,16 @@ func (bm Bitmap) Has(i Sym) bool {
|
||||
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)
|
||||
}
|
||||
@ -625,6 +635,11 @@ func (l *Loader) NDef() int {
|
||||
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) {
|
||||
@ -2195,7 +2210,6 @@ func (l *Loader) ExtractSymbols(syms *sym.Symbols) {
|
||||
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)
|
||||
}
|
||||
@ -2209,7 +2223,6 @@ func (l *Loader) ExtractSymbols(syms *sym.Symbols) {
|
||||
}
|
||||
s := l.allocSym(name, ver)
|
||||
l.installSym(i, s)
|
||||
syms.Allsym = append(syms.Allsym, s) // XXX see above
|
||||
return s
|
||||
}
|
||||
syms.Lookup = l.SymLookup
|
||||
@ -2221,7 +2234,6 @@ func (l *Loader) ExtractSymbols(syms *sym.Symbols) {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -34,8 +34,6 @@ type Symbols struct {
|
||||
// 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
|
||||
@ -55,7 +53,6 @@ type Symbols struct {
|
||||
func NewSymbols() *Symbols {
|
||||
return &Symbols{
|
||||
versions: SymVerStatic,
|
||||
Allsym: make([]*Symbol, 0, 100000),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user