From c08f6a5b2651b2ce4a9510952fb88739719fe5a4 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 29 Jan 2026 14:50:05 -0800 Subject: [PATCH] cmd/link: put type:* at the start of the type descriptors That used to happen naturally because the symbol had zero size. After CL 724261 we need to force it. Fixes #77372 Change-Id: Ia8eef989bc9cbad5459b60ff6535136e7e0c6cab Reviewed-on: https://go-review.googlesource.com/c/go/+/740400 Reviewed-by: Keith Randall Auto-Submit: Ian Lance Taylor Reviewed-by: Dmitri Shuralyov Reviewed-by: Keith Randall LUCI-TryBot-Result: Go LUCI --- src/cmd/link/internal/ld/data.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go index 63fe516d4e..683df3bb67 100644 --- a/src/cmd/link/internal/ld/data.go +++ b/src/cmd/link/internal/ld/data.go @@ -2395,6 +2395,9 @@ func (state *dodataState) dodataSect(ctxt *Link, symn sym.SymKind, syms []loader // sorted by type string. The reflect package will use // this to ensure that type descriptor pointers are unique. + // We define type:* for some links. + typeStar := ldr.Lookup("type:*", 0) + // Compute all the type strings we need once. typelinkStrings := make(map[loader.Sym]string) for _, s := range syms { @@ -2410,6 +2413,14 @@ func (state *dodataState) dodataSect(ctxt *Link, symn sym.SymKind, syms []loader if ret, matched := sortHeadTail(si, sj); matched { return ret } + if typeStar != 0 { + // type:* comes first, after runtime.types + if si == typeStar { + return true + } else if sj == typeStar { + return false + } + } iTypestr, iIsTypelink := typelinkStrings[si] jTypestr, jIsTypelink := typelinkStrings[sj] @@ -2438,7 +2449,7 @@ func (state *dodataState) dodataSect(ctxt *Link, symn sym.SymKind, syms []loader typeLinkSize := int64(1) for i := range sl { si := sl[i].sym - if si == head { + if si == head || si == typeStar { continue } if _, isTypelink := typelinkStrings[si]; !isTypelink { -- 2.52.0