aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2026-01-29 14:50:05 -0800
committerGopher Robot <gobot@golang.org>2026-01-29 15:15:54 -0800
commitc08f6a5b2651b2ce4a9510952fb88739719fe5a4 (patch)
treefa737b80e2804496841c74b85dc0dc776e5092a0 /src/cmd
parent14a4cb13e389d8dbc1ba3ba0097e208f1436a22a (diff)
downloadgo-c08f6a5b2651b2ce4a9510952fb88739719fe5a4.tar.xz
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 <khr@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/link/internal/ld/data.go13
1 files changed, 12 insertions, 1 deletions
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 {