}
// already loaded?
- for i := 0; i < len(ctxt.Library); i++ {
- if ctxt.Library[i].Pkg == pkg {
- return ctxt.Library[i]
- }
+ if l := ctxt.LibraryByPkg[pkg]; l != nil {
+ return l
}
var pname string
* pkg: package import path, e.g. container/vector
*/
func addlibpath(ctxt *Link, srcref string, objref string, file string, pkg string, shlibnamefile string) *Library {
- for i := 0; i < len(ctxt.Library); i++ {
- if pkg == ctxt.Library[i].Pkg {
- return ctxt.Library[i]
- }
+ if l := ctxt.LibraryByPkg[pkg]; l != nil {
+ return l
}
if ctxt.Debugvlog > 1 {
ctxt.Logf("%5.2f addlibpath: srcref: %s objref: %s file: %s pkg: %s shlibnamefile: %s\n", Cputime(), srcref, objref, file, pkg, shlibnamefile)
}
- ctxt.Library = append(ctxt.Library, &Library{})
- l := ctxt.Library[len(ctxt.Library)-1]
+ l := &Library{}
+ ctxt.LibraryByPkg[pkg] = l
+ ctxt.Library = append(ctxt.Library, l)
l.Objref = objref
l.Srcref = srcref
l.File = file
Loaded bool // set after all inputs have been loaded as symbols
- Tlsg *Symbol
- Libdir []string
- Library []*Library
- Shlibs []Shlib
- Tlsoffset int
- Textp []*Symbol
- Filesyms []*Symbol
- Moduledata *Symbol
+ Tlsg *Symbol
+ Libdir []string
+ Library []*Library
+ LibraryByPkg map[string]*Library
+ Shlibs []Shlib
+ Tlsoffset int
+ Textp []*Symbol
+ Filesyms []*Symbol
+ Moduledata *Symbol
tramps []*Symbol // trampolines
}
},
Allsym: make([]*Symbol, 0, 100000),
},
- Arch: arch,
+ Arch: arch,
+ LibraryByPkg: make(map[string]*Library),
}
if objabi.GOARCH != arch.Name {