mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.link] cmd/link: fix some bugs in loader
This patch fixes a couple of bugs introduced in CL 210778 and CL 207606: - apply the same version selection scheme in loader.CreateExtSym that we're currently using for loader.Create (since the two functions will be used in the same way by the host object loader) - add code to the loader's NewLoader function to create initial map values for some of the map-based symbol attributes (somewhere along the line the code to do this seems to have gotten lost, so this patch adds it back). - fix a coding error in growAttrBitmaps (wrong bitmap passed to append when extending attrOnList) Change-Id: Ie0c8c6876428bb21d788c19a7a2db945ac649fac Reviewed-on: https://go-review.googlesource.com/c/go/+/212097 Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
e4a8da499b
commit
9a5468edff
1 changed files with 26 additions and 14 deletions
|
|
@ -232,18 +232,26 @@ const (
|
|||
func NewLoader(flags uint32) *Loader {
|
||||
nbuiltin := goobj2.NBuiltin()
|
||||
return &Loader{
|
||||
start: make(map[*oReader]Sym),
|
||||
objs: []objIdx{{nil, 0, 0}},
|
||||
symsByName: [2]map[string]Sym{make(map[string]Sym), make(map[string]Sym)},
|
||||
objByPkg: make(map[string]*oReader),
|
||||
outer: make(map[Sym]Sym),
|
||||
sub: make(map[Sym]Sym),
|
||||
align: make(map[Sym]int32),
|
||||
overwrite: make(map[Sym]Sym),
|
||||
itablink: make(map[Sym]struct{}),
|
||||
extStaticSyms: make(map[nameVer]Sym),
|
||||
builtinSyms: make([]Sym, nbuiltin),
|
||||
flags: flags,
|
||||
start: make(map[*oReader]Sym),
|
||||
objs: []objIdx{{nil, 0, 0}},
|
||||
symsByName: [2]map[string]Sym{make(map[string]Sym), make(map[string]Sym)},
|
||||
objByPkg: make(map[string]*oReader),
|
||||
outer: make(map[Sym]Sym),
|
||||
sub: make(map[Sym]Sym),
|
||||
align: make(map[Sym]int32),
|
||||
dynimplib: make(map[Sym]string),
|
||||
dynimpvers: make(map[Sym]string),
|
||||
localentry: make(map[Sym]uint8),
|
||||
extname: make(map[Sym]string),
|
||||
attrTopFrame: make(map[Sym]struct{}),
|
||||
attrSpecial: make(map[Sym]struct{}),
|
||||
attrCgoExportDynamic: make(map[Sym]struct{}),
|
||||
attrCgoExportStatic: make(map[Sym]struct{}),
|
||||
overwrite: make(map[Sym]Sym),
|
||||
itablink: make(map[Sym]struct{}),
|
||||
extStaticSyms: make(map[nameVer]Sym),
|
||||
builtinSyms: make([]Sym, nbuiltin),
|
||||
flags: flags,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1173,7 +1181,7 @@ func (l *Loader) growAttrBitmaps(reqLen int) {
|
|||
if reqLen > l.attrReachable.len() {
|
||||
// These are indexed by global symbol
|
||||
l.attrReachable = growBitmap(reqLen, l.attrReachable)
|
||||
l.attrOnList = growBitmap(reqLen, l.attrReachable)
|
||||
l.attrOnList = growBitmap(reqLen, l.attrOnList)
|
||||
}
|
||||
// These are indexed by external symbol offset (e.g. i - l.extStart)
|
||||
if l.extStart == 0 {
|
||||
|
|
@ -1665,7 +1673,11 @@ func (l *Loader) LookupOrCreate(name string, version int) *sym.Symbol {
|
|||
// CreateExtSym creates a new external symbol with the specified name
|
||||
// without adding it to any lookup tables, returning a Sym index for it.
|
||||
func (l *Loader) CreateExtSym(name string) Sym {
|
||||
return l.newExtSym(name, sym.SymVerABI0)
|
||||
// Assign a new unique negative version -- this is to mark the
|
||||
// symbol so that it can be skipped when ExtractSymbols is adding
|
||||
// ext syms to the sym.Symbols hash.
|
||||
l.anonVersion--
|
||||
return l.newExtSym(name, l.anonVersion)
|
||||
}
|
||||
|
||||
// Create creates a symbol with the specified name, returning a
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue