Skip to content

Commit 88cf0c5

Browse files
committed
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>
1 parent 7a38975 commit 88cf0c5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎src/cmd/link/internal/loader/loader.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,17 +2298,17 @@ func (l *Loader) LoadSyms(arch *sys.Arch) {
22982298
st.preloadSyms(r, hashedDef)
22992299
st.preloadSyms(r, nonPkgDef)
23002300
}
2301-
for _, sf := range l.sizeFixups {
2302-
pp := l.cloneToExternal(sf.sym)
2303-
pp.size = int64(sf.size)
2304-
}
23052301
for _, vr := range st.linknameVarRefs {
23062302
l.checkLinkname(vr.pkg, vr.name, vr.sym)
23072303
}
23082304
l.nhashedsyms = len(st.hashed64Syms) + len(st.hashedSyms)
23092305
for _, r := range l.objs[goObjStart:] {
23102306
loadObjRefs(l, r, arch)
23112307
}
2308+
for _, sf := range l.sizeFixups {
2309+
pp := l.cloneToExternal(sf.sym)
2310+
pp.size = int64(sf.size)
2311+
}
23122312
l.values = make([]int64, l.NSym(), l.NSym()+1000) // +1000 make some room for external symbols
23132313
l.outer = make([]Sym, l.NSym(), l.NSym()+1000)
23142314
}

0 commit comments

Comments
 (0)