Skip to content

Commit 6533cc1

Browse files
committed
cmd/internal/goobj: update to support go19ld
Updates the disassembler to support the same object file version used by the assembler and linker. Related #14782. Change-Id: I4cd7560c4e4e1350cfb27ca9cbe0fde25fe693cc Reviewed-on: https://go-review.googlesource.com/37797 Run-TryBot: Matthew Dempsky <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Austin Clements <[email protected]>
1 parent 7c84dc7 commit 6533cc1

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/cmd/internal/goobj/read.go

+21-2
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,11 @@ type Func struct {
198198
PCSP Data // PC → SP offset map
199199
PCFile Data // PC → file number map (index into File)
200200
PCLine Data // PC → line number map
201+
PCInline Data // PC → inline tree index map
201202
PCData []Data // PC → runtime support data map
202203
FuncData []FuncData // non-PC-specific runtime support data
203204
File []string // paths indexed by PCFile
205+
InlTree []InlinedCall
204206
}
205207

206208
// TODO: Add PCData []byte and PCDataIter (similar to liblink).
@@ -211,6 +213,15 @@ type FuncData struct {
211213
Offset int64 // offset into symbol for funcdata pointer
212214
}
213215

216+
// An InlinedCall is a node in an InlTree.
217+
// See cmd/internal/obj.InlTree for details.
218+
type InlinedCall struct {
219+
Parent int
220+
File string
221+
Line int
222+
Func SymID
223+
}
224+
214225
// A Package is a parsed Go object file or archive defining a Go package.
215226
type Package struct {
216227
ImportPath string // import path denoting this package
@@ -583,7 +594,7 @@ func (r *objReader) parseObject(prefix []byte) error {
583594
// TODO: extract OS + build ID if/when we need it
584595

585596
r.readFull(r.tmp[:8])
586-
if !bytes.Equal(r.tmp[:8], []byte("\x00\x00go17ld")) {
597+
if !bytes.Equal(r.tmp[:8], []byte("\x00\x00go19ld")) {
587598
return r.error(errCorruptObject)
588599
}
589600

@@ -671,6 +682,7 @@ func (r *objReader) parseObject(prefix []byte) error {
671682
f.PCSP = r.readData()
672683
f.PCFile = r.readData()
673684
f.PCLine = r.readData()
685+
f.PCInline = r.readData()
674686
f.PCData = make([]Data, r.readInt())
675687
for i := range f.PCData {
676688
f.PCData[i] = r.readData()
@@ -686,11 +698,18 @@ func (r *objReader) parseObject(prefix []byte) error {
686698
for i := range f.File {
687699
f.File[i] = r.readSymID().Name
688700
}
701+
f.InlTree = make([]InlinedCall, r.readInt())
702+
for i := range f.InlTree {
703+
f.InlTree[i].Parent = r.readInt()
704+
f.InlTree[i].File = r.readSymID().Name
705+
f.InlTree[i].Line = r.readInt()
706+
f.InlTree[i].Func = r.readSymID()
707+
}
689708
}
690709
}
691710

692711
r.readFull(r.tmp[:7])
693-
if !bytes.Equal(r.tmp[:7], []byte("\xffgo17ld")) {
712+
if !bytes.Equal(r.tmp[:7], []byte("\xffgo19ld")) {
694713
return r.error(errCorruptObject)
695714
}
696715

0 commit comments

Comments
 (0)