[go] runtime, cmd/link, cmd/internal/objfile: adapting pclntab/lrodata patch

2 views
Skip to first unread message

David Chase (Gerrit)

unread,
Dec 15, 2025, 6:19:52 PM (20 hours ago) Dec 15
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

David Chase has uploaded the change for review

Commit message

runtime, cmd/link, cmd/internal/objfile: adapting pclntab/lrodata patch

DO NOT SUBMIT

this is one way to make it work, another option is
to make pclntab-in-lrodata be more narrowly targeted

kept as a commit for preservation/posterity

includes fixes to mach-o processing for pclntab in lrodata
Change-Id: If8f0eaa804e8d13f9fe2e202e63365e4292c9e8e

Change diff

diff --git a/src/cmd/internal/objfile/macho.go b/src/cmd/internal/objfile/macho.go
index eaf665f..d2b4228 100644
--- a/src/cmd/internal/objfile/macho.go
+++ b/src/cmd/internal/objfile/macho.go
@@ -87,6 +87,13 @@
if pclntab, err = sect.Data(); err != nil {
return 0, nil, err
}
+ return textStart, pclntab, nil
+ }
+ if sect := f.macho.Section("__lrodata_gopcln"); sect != nil {
+ if pclntab, err = sect.Data(); err != nil {
+ return 0, nil, err
+ }
+ return textStart, pclntab, nil
}
return textStart, pclntab, nil
}
diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go
index 5b6dabb..c9fe261 100644
--- a/src/cmd/link/internal/ld/data.go
+++ b/src/cmd/link/internal/ld/data.go
@@ -2140,7 +2140,7 @@
}

/* gopclntab */
- sect = state.allocateNamedSectionAndAssignSyms(segro, ".gopclntab", sym.SPCLNTAB, sym.SRODATA, 04)
+ sect = state.allocateNamedSectionAndAssignSyms(segro, ".lrodata.gopclntab", sym.SPCLNTAB, sym.SRODATA, 04)
ldr.SetSymSect(ldr.LookupOrCreateSym("runtime.pclntab", 0), sect)
ldr.SetSymSect(ldr.LookupOrCreateSym("runtime.pcheader", 0), sect)
ldr.SetSymSect(ldr.LookupOrCreateSym("runtime.funcnametab", 0), sect)
diff --git a/src/cmd/link/link_test.go b/src/cmd/link/link_test.go
index bc7504e..727c5cc 100644
--- a/src/cmd/link/link_test.go
+++ b/src/cmd/link/link_test.go
@@ -1879,7 +1879,7 @@
}

for _, sec := range mf.Sections {
- if sec.Name == "__gopclntab" {
+ if sec.Name == "__gopclntab" || sec.Name == "__lrodata_gopcln" {
data, err := sec.Data()
if err != nil {
t.Fatal(err)
diff --git a/src/runtime/stkframe.go b/src/runtime/stkframe.go
index b63c0b4..56cb874 100644
--- a/src/runtime/stkframe.go
+++ b/src/runtime/stkframe.go
@@ -269,6 +269,11 @@
ptr := uintptr(unsafe.Pointer(&methodValueCallFrameObjs[0]))
var mod *moduledata
for datap := &firstmoduledata; datap != nil; datap = datap.next {
+ // Check if ptr is in pclntab section (gofunc to epclntab).
+ if datap.gofunc <= ptr && ptr < datap.epclntab {
+ mod = datap
+ break
+ }
if datap.noptrbss <= ptr && ptr < datap.enoptrbss {
mod = datap
break

Change information

Files:
  • M src/cmd/internal/objfile/macho.go
  • M src/cmd/link/internal/ld/data.go
  • M src/cmd/link/link_test.go
  • M src/runtime/stkframe.go
Change size: S
Delta: 4 files changed, 14 insertions(+), 2 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedDo-Not-Submit
  • 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: If8f0eaa804e8d13f9fe2e202e63365e4292c9e8e
Gerrit-Change-Number: 730300
Gerrit-PatchSet: 1
Gerrit-Owner: David Chase <drc...@google.com>
Gerrit-Reviewer: David Chase <drc...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Ian Lance Taylor (Gerrit)

unread,
Dec 15, 2025, 6:23:32 PM (20 hours ago) Dec 15
to David Chase, goph...@pubsubhelper.golang.org, Ian Lance Taylor, Go LUCI, golang-co...@googlegroups.com
Attention needed from David Chase

Ian Lance Taylor added 1 comment

File src/runtime/stkframe.go
Line 272, Patchset 1 (Latest): // Check if ptr is in pclntab section (gofunc to epclntab).
Ian Lance Taylor . unresolved

This part of the change should not be required. methodValueCallFrameObjs should really be in noptrbss, not anyplace else.

Open in Gerrit

Related details

Attention is currently required from:
  • David Chase
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedDo-Not-Submit
    • requirement is not 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: If8f0eaa804e8d13f9fe2e202e63365e4292c9e8e
    Gerrit-Change-Number: 730300
    Gerrit-PatchSet: 1
    Gerrit-Owner: David Chase <drc...@google.com>
    Gerrit-Reviewer: David Chase <drc...@google.com>
    Gerrit-CC: Ian Lance Taylor <ia...@golang.org>
    Gerrit-Attention: David Chase <drc...@google.com>
    Gerrit-Comment-Date: Mon, 15 Dec 2025 23:23:28 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages