]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: put type:* at the start of the type descriptors
authorIan Lance Taylor <iant@golang.org>
Thu, 29 Jan 2026 22:50:05 +0000 (14:50 -0800)
committerGopher Robot <gobot@golang.org>
Thu, 29 Jan 2026 23:15:54 +0000 (15:15 -0800)
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>

src/cmd/link/internal/ld/data.go

index 63fe516d4e7e92fd53ce87a040dffdfa4c32dfbd..683df3bb67f89149f095e2181c0d5373054d046e 100644 (file)
@@ -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 {