[go] cmd/link: put itabs in the .go.type section

4 views
Skip to first unread message

Ian Lance Taylor (Gerrit)

unread,
Dec 10, 2025, 11:47:18 PM12/10/25
to goph...@pubsubhelper.golang.org, Ian Lance Taylor, golang-co...@googlegroups.com

Ian Lance Taylor has uploaded the change for review

Commit message

cmd/link: put itabs in the .go.type section

For #76038
Change-Id: I4c30d5854fcaacc7fd7f84b4679a5be30379122d

Change diff

diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go
index 51163c2..1dbfb00 100644
--- a/src/cmd/link/internal/ld/data.go
+++ b/src/cmd/link/internal/ld/data.go
@@ -1543,6 +1543,14 @@
etypes.SetType(sym.STYPE)
ldr.SetAttrSpecial(etypes.Sym(), false)

+ itabs := ldr.CreateSymForUpdate("runtime.itabs", 0)
+ itabs.SetType(sym.STYPE)
+ ldr.SetAttrSpecial(itabs.Sym(), false)
+
+ eitabs := ldr.CreateSymForUpdate("runtime.eitabs", 0)
+ eitabs.SetType(sym.STYPE)
+ ldr.SetAttrSpecial(eitabs.Sym(), false)
+
if ctxt.HeadType == objabi.Haix {
rodata := ldr.CreateSymForUpdate("runtime.rodata", 0)
rodata.SetType(sym.SSTRING)
@@ -2220,6 +2228,8 @@
ldr.SetSymSect(ldr.LookupOrCreateSym("runtime.types", 0), sect)
ldr.SetSymSect(ldr.LookupOrCreateSym("runtime.etypedesc", 0), sect)
ldr.SetSymSect(ldr.LookupOrCreateSym("runtime.etypes", 0), sect)
+ ldr.SetSymSect(ldr.LookupOrCreateSym("runtime.itabs", 0), sect)
+ ldr.SetSymSect(ldr.LookupOrCreateSym("runtime.eitabs", 0), sect)

sect = createRelroSect(".go.func", sym.SGOFUNC)

@@ -2322,7 +2332,7 @@
for k, s := range syms {
ss := ldr.SymSize(s)
sl[k] = symNameSize{sz: ss, sym: s}
- if !sortBySize {
+ if !sortBySize || symn == sym.STYPE {
sl[k].name = ldr.SymName(s)
}
ds := int64(len(ldr.Data(s)))
@@ -2344,7 +2354,7 @@
"runtime.noptrdata", "runtime.noptrbss":
head = s
continue
- case "runtime.etext", "runtime.ebss", "runtime.edata", "runtime.etypes", "runtime.erodata",
+ case "runtime.etext", "runtime.ebss", "runtime.edata", "runtime.eitabs", "runtime.erodata",
"runtime.enoptrdata", "runtime.enoptrbss":
tail = s
continue
@@ -2399,6 +2409,7 @@
// Sort type descriptors with the typelink flag first,
// sorted by type string. The reflect package will use
// this to ensure that type descriptor pointers are unique.
+ // Sort itabs after type descriptors.

// Compute all the type strings we need once.
typelinkStrings := make(map[loader.Sym]string)
@@ -2408,6 +2419,10 @@
}
}

+ isType := func(name string) bool {
+ return strings.HasPrefix(name, "type:")
+ }
+
sort.Slice(sl, func(i, j int) bool {
si, sj := sl[i].sym, sl[j].sym

@@ -2416,23 +2431,32 @@
return ret
}

- iTypestr, iIsTypelink := typelinkStrings[si]
- jTypestr, jIsTypelink := typelinkStrings[sj]
+ iIsType := isType(sl[i].name)
+ jIsType := isType(sl[j].name)
+ if iIsType && jIsType {
+ iTypestr, iIsTypelink := typelinkStrings[si]
+ jTypestr, jIsTypelink := typelinkStrings[sj]

- if iIsTypelink {
- if jIsTypelink {
+ if iIsTypelink && jIsTypelink {
// typelink symbols sort by type string
return iTypestr < jTypestr
+ } else if iIsTypelink {
+ // typelink < non-typelink
+ return true
+ } else if jIsTypelink {
+ // non-typelink > typelink
+ return false
}
-
- // typelink < non-typelink
+ } else if iIsType {
+ // type < itab
return true
- } else if jIsTypelink {
- // non-typelink greater than typelink
+ } else if jIsType {
+ // itab > type
return false
}

- // non-typelink symbols sort by size as usual
+ // Otherwise, within non-typelink types and itabs,
+ // sort by size as usual.
return sortFn(i, j)
})

@@ -2441,7 +2465,8 @@
// createRelroSect in allocateDataSections.
// TODO: This wastes some space.
offset := int64(1)
- for i := range sl {
+ i := 0
+ for ; i < len(sl); i++ {
si := sl[i].sym
if _, isTypelink := typelinkStrings[si]; !isTypelink {
break
@@ -2452,6 +2477,21 @@

ldr.SetSymValue(ldr.LookupOrCreateSym("runtime.etypedesc", 0), offset)

+ // Find the end of the type descriptors.
+ for ; i < len(sl); i++ {
+ if !isType(sl[i].name) {
+ break
+ }
+ offset = Rnd(offset, int64(symalign(ldr, sl[i].sym)))
+ offset += sl[i].sz
+ }
+
+ ldr.SetSymValue(ldr.LookupOrCreateSym("runtime.etypes", 0), offset)
+ if i < len(sl) {
+ offset = Rnd(offset, int64(symalign(ldr, sl[i].sym)))
+ }
+ ldr.SetSymValue(ldr.LookupOrCreateSym("runtime.itabs", 0), offset)
+
default:
sort.Slice(sl, sortFn)
}
@@ -3098,10 +3138,15 @@
ctxt.xdefine("runtime.rodata", sym.SRODATA, int64(rodata.Vaddr))
ctxt.xdefine("runtime.erodata", sym.SRODATA, int64(rodata.Vaddr+rodata.Length))
ctxt.xdefine("runtime.types", sym.SRODATA, int64(types.Vaddr))
- // etypedesc was set to the offset from the symbol start in dodataSect.
+ // etypedesc, etypes, and itabs were set to the offset from the
+ // symbol start in dodataSect.
s := ldr.Lookup("runtime.etypedesc", 0)
ctxt.xdefine("runtime.etypedesc", sym.SRODATA, int64(types.Vaddr+uint64(ldr.SymValue(s))))
- ctxt.xdefine("runtime.etypes", sym.SRODATA, int64(types.Vaddr+types.Length))
+ s = ldr.Lookup("runtime.etypes", 0)
+ ctxt.xdefine("runtime.etypes", sym.SRODATA, int64(types.Vaddr+uint64(ldr.SymValue(s))))
+ s = ldr.Lookup("runtime.itabs", 0)
+ ctxt.xdefine("runtime.itabs", sym.SRODATA, int64(types.Vaddr+uint64(ldr.SymValue(s))))
+ ctxt.xdefine("runtime.eitabs", sym.SRODATA, int64(types.Vaddr+types.Length))

s = ldr.Lookup("runtime.gcdata", 0)
ldr.SetAttrLocal(s, true)
diff --git a/src/cmd/link/internal/ld/symtab.go b/src/cmd/link/internal/ld/symtab.go
index b379d4a..87a4d4e 100644
--- a/src/cmd/link/internal/ld/symtab.go
+++ b/src/cmd/link/internal/ld/symtab.go
@@ -435,6 +435,8 @@
ctxt.xdefine("runtime.types", sym.SRODATA, 0)
ctxt.xdefine("runtime.etypedesc", sym.SRODATA, 0)
ctxt.xdefine("runtime.etypes", sym.SRODATA, 0)
+ ctxt.xdefine("runtime.itabs", sym.SRODATA, 0)
+ ctxt.xdefine("runtime.eitabs", sym.SRODATA, 0)
ctxt.xdefine("runtime.noptrdata", sym.SNOPTRDATA, 0)
ctxt.xdefine("runtime.enoptrdata", sym.SNOPTRDATAEND, 0)
ctxt.xdefine("runtime.data", sym.SDATA, 0)
@@ -460,15 +462,12 @@
ctxt.xdefine("runtime.egcbss", sym.SRODATA, 0)

// pseudo-symbols to mark locations of type, string, and go string data.
- var symtype loader.Sym
- if !ctxt.DynlinkingGo() {
- s = ldr.CreateSymForUpdate("type:*", 0)
- s.SetType(sym.STYPE)
- s.SetSize(0)
- s.SetAlign(int32(ctxt.Arch.PtrSize))
- symtype = s.Sym()
- setCarrierSym(sym.STYPE, symtype)
- }
+ s = ldr.CreateSymForUpdate("type:*", 0)
+ s.SetType(sym.STYPE)
+ s.SetSize(0)
+ s.SetAlign(int32(ctxt.Arch.PtrSize))
+ symtype := s.Sym()
+ setCarrierSym(sym.STYPE, symtype)

groupSym := func(name string, t sym.SymKind) loader.Sym {
s := ldr.CreateSymForUpdate(name, 0)
@@ -524,11 +523,13 @@
case strings.HasPrefix(name, "type:"):
if !ctxt.DynlinkingGo() {
ldr.SetAttrNotInSymbolTable(s, true)
- }
- symGroupType[s] = sym.STYPE
- if symtype != 0 {
ldr.SetCarrierSym(s, symtype)
}
+ symGroupType[s] = sym.STYPE
+
+ case ldr.IsItab(s):
+ ldr.SetCarrierSym(s, symtype)
+ symGroupType[s] = sym.STYPE
}
}

Change information

Files:
  • M src/cmd/link/internal/ld/data.go
  • M src/cmd/link/internal/ld/symtab.go
Change size: M
Delta: 2 files changed, 72 insertions(+), 26 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I4c30d5854fcaacc7fd7f84b4679a5be30379122d
Gerrit-Change-Number: 729200
Gerrit-PatchSet: 1
Gerrit-Owner: Ian Lance Taylor <ia...@golang.org>
unsatisfied_requirement
satisfied_requirement
open
diffy

Ian Lance Taylor (Gerrit)

unread,
Dec 10, 2025, 11:47:28 PM12/10/25
to Ian Lance Taylor, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Ian Lance Taylor voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I4c30d5854fcaacc7fd7f84b4679a5be30379122d
Gerrit-Change-Number: 729200
Gerrit-PatchSet: 1
Gerrit-Owner: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Comment-Date: Thu, 11 Dec 2025 04:47:23 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Ian Lance Taylor (Gerrit)

unread,
Dec 11, 2025, 12:16:23 AM12/11/25
to Ian Lance Taylor, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Cherry Mui, Ian Lance Taylor and Russ Cox

Ian Lance Taylor uploaded new patchset

Ian Lance Taylor uploaded patch set #2 to this change.
Following approvals got outdated and were removed:
  • TryBots-Pass: LUCI-TryBot-Result-1 by Go LUCI
Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Ian Lance Taylor
  • Russ Cox
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newpatchset
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I4c30d5854fcaacc7fd7f84b4679a5be30379122d
Gerrit-Change-Number: 729200
Gerrit-PatchSet: 2
Gerrit-Owner: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Russ Cox <r...@golang.org>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-Attention: Russ Cox <r...@golang.org>
Gerrit-Attention: Cherry Mui <cher...@google.com>
Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
unsatisfied_requirement
satisfied_requirement
open
diffy

Ian Lance Taylor (Gerrit)

unread,
Dec 11, 2025, 12:16:33 AM12/11/25
to Ian Lance Taylor, goph...@pubsubhelper.golang.org, Cherry Mui, Russ Cox, Gopher Robot, Go LUCI, golang-co...@googlegroups.com
Attention needed from Cherry Mui and Russ Cox

Ian Lance Taylor voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Russ Cox
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I4c30d5854fcaacc7fd7f84b4679a5be30379122d
Gerrit-Change-Number: 729200
Gerrit-PatchSet: 2
Gerrit-Owner: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Russ Cox <r...@golang.org>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-Attention: Russ Cox <r...@golang.org>
Gerrit-Attention: Cherry Mui <cher...@google.com>
Gerrit-Comment-Date: Thu, 11 Dec 2025 05:16:30 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Ian Lance Taylor (Gerrit)

unread,
Feb 6, 2026, 8:01:42 PM (6 hours ago) Feb 6
to Ian Lance Taylor, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
Attention needed from Cherry Mui and Russ Cox

Ian Lance Taylor uploaded new patchset

Ian Lance Taylor uploaded patch set #8 to this change.
Following approvals got outdated and were removed:
  • TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Russ Cox
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newpatchset
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I4c30d5854fcaacc7fd7f84b4679a5be30379122d
Gerrit-Change-Number: 729200
Gerrit-PatchSet: 8
unsatisfied_requirement
satisfied_requirement
open
diffy

Ian Lance Taylor (Gerrit)

unread,
Feb 6, 2026, 10:07:01 PM (4 hours ago) Feb 6
to Ian Lance Taylor, goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Russ Cox, Gopher Robot, golang-co...@googlegroups.com
Attention needed from Cherry Mui and Russ Cox

Ian Lance Taylor voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Russ Cox
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I4c30d5854fcaacc7fd7f84b4679a5be30379122d
Gerrit-Change-Number: 729200
Gerrit-PatchSet: 8
Gerrit-Owner: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Russ Cox <r...@golang.org>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-Attention: Russ Cox <r...@golang.org>
Gerrit-Attention: Cherry Mui <cher...@google.com>
Gerrit-Comment-Date: Sat, 07 Feb 2026 03:06:57 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Pagol Mon (Gerrit)

unread,
Feb 6, 2026, 11:03:53 PM (3 hours ago) Feb 6
to Ian Lance Taylor, goph...@pubsubhelper.golang.org, Go LUCI, Cherry Mui, Russ Cox, Gopher Robot, golang-co...@googlegroups.com
Attention needed from Cherry Mui, Ian Lance Taylor and Russ Cox

Pagol Mon voted Code-Review+1

Code-Review+1
Open in Gerrit

Related details

Attention is currently required from:
  • Cherry Mui
  • Ian Lance Taylor
  • Russ Cox
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I4c30d5854fcaacc7fd7f84b4679a5be30379122d
    Gerrit-Change-Number: 729200
    Gerrit-PatchSet: 8
    Gerrit-Owner: Ian Lance Taylor <ia...@golang.org>
    Gerrit-Reviewer: Cherry Mui <cher...@google.com>
    Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
    Gerrit-Reviewer: Pagol Mon <mpag...@gmail.com>
    Gerrit-Reviewer: Russ Cox <r...@golang.org>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Attention: Russ Cox <r...@golang.org>
    Gerrit-Attention: Cherry Mui <cher...@google.com>
    Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
    Gerrit-Comment-Date: Sat, 07 Feb 2026 04:03:42 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages