diff options
| author | Ian Lance Taylor <iant@golang.org> | 2025-12-10 20:46:43 -0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-03-10 20:05:35 -0700 |
| commit | bcc369284d5ed042e1155ac11ccf15ea2990a64e (patch) | |
| tree | 3b22c6fcfbd6eb0e303b4555e216d2542decad5b /src/cmd | |
| parent | 703cc8abeca5ff4f3da1df6766c6abf43462257b (diff) | |
| download | go-bcc369284d5ed042e1155ac11ccf15ea2990a64e.tar.xz | |
cmd/link: put itabs in the .go.type section
For #76038
Change-Id: I4c30d5854fcaacc7fd7f84b4679a5be30379122d
Reviewed-on: https://go-review.googlesource.com/c/go/+/729200
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Mark Freeman <markfreeman@google.com>
Reviewed-by: Pagol Mon <mpagol707@gmail.com>
Diffstat (limited to 'src/cmd')
| -rw-r--r-- | src/cmd/link/internal/ld/data.go | 28 | ||||
| -rw-r--r-- | src/cmd/link/internal/ld/symtab.go | 31 |
2 files changed, 31 insertions, 28 deletions
diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go index 89df83cfeb..1265b028e6 100644 --- a/src/cmd/link/internal/ld/data.go +++ b/src/cmd/link/internal/ld/data.go @@ -2430,6 +2430,7 @@ func (state *dodataState) dodataSect(ctxt *Link, symn sym.SymKind, syms []loader // 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. // We define type:* for some links. typeStar := ldr.Lookup("type:*", 0) @@ -2458,23 +2459,32 @@ func (state *dodataState) dodataSect(ctxt *Link, symn sym.SymKind, syms []loader } } - iTypestr, iIsTypelink := typelinkStrings[si] - jTypestr, jIsTypelink := typelinkStrings[sj] + iIsType := !ldr.IsItab(si) + jIsType := !ldr.IsItab(sj) + 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) }) diff --git a/src/cmd/link/internal/ld/symtab.go b/src/cmd/link/internal/ld/symtab.go index b88cfd3386..3dc2adc810 100644 --- a/src/cmd/link/internal/ld/symtab.go +++ b/src/cmd/link/internal/ld/symtab.go @@ -459,15 +459,12 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind { 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) @@ -523,20 +520,16 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind { case strings.HasPrefix(name, "type:"): if !ctxt.DynlinkingGo() { ldr.SetAttrNotInSymbolTable(s, true) + ldr.SetCarrierSym(s, symtype) } symGroupType[s] = sym.STYPE - if symtype != 0 { + + case ldr.IsItab(s): + if !ctxt.DynlinkingGo() { + ldr.SetAttrNotInSymbolTable(s, true) ldr.SetCarrierSym(s, symtype) } - if ctxt.HeadType == objabi.Haix { - // The default alignment is currently 0x20, - // which the AIX external linker doesn't - // seem to support. To get consistent - // alignment on AIX, force alignment to 8. - if symalign(ldr, s) > 8 { - ldr.SetSymAlign(s, 8) - } - } + symGroupType[s] = sym.STYPE } } |
