cmd/link: skip special symbols for label symbol generation

Some special symbols, e.g. funcdata symbols, don't have a section
set, because they are laid out as part of the top-level
go:func.* symbol. Similarly, other non-top-level symbols are part
of some top-level symbols. There is no relocation directly
targetting those symbols, so there is no need to generate label
symbols for them.

Fixes #77593.

(No in-tree test as it needs a function with very large funcdata.)

Change-Id: I4aac4d0438bd64ac60b9baa3c2c66bb11f03c404
Reviewed-on: https://go-review.googlesource.com/c/go/+/756060
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
Cherry Mui
2026-03-17 11:18:36 -04:00
parent 30bfe53dd7
commit 0520d3f352

View File

@@ -1284,6 +1284,9 @@ func gensymlate(ctxt *ld.Link, ldr *loader.Loader) {
// addLabelSyms adds "label" symbols at s+limit, s+2*limit, etc.
addLabelSyms := func(s loader.Sym, limit, sz int64) {
if ldr.SymSect(s) == nil {
log.Fatalf("gensymlate: symbol %s has no section (type=%v)", ldr.SymName(s), ldr.SymType(s))
}
v := ldr.SymValue(s)
for off := limit; off < sz; off += limit {
p := ldr.LookupOrCreateSym(offsetLabelName(ldr, s, off), ldr.SymVersion(s))
@@ -1326,6 +1329,10 @@ func gensymlate(ctxt *ld.Link, ldr *loader.Loader) {
if t >= sym.SDWARFSECT {
continue // no need to add label for DWARF symbols
}
if ldr.AttrSpecial(s) || !ldr.TopLevelSym(s) {
// no need to add label for special symbols and non-top-level symbols
continue
}
sz := ldr.SymSize(s)
if sz <= limit {
continue