aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/symtab.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go
index 87b4eeb220..6236643ceb 100644
--- a/src/runtime/symtab.go
+++ b/src/runtime/symtab.go
@@ -273,7 +273,22 @@ func (f *Func) raw() *_func {
func (f *Func) funcInfo() funcInfo {
fn := f.raw()
- return funcInfo{fn, findmoduledatap(fn.entry)}
+ // Find the module containing fn. fn is located in the pclntable.
+ // The unsafe.Pointer to uintptr conversions and arithmetic
+ // are safe because we are working with module addresses.
+ ptr := uintptr(unsafe.Pointer(fn))
+ var mod *moduledata
+ for datap := &firstmoduledata; datap != nil; datap = datap.next {
+ if len(datap.pclntable) == 0 {
+ continue
+ }
+ base := uintptr(unsafe.Pointer(&datap.pclntable[0]))
+ if base <= ptr && ptr < base+uintptr(len(datap.pclntable)) {
+ mod = datap
+ break
+ }
+ }
+ return funcInfo{fn, mod}
}
// PCDATA and FUNCDATA table indexes.