diff options
author | Cherry Mui <cherryyz@google.com> | 2021-09-28 17:07:01 -0400 |
---|---|---|
committer | Cherry Mui <cherryyz@google.com> | 2021-09-29 13:53:55 +0000 |
commit | e180e2c27c3c3f06a4df6352386efedc15a1e38c (patch) | |
tree | b9a2addb3a2cfcea01926f97c1b21cde88fe06ff /src/cmd/internal | |
parent | 587b3c1192397393afb0ec5acd608e3dfe9f2116 (diff) | |
download | go-e180e2c27c3c3f06a4df6352386efedc15a1e38c.tar.gz go-e180e2c27c3c3f06a4df6352386efedc15a1e38c.zip |
cmd/internal/goobj, cmd/link: remove funcdataoff
FUNCDATA is always a symbol reference with 0 offset. Assert the
offset is 0 and remove funcdataoff.
Change-Id: I326815365c9db5aeef6b869df5d78a9957bc16a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/352894
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/cmd/internal')
-rw-r--r-- | src/cmd/internal/goobj/funcinfo.go | 35 | ||||
-rw-r--r-- | src/cmd/internal/obj/link.go | 17 | ||||
-rw-r--r-- | src/cmd/internal/obj/objfile.go | 4 | ||||
-rw-r--r-- | src/cmd/internal/obj/pcln.go | 11 |
4 files changed, 21 insertions, 46 deletions
diff --git a/src/cmd/internal/goobj/funcinfo.go b/src/cmd/internal/goobj/funcinfo.go index 6e7970fb74..59cb957fa7 100644 --- a/src/cmd/internal/goobj/funcinfo.go +++ b/src/cmd/internal/goobj/funcinfo.go @@ -21,11 +21,8 @@ type FuncInfo struct { Locals uint32 FuncID objabi.FuncID FuncFlag objabi.FuncFlag - - Funcdataoff []uint32 - File []CUFileIndex - - InlTree []InlTreeNode + File []CUFileIndex + InlTree []InlTreeNode } func (a *FuncInfo) Write(w *bytes.Buffer) { @@ -45,10 +42,6 @@ func (a *FuncInfo) Write(w *bytes.Buffer) { writeUint8(0) // pad to uint32 boundary writeUint8(0) - writeUint32(uint32(len(a.Funcdataoff))) - for _, x := range a.Funcdataoff { - writeUint32(x) - } writeUint32(uint32(len(a.File))) for _, f := range a.File { writeUint32(uint32(f)) @@ -65,25 +58,19 @@ func (a *FuncInfo) Write(w *bytes.Buffer) { // corresponding "off" field stores the byte offset of the start of // the items in question. type FuncInfoLengths struct { - NumFuncdataoff uint32 - FuncdataoffOff uint32 - NumFile uint32 - FileOff uint32 - NumInlTree uint32 - InlTreeOff uint32 - Initialized bool + NumFile uint32 + FileOff uint32 + NumInlTree uint32 + InlTreeOff uint32 + Initialized bool } func (*FuncInfo) ReadFuncInfoLengths(b []byte) FuncInfoLengths { var result FuncInfoLengths - // Offset to the number of funcdataoff values. This value is determined by counting + // Offset to the number of the file table. This value is determined by counting // the number of bytes until we write funcdataoff to the file. - const numfuncdataoffOff = 12 - result.NumFuncdataoff = binary.LittleEndian.Uint32(b[numfuncdataoffOff:]) - result.FuncdataoffOff = numfuncdataoffOff + 4 - - numfileOff := result.FuncdataoffOff + 4*result.NumFuncdataoff + const numfileOff = 12 result.NumFile = binary.LittleEndian.Uint32(b[numfileOff:]) result.FileOff = numfileOff + 4 @@ -104,10 +91,6 @@ func (*FuncInfo) ReadFuncID(b []byte) objabi.FuncID { return objabi.FuncID(b[8]) func (*FuncInfo) ReadFuncFlag(b []byte) objabi.FuncFlag { return objabi.FuncFlag(b[9]) } -func (*FuncInfo) ReadFuncdataoff(b []byte, funcdataofffoff uint32, k uint32) int64 { - return int64(binary.LittleEndian.Uint32(b[funcdataofffoff+4*k:])) -} - func (*FuncInfo) ReadFile(b []byte, filesoff uint32, k uint32) CUFileIndex { return CUFileIndex(binary.LittleEndian.Uint32(b[filesoff+4*k:])) } diff --git a/src/cmd/internal/obj/link.go b/src/cmd/internal/obj/link.go index 82ff5994d1..abb37416cc 100644 --- a/src/cmd/internal/obj/link.go +++ b/src/cmd/internal/obj/link.go @@ -830,15 +830,14 @@ func (*LSym) CanBeAnSSAAux() {} type Pcln struct { // Aux symbols for pcln - Pcsp *LSym - Pcfile *LSym - Pcline *LSym - Pcinline *LSym - Pcdata []*LSym - Funcdata []*LSym - Funcdataoff []int64 - UsedFiles map[goobj.CUFileIndex]struct{} // file indices used while generating pcfile - InlTree InlTree // per-function inlining tree extracted from the global tree + Pcsp *LSym + Pcfile *LSym + Pcline *LSym + Pcinline *LSym + Pcdata []*LSym + Funcdata []*LSym + UsedFiles map[goobj.CUFileIndex]struct{} // file indices used while generating pcfile + InlTree InlTree // per-function inlining tree extracted from the global tree } type Reloc struct { diff --git a/src/cmd/internal/obj/objfile.go b/src/cmd/internal/obj/objfile.go index bed32198d7..3d8d69f069 100644 --- a/src/cmd/internal/obj/objfile.go +++ b/src/cmd/internal/obj/objfile.go @@ -671,10 +671,6 @@ func genFuncInfoSyms(ctxt *Link) { FuncFlag: fn.FuncFlag, } pc := &fn.Pcln - o.Funcdataoff = make([]uint32, len(pc.Funcdataoff)) - for i, x := range pc.Funcdataoff { - o.Funcdataoff[i] = uint32(x) - } i := 0 o.File = make([]goobj.CUFileIndex, len(pc.UsedFiles)) for f := range pc.UsedFiles { diff --git a/src/cmd/internal/obj/pcln.go b/src/cmd/internal/obj/pcln.go index 42c4a2a9d9..49b425b124 100644 --- a/src/cmd/internal/obj/pcln.go +++ b/src/cmd/internal/obj/pcln.go @@ -8,6 +8,7 @@ import ( "cmd/internal/goobj" "cmd/internal/objabi" "encoding/binary" + "fmt" "log" ) @@ -280,8 +281,6 @@ func linkpcln(ctxt *Link, cursym *LSym) { pcln.Pcdata = make([]*LSym, npcdata) pcln.Funcdata = make([]*LSym, nfuncdata) - pcln.Funcdataoff = make([]int64, nfuncdata) - pcln.Funcdataoff = pcln.Funcdataoff[:nfuncdata] pcln.Pcsp = funcpctab(ctxt, cursym, "pctospadj", pctospadj, nil) pcln.Pcfile = funcpctab(ctxt, cursym, "pctofile", pctofileline, pcln) @@ -351,12 +350,10 @@ func linkpcln(ctxt *Link, cursym *LSym) { continue } i := int(p.From.Offset) - pcln.Funcdataoff[i] = p.To.Offset - if p.To.Type != TYPE_CONST { - // TODO: Dedup. - //funcdata_bytes += p->to.sym->size; - pcln.Funcdata[i] = p.To.Sym + if p.To.Type != TYPE_MEM || p.To.Offset != 0 { + panic(fmt.Sprintf("bad funcdata: %v", p)) } + pcln.Funcdata[i] = p.To.Sym } } } |