aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2026-03-29 21:05:35 -0700
committerGopher Robot <gobot@golang.org>2026-03-31 11:01:05 -0700
commit9387929d09490ae30a8da75c64d9c64e2c16936d (patch)
tree78b0a19354e994c31116454a0e2b770a02127744
parentf665ff8bc1ab2576d173cb69c3b2e87916dc74fd (diff)
downloadgo-9387929d09490ae30a8da75c64d9c64e2c16936d.tar.xz
cmd/link, runtime: record size of itabs
We were depending on runtime.etypes immediately following the itabs. However, on AIX, runtime.etypes, as a zero-sized symbol, can float when using external linking. It won't necessarily stay right at the end of the itabs. Rather than worry about this, just record the size of the itab data. In practice it almost always works on AIX, but it fails the runtime test TestSchedPauseMetrics/runtime/debug.WriteHeapDump, which fails when iterating over all the itabs. Tested on AIX. This should fix AIX on the build dashboard. Change-Id: Id3a113b75b93fa8440c047e92f764ab81423df48 Reviewed-on: https://go-review.googlesource.com/c/go/+/760203 Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Junyang Shao <shaojunyang@google.com>
-rw-r--r--src/cmd/link/internal/ld/data.go13
-rw-r--r--src/cmd/link/internal/ld/link.go1
-rw-r--r--src/cmd/link/internal/ld/symtab.go2
-rw-r--r--src/runtime/iface.go3
-rw-r--r--src/runtime/symtab.go2
5 files changed, 19 insertions, 2 deletions
diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go
index bf2bac18af..773efb421f 100644
--- a/src/cmd/link/internal/ld/data.go
+++ b/src/cmd/link/internal/ld/data.go
@@ -2549,6 +2549,19 @@ func (state *dodataState) dodataSect(ctxt *Link, symn sym.SymKind, syms []loader
su.SetUint(ctxt.Arch, ctxt.moduledataItabOffset, uint64(typeSize))
}
+ itabSize := int64(0)
+ for ; i < len(sl); i++ {
+ itabSize = Rnd(itabSize, int64(symalign(ldr, sl[i].sym)))
+ itabSize += sl[i].sz
+ }
+
+ if ctxt.moduledataItabSizeOffset == 0 {
+ Errorf("internal error: phase error: moduledataItabSizeOffset not set in dodataSect")
+ } else {
+ su := ldr.MakeSymbolUpdater(ctxt.Moduledata)
+ su.SetUint(ctxt.Arch, ctxt.moduledataItabSizeOffset, uint64(itabSize))
+ }
+
default:
sort.Slice(sl, sortFn)
}
diff --git a/src/cmd/link/internal/ld/link.go b/src/cmd/link/internal/ld/link.go
index 1ab54dc918..c0d20680a7 100644
--- a/src/cmd/link/internal/ld/link.go
+++ b/src/cmd/link/internal/ld/link.go
@@ -98,6 +98,7 @@ type Link struct {
moduledataTypeDescOffset int64
moduledataItabOffset int64
+ moduledataItabSizeOffset int64
PackageFile map[string]string
PackageShlib map[string]string
diff --git a/src/cmd/link/internal/ld/symtab.go b/src/cmd/link/internal/ld/symtab.go
index ddc2278593..37ab0fa582 100644
--- a/src/cmd/link/internal/ld/symtab.go
+++ b/src/cmd/link/internal/ld/symtab.go
@@ -638,6 +638,8 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind {
moduledata.AddAddr(ctxt.Arch, ldr.Lookup("runtime.etypes", 0))
ctxt.moduledataItabOffset = moduledata.Size()
moduledata.AddUint(ctxt.Arch, 0) // filled in by dodataSect
+ ctxt.moduledataItabSizeOffset = moduledata.Size()
+ moduledata.AddUint(ctxt.Arch, 0) // filled in by dodataSect
moduledata.AddAddr(ctxt.Arch, ldr.Lookup("runtime.rodata", 0))
moduledata.AddAddr(ctxt.Arch, ldr.Lookup("go:func.*", 0))
moduledata.AddAddr(ctxt.Arch, ldr.Lookup("runtime.epclntab", 0))
diff --git a/src/runtime/iface.go b/src/runtime/iface.go
index 5e58db6108..009f104327 100644
--- a/src/runtime/iface.go
+++ b/src/runtime/iface.go
@@ -269,7 +269,8 @@ func itabsinit() {
// This is an optimization to let us skip creating itabs we already have.
func addModuleItabs(md *moduledata) {
p := md.types + md.itaboffset
- for p < md.etypes {
+ end := p + md.itabsize
+ for p < end {
itab := (*itab)(unsafe.Pointer(p))
itabAdd(itab)
p += uintptr(itab.Size())
diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go
index f5e69c26ec..aa84a6f94e 100644
--- a/src/runtime/symtab.go
+++ b/src/runtime/symtab.go
@@ -420,7 +420,7 @@ type moduledata struct {
covctrs, ecovctrs uintptr
end, gcdata, gcbss uintptr
types, typedesclen, etypes uintptr
- itaboffset uintptr
+ itaboffset, itabsize uintptr
rodata uintptr
gofunc uintptr // go.func.*
epclntab uintptr