aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/symtab.go
diff options
context:
space:
mode:
authorKatie Hockman <katie@golang.org>2020-12-14 10:03:05 -0500
committerKatie Hockman <katie@golang.org>2020-12-14 10:06:13 -0500
commit0345ede87ee12698988973884cfc0fd3d499dffd (patch)
tree7123cff141ee5661208d2f5f437b8f5252ac7f6a /src/runtime/symtab.go
parent4651d6b267818b0e0d128a5443289717c4bb8cbc (diff)
parent0a02371b0576964e81c3b40d328db9a3ef3b031b (diff)
downloadgo-0345ede87ee12698988973884cfc0fd3d499dffd.tar.xz
[dev.fuzz] all: merge master into dev.fuzz
Change-Id: I5d8c8329ccc9d747bd81ade6b1cb7cb8ae2e94b2
Diffstat (limited to 'src/runtime/symtab.go')
-rw-r--r--src/runtime/symtab.go78
1 files changed, 50 insertions, 28 deletions
diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go
index fa8d17035e..7667f23f1d 100644
--- a/src/runtime/symtab.go
+++ b/src/runtime/symtab.go
@@ -268,25 +268,20 @@ func (f *Func) funcInfo() funcInfo {
//
// See funcdata.h and ../cmd/internal/objabi/funcdata.go.
const (
- _PCDATA_RegMapIndex = 0 // if !go115ReduceLiveness
- _PCDATA_UnsafePoint = 0 // if go115ReduceLiveness
+ _PCDATA_UnsafePoint = 0
_PCDATA_StackMapIndex = 1
_PCDATA_InlTreeIndex = 2
_FUNCDATA_ArgsPointerMaps = 0
_FUNCDATA_LocalsPointerMaps = 1
- _FUNCDATA_RegPointerMaps = 2 // if !go115ReduceLiveness
- _FUNCDATA_StackObjects = 3
- _FUNCDATA_InlTree = 4
- _FUNCDATA_OpenCodedDeferInfo = 5
+ _FUNCDATA_StackObjects = 2
+ _FUNCDATA_InlTree = 3
+ _FUNCDATA_OpenCodedDeferInfo = 4
_ArgsSizeUnknown = -0x80000000
)
const (
- // Only if !go115ReduceLiveness.
- _PCDATA_RegMapUnsafe = _PCDATA_UnsafePointUnsafe // Unsafe for async preemption
-
// PCDATA_UnsafePoint values.
_PCDATA_UnsafePointSafe = -1 // Safe for async preemption
_PCDATA_UnsafePointUnsafe = -2 // Unsafe for async preemption
@@ -326,7 +321,7 @@ const (
funcID_gcBgMarkWorker
funcID_systemstack_switch
funcID_systemstack
- funcID_cgocallback_gofunc
+ funcID_cgocallback
funcID_gogo
funcID_externalthreadhandler
funcID_debugCallV1
@@ -337,14 +332,18 @@ const (
funcID_wrapper // any autogenerated code (hash/eq algorithms, method wrappers, etc.)
)
-// PCHeader holds data used by the pclntab lookups.
+// pcHeader holds data used by the pclntab lookups.
type pcHeader struct {
magic uint32 // 0xFFFFFFFA
pad1, pad2 uint8 // 0,0
minLC uint8 // min instruction size
ptrSize uint8 // size of a ptr in bytes
nfunc int // number of functions in the module
+ nfiles uint // number of entries in the file tab.
funcnameOffset uintptr // offset to the funcnametab variable from pcHeader
+ cuOffset uintptr // offset to the cutab variable from pcHeader
+ filetabOffset uintptr // offset to the filetab variable from pcHeader
+ pctabOffset uintptr // offset to the pctab varible from pcHeader
pclnOffset uintptr // offset to the pclntab variable from pcHeader
}
@@ -356,9 +355,11 @@ type pcHeader struct {
type moduledata struct {
pcHeader *pcHeader
funcnametab []byte
+ cutab []uint32
+ filetab []byte
+ pctab []byte
pclntable []byte
ftab []functab
- filetab []uint32
findfunctab uintptr
minpc, maxpc uintptr
@@ -720,7 +721,7 @@ type pcvalueCache struct {
type pcvalueCacheEnt struct {
// targetpc and off together are the key of this cache entry.
targetpc uintptr
- off int32
+ off uint32
// val is the value of this cached pcvalue entry.
val int32
}
@@ -735,7 +736,7 @@ func pcvalueCacheKey(targetpc uintptr) uintptr {
// Returns the PCData value, and the PC where this value starts.
// TODO: the start PC is returned only when cache is nil.
-func pcvalue(f funcInfo, off int32, targetpc uintptr, cache *pcvalueCache, strict bool) (int32, uintptr) {
+func pcvalue(f funcInfo, off uint32, targetpc uintptr, cache *pcvalueCache, strict bool) (int32, uintptr) {
if off == 0 {
return -1, 0
}
@@ -769,7 +770,7 @@ func pcvalue(f funcInfo, off int32, targetpc uintptr, cache *pcvalueCache, stric
return -1, 0
}
datap := f.datap
- p := datap.pclntable[off:]
+ p := datap.pctab[off:]
pc := f.entry
prevpc := pc
val := int32(-1)
@@ -811,7 +812,7 @@ func pcvalue(f funcInfo, off int32, targetpc uintptr, cache *pcvalueCache, stric
print("runtime: invalid pc-encoded table f=", funcname(f), " pc=", hex(pc), " targetpc=", hex(targetpc), " tab=", p, "\n")
- p = datap.pclntable[off:]
+ p = datap.pctab[off:]
pc = f.entry
val = -1
for {
@@ -838,6 +839,22 @@ func funcname(f funcInfo) string {
return gostringnocopy(cfuncname(f))
}
+func funcpkgpath(f funcInfo) string {
+ name := funcname(f)
+ i := len(name) - 1
+ for ; i > 0; i-- {
+ if name[i] == '/' {
+ break
+ }
+ }
+ for ; i < len(name); i++ {
+ if name[i] == '.' {
+ break
+ }
+ }
+ return name[:i]
+}
+
func cfuncnameFromNameoff(f funcInfo, nameoff int32) *byte {
if !f.valid() {
return nil
@@ -854,7 +871,12 @@ func funcfile(f funcInfo, fileno int32) string {
if !f.valid() {
return "?"
}
- return gostringnocopy(&datap.pclntable[datap.filetab[fileno]])
+ // Make sure the cu index and file offset are valid
+ if fileoff := datap.cutab[f.cuOffset+uint32(fileno)]; fileoff != ^uint32(0) {
+ return gostringnocopy(&datap.filetab[fileoff])
+ }
+ // pcln section is corrupt.
+ return "?"
}
func funcline1(f funcInfo, targetpc uintptr, strict bool) (file string, line int32) {
@@ -868,7 +890,7 @@ func funcline1(f funcInfo, targetpc uintptr, strict bool) (file string, line int
// print("looking for ", hex(targetpc), " in ", funcname(f), " got file=", fileno, " line=", lineno, "\n")
return "?", 0
}
- file = gostringnocopy(&datap.pclntable[datap.filetab[fileno]])
+ file = funcfile(f, fileno)
return
}
@@ -887,7 +909,7 @@ func funcspdelta(f funcInfo, targetpc uintptr, cache *pcvalueCache) int32 {
// funcMaxSPDelta returns the maximum spdelta at any point in f.
func funcMaxSPDelta(f funcInfo) int32 {
datap := f.datap
- p := datap.pclntable[f.pcsp:]
+ p := datap.pctab[f.pcsp:]
pc := f.entry
val := int32(-1)
max := int32(0)
@@ -903,20 +925,20 @@ func funcMaxSPDelta(f funcInfo) int32 {
}
}
-func pcdatastart(f funcInfo, table int32) int32 {
- return *(*int32)(add(unsafe.Pointer(&f.nfuncdata), unsafe.Sizeof(f.nfuncdata)+uintptr(table)*4))
+func pcdatastart(f funcInfo, table uint32) uint32 {
+ return *(*uint32)(add(unsafe.Pointer(&f.nfuncdata), unsafe.Sizeof(f.nfuncdata)+uintptr(table)*4))
}
-func pcdatavalue(f funcInfo, table int32, targetpc uintptr, cache *pcvalueCache) int32 {
- if table < 0 || table >= f.npcdata {
+func pcdatavalue(f funcInfo, table uint32, targetpc uintptr, cache *pcvalueCache) int32 {
+ if table >= f.npcdata {
return -1
}
r, _ := pcvalue(f, pcdatastart(f, table), targetpc, cache, true)
return r
}
-func pcdatavalue1(f funcInfo, table int32, targetpc uintptr, cache *pcvalueCache, strict bool) int32 {
- if table < 0 || table >= f.npcdata {
+func pcdatavalue1(f funcInfo, table uint32, targetpc uintptr, cache *pcvalueCache, strict bool) int32 {
+ if table >= f.npcdata {
return -1
}
r, _ := pcvalue(f, pcdatastart(f, table), targetpc, cache, strict)
@@ -925,8 +947,8 @@ func pcdatavalue1(f funcInfo, table int32, targetpc uintptr, cache *pcvalueCache
// Like pcdatavalue, but also return the start PC of this PCData value.
// It doesn't take a cache.
-func pcdatavalue2(f funcInfo, table int32, targetpc uintptr) (int32, uintptr) {
- if table < 0 || table >= f.npcdata {
+func pcdatavalue2(f funcInfo, table uint32, targetpc uintptr) (int32, uintptr) {
+ if table >= f.npcdata {
return -1, 0
}
return pcvalue(f, pcdatastart(f, table), targetpc, nil, true)
@@ -1008,7 +1030,7 @@ type inlinedCall struct {
parent int16 // index of parent in the inltree, or < 0
funcID funcID // type of the called function
_ byte
- file int32 // fileno index into filetab
+ file int32 // perCU file index for inlined call. See cmd/link:pcln.go
line int32 // line number of the call site
func_ int32 // offset into pclntab for name of called function
parentPc int32 // position of an instruction whose source position is the call site (offset from entry)