cmd/link: do size fixups after symbol references are loaded
When we do a size fixup, we need to clone the symbol to an external symbol so we can modify it. This includes cloning the relocations, which includes resolving the relocations. If the symbol being fixed has a relocation referencing a non-Go symbol, that symbol has not yet been created, it will be resolved to an empty symbol. Load the references first, so the referenced symbol, even if it is a non-Go symbol, exists. Fixes #74537. Change-Id: I81525bd7c3e232b80eefeb0f18e13ba5331e1510 Reviewed-on: https://go-review.googlesource.com/c/go/+/687315 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
@@ -2298,10 +2298,6 @@ func (l *Loader) LoadSyms(arch *sys.Arch) {
|
||||
st.preloadSyms(r, hashedDef)
|
||||
st.preloadSyms(r, nonPkgDef)
|
||||
}
|
||||
for _, sf := range l.sizeFixups {
|
||||
pp := l.cloneToExternal(sf.sym)
|
||||
pp.size = int64(sf.size)
|
||||
}
|
||||
for _, vr := range st.linknameVarRefs {
|
||||
l.checkLinkname(vr.pkg, vr.name, vr.sym)
|
||||
}
|
||||
@@ -2309,6 +2305,10 @@ func (l *Loader) LoadSyms(arch *sys.Arch) {
|
||||
for _, r := range l.objs[goObjStart:] {
|
||||
loadObjRefs(l, r, arch)
|
||||
}
|
||||
for _, sf := range l.sizeFixups {
|
||||
pp := l.cloneToExternal(sf.sym)
|
||||
pp.size = int64(sf.size)
|
||||
}
|
||||
l.values = make([]int64, l.NSym(), l.NSym()+1000) // +1000 make some room for external symbols
|
||||
l.outer = make([]Sym, l.NSym(), l.NSym()+1000)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user