mirror of
https://github.com/golang/go
synced 2024-11-17 04:04:46 -07:00
cmd/link: make funcSize a constant
Now that it no longer depends on the size of a pointer, we can make it a constant, which simplifies a bit of code. Change-Id: I1b7c3b1b648da5c8960378a02b9263e2cc902441 Reviewed-on: https://go-review.googlesource.com/c/go/+/352952 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
d3ad216f8e
commit
2d6d558417
@ -17,11 +17,10 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
const funcSize = 10 * 4 // funcSize is the size of the _func object in runtime/runtime2.go
|
||||
|
||||
// pclntab holds the state needed for pclntab generation.
|
||||
type pclntab struct {
|
||||
// The size of the func object in the runtime.
|
||||
funcSize uint32
|
||||
|
||||
// The first and last functions found.
|
||||
firstFunc, lastFunc loader.Sym
|
||||
|
||||
@ -69,11 +68,7 @@ func (state *pclntab) addGeneratedSym(ctxt *Link, name string, size int64, f gen
|
||||
// generate pclntab.
|
||||
func makePclntab(ctxt *Link, container loader.Bitmap) (*pclntab, []*sym.CompilationUnit, []loader.Sym) {
|
||||
ldr := ctxt.loader
|
||||
|
||||
state := &pclntab{
|
||||
// This is the size of the _func object in runtime/runtime2.go.
|
||||
funcSize: 10 * 4,
|
||||
}
|
||||
state := new(pclntab)
|
||||
|
||||
// Gather some basic stats and info.
|
||||
seenCUs := make(map[*sym.CompilationUnit]struct{})
|
||||
@ -671,7 +666,7 @@ func (state pclntab) calculateFunctabSize(ctxt *Link, funcs []loader.Sym) (int64
|
||||
size = Rnd(size, int64(ctxt.Arch.PtrSize))
|
||||
startLocations[i] = uint32(size)
|
||||
fi := ldr.FuncInfo(s)
|
||||
size += int64(state.funcSize)
|
||||
size += funcSize
|
||||
if fi.Valid() {
|
||||
fi.Preload()
|
||||
numFuncData := ldr.NumFuncdata(s)
|
||||
@ -748,7 +743,7 @@ func (state *pclntab) writeFuncData(ctxt *Link, sb *loader.SymbolBuilder, funcs
|
||||
// Missing funcdata will be 0 (nil pointer).
|
||||
funcdata = funcData(ldr, s, fi, inlSyms[s], funcdata)
|
||||
if len(funcdata) > 0 {
|
||||
off := int64(startLocations[i] + state.funcSize + numPCData(ldr, s, fi)*4)
|
||||
off := int64(startLocations[i] + funcSize + numPCData(ldr, s, fi)*4)
|
||||
off = Rnd(off, int64(ctxt.Arch.PtrSize))
|
||||
for j := range funcdata {
|
||||
dataoff := off + int64(ctxt.Arch.PtrSize*j)
|
||||
|
Loading…
Reference in New Issue
Block a user