mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link, runtime: don't store text start in pcHeader
The textStart field requires a relocation, the only relocation in pclntab. And nothing uses it. So remove it. Replace it with a zero, which can itself be removed at some point in coordination with Delve. For #76038 Change-Id: I35675c0868c5d957bb375e40b804c516ae0300ca Reviewed-on: https://go-review.googlesource.com/c/go/+/717240 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
7347b54727
commit
0e1bd8b5f1
3 changed files with 17 additions and 19 deletions
|
|
@ -243,7 +243,6 @@ func makeInlSyms(ctxt *Link, funcs []loader.Sym, nameOffsets map[loader.Sym]uint
|
||||||
// generator to fill in its data later.
|
// generator to fill in its data later.
|
||||||
func (state *pclntab) generatePCHeader(ctxt *Link) {
|
func (state *pclntab) generatePCHeader(ctxt *Link) {
|
||||||
ldr := ctxt.loader
|
ldr := ctxt.loader
|
||||||
textStartOff := int64(8 + 2*ctxt.Arch.PtrSize)
|
|
||||||
size := int64(8 + 8*ctxt.Arch.PtrSize)
|
size := int64(8 + 8*ctxt.Arch.PtrSize)
|
||||||
writeHeader := func(ctxt *Link, s loader.Sym) {
|
writeHeader := func(ctxt *Link, s loader.Sym) {
|
||||||
header := ctxt.loader.MakeSymbolUpdater(s)
|
header := ctxt.loader.MakeSymbolUpdater(s)
|
||||||
|
|
@ -264,10 +263,7 @@ func (state *pclntab) generatePCHeader(ctxt *Link) {
|
||||||
header.SetUint8(ctxt.Arch, 7, uint8(ctxt.Arch.PtrSize))
|
header.SetUint8(ctxt.Arch, 7, uint8(ctxt.Arch.PtrSize))
|
||||||
off := header.SetUint(ctxt.Arch, 8, uint64(state.nfunc))
|
off := header.SetUint(ctxt.Arch, 8, uint64(state.nfunc))
|
||||||
off = header.SetUint(ctxt.Arch, off, uint64(state.nfiles))
|
off = header.SetUint(ctxt.Arch, off, uint64(state.nfiles))
|
||||||
if off != textStartOff {
|
off = header.SetUintptr(ctxt.Arch, off, 0) // unused
|
||||||
panic(fmt.Sprintf("pcHeader textStartOff: %d != %d", off, textStartOff))
|
|
||||||
}
|
|
||||||
off += int64(ctxt.Arch.PtrSize) // skip runtimeText relocation
|
|
||||||
off = writeSymOffset(off, state.funcnametab)
|
off = writeSymOffset(off, state.funcnametab)
|
||||||
off = writeSymOffset(off, state.cutab)
|
off = writeSymOffset(off, state.cutab)
|
||||||
off = writeSymOffset(off, state.filetab)
|
off = writeSymOffset(off, state.filetab)
|
||||||
|
|
@ -279,9 +275,6 @@ func (state *pclntab) generatePCHeader(ctxt *Link) {
|
||||||
}
|
}
|
||||||
|
|
||||||
state.pcheader = state.addGeneratedSym(ctxt, "runtime.pcheader", size, writeHeader)
|
state.pcheader = state.addGeneratedSym(ctxt, "runtime.pcheader", size, writeHeader)
|
||||||
// Create the runtimeText relocation.
|
|
||||||
sb := ldr.MakeSymbolUpdater(state.pcheader)
|
|
||||||
sb.SetAddr(ctxt.Arch, textStartOff, ldr.Lookup("runtime.text", 0))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// walkFuncs iterates over the funcs, calling a function for each unique
|
// walkFuncs iterates over the funcs, calling a function for each unique
|
||||||
|
|
|
||||||
|
|
@ -1009,7 +1009,7 @@ const (
|
||||||
type _func struct {
|
type _func struct {
|
||||||
sys.NotInHeap // Only in static data
|
sys.NotInHeap // Only in static data
|
||||||
|
|
||||||
entryOff uint32 // start pc, as offset from moduledata.text/pcHeader.textStart
|
entryOff uint32 // start pc, as offset from moduledata.text
|
||||||
nameOff int32 // function name, as index into moduledata.funcnametab.
|
nameOff int32 // function name, as index into moduledata.funcnametab.
|
||||||
|
|
||||||
args int32 // in/out args size
|
args int32 // in/out args size
|
||||||
|
|
|
||||||
|
|
@ -374,13 +374,19 @@ func (f *_func) funcInfo() funcInfo {
|
||||||
|
|
||||||
// pcHeader holds data used by the pclntab lookups.
|
// pcHeader holds data used by the pclntab lookups.
|
||||||
type pcHeader struct {
|
type pcHeader struct {
|
||||||
magic uint32 // 0xFFFFFFF1
|
magic uint32 // 0xFFFFFFF1
|
||||||
pad1, pad2 uint8 // 0,0
|
pad1, pad2 uint8 // 0,0
|
||||||
minLC uint8 // min instruction size
|
minLC uint8 // min instruction size
|
||||||
ptrSize uint8 // size of a ptr in bytes
|
ptrSize uint8 // size of a ptr in bytes
|
||||||
nfunc int // number of functions in the module
|
nfunc int // number of functions in the module
|
||||||
nfiles uint // number of entries in the file tab
|
nfiles uint // number of entries in the file tab
|
||||||
textStart uintptr // base for function entry PC offsets in this module, equal to moduledata.text
|
|
||||||
|
// The next field used to be textStart. This is no longer stored
|
||||||
|
// as it requires a relocation. Code should use the moduledata text
|
||||||
|
// field instead. This unused field can be removed in coordination
|
||||||
|
// with Delve.
|
||||||
|
_ uintptr
|
||||||
|
|
||||||
funcnameOffset uintptr // offset to the funcnametab variable from pcHeader
|
funcnameOffset uintptr // offset to the funcnametab variable from pcHeader
|
||||||
cuOffset uintptr // offset to the cutab variable from pcHeader
|
cuOffset uintptr // offset to the cutab variable from pcHeader
|
||||||
filetabOffset uintptr // offset to the filetab variable from pcHeader
|
filetabOffset uintptr // offset to the filetab variable from pcHeader
|
||||||
|
|
@ -618,10 +624,9 @@ func moduledataverify1(datap *moduledata) {
|
||||||
// Check that the pclntab's format is valid.
|
// Check that the pclntab's format is valid.
|
||||||
hdr := datap.pcHeader
|
hdr := datap.pcHeader
|
||||||
if hdr.magic != 0xfffffff1 || hdr.pad1 != 0 || hdr.pad2 != 0 ||
|
if hdr.magic != 0xfffffff1 || hdr.pad1 != 0 || hdr.pad2 != 0 ||
|
||||||
hdr.minLC != sys.PCQuantum || hdr.ptrSize != goarch.PtrSize || hdr.textStart != datap.text {
|
hdr.minLC != sys.PCQuantum || hdr.ptrSize != goarch.PtrSize {
|
||||||
println("runtime: pcHeader: magic=", hex(hdr.magic), "pad1=", hdr.pad1, "pad2=", hdr.pad2,
|
println("runtime: pcHeader: magic=", hex(hdr.magic), "pad1=", hdr.pad1, "pad2=", hdr.pad2,
|
||||||
"minLC=", hdr.minLC, "ptrSize=", hdr.ptrSize, "pcHeader.textStart=", hex(hdr.textStart),
|
"minLC=", hdr.minLC, "ptrSize=", hdr.ptrSize, "pluginpath=", datap.pluginpath)
|
||||||
"text=", hex(datap.text), "pluginpath=", datap.pluginpath)
|
|
||||||
throw("invalid function symbol table")
|
throw("invalid function symbol table")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue