From: Cherry Mui Date: Thu, 10 Jul 2025 04:46:00 +0000 (-0400) Subject: cmd/link: do size fixups after symbol references are loaded X-Git-Tag: go1.25rc3~5^2~35 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=88cf0c5d55;p=gostls13.git 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 Reviewed-by: David Chase --- diff --git a/src/cmd/link/internal/loader/loader.go b/src/cmd/link/internal/loader/loader.go index b1891bac43..a02a268880 100644 --- a/src/cmd/link/internal/loader/loader.go +++ b/src/cmd/link/internal/loader/loader.go @@ -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) }