aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2025-07-10 00:46:00 -0400
committerCherry Mui <cherryyz@google.com>2025-07-11 07:32:16 -0700
commit88cf0c5d55a8c18da515485f4a3fcf008b96cb07 (patch)
tree5a3b3712ea31a205009c0e85c8d4e34df5a40742 /src
parent7a38975a48ac735e62b389957bfc898437d628dc (diff)
downloadgo-88cf0c5d55a8c18da515485f4a3fcf008b96cb07.tar.xz
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>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/link/internal/loader/loader.go8
1 files changed, 4 insertions, 4 deletions
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)
}