Commit 6533cc1c authored by Matthew Dempsky's avatar Matthew Dempsky

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 <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarAustin Clements <austin@google.com>
parent 7c84dc79
......@@ -198,9 +198,11 @@ type Func struct {
PCSP Data // PC → SP offset map
PCFile Data // PC → file number map (index into File)
PCLine Data // PC → line number map
PCInline Data // PC → inline tree index map
PCData []Data // PC → runtime support data map
FuncData []FuncData // non-PC-specific runtime support data
File []string // paths indexed by PCFile
InlTree []InlinedCall
}
// TODO: Add PCData []byte and PCDataIter (similar to liblink).
......@@ -211,6 +213,15 @@ type FuncData struct {
Offset int64 // offset into symbol for funcdata pointer
}
// An InlinedCall is a node in an InlTree.
// See cmd/internal/obj.InlTree for details.
type InlinedCall struct {
Parent int
File string
Line int
Func SymID
}
// A Package is a parsed Go object file or archive defining a Go package.
type Package struct {
ImportPath string // import path denoting this package
......@@ -583,7 +594,7 @@ func (r *objReader) parseObject(prefix []byte) error {
// TODO: extract OS + build ID if/when we need it
r.readFull(r.tmp[:8])
if !bytes.Equal(r.tmp[:8], []byte("\x00\x00go17ld")) {
if !bytes.Equal(r.tmp[:8], []byte("\x00\x00go19ld")) {
return r.error(errCorruptObject)
}
......@@ -671,6 +682,7 @@ func (r *objReader) parseObject(prefix []byte) error {
f.PCSP = r.readData()
f.PCFile = r.readData()
f.PCLine = r.readData()
f.PCInline = r.readData()
f.PCData = make([]Data, r.readInt())
for i := range f.PCData {
f.PCData[i] = r.readData()
......@@ -686,11 +698,18 @@ func (r *objReader) parseObject(prefix []byte) error {
for i := range f.File {
f.File[i] = r.readSymID().Name
}
f.InlTree = make([]InlinedCall, r.readInt())
for i := range f.InlTree {
f.InlTree[i].Parent = r.readInt()
f.InlTree[i].File = r.readSymID().Name
f.InlTree[i].Line = r.readInt()
f.InlTree[i].Func = r.readSymID()
}
}
}
r.readFull(r.tmp[:7])
if !bytes.Equal(r.tmp[:7], []byte("\xffgo17ld")) {
if !bytes.Equal(r.tmp[:7], []byte("\xffgo19ld")) {
return r.error(errCorruptObject)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment