MCPcopy Create free account
hub / github.com/google/pprof / computeBase

Method computeBase

internal/binutils/binutils.go:592–617  ·  view source on GitHub ↗

computeBase computes the relocation base for the given binary file only if the elfMapping field is set. It populates the base and isData fields and returns an error.

(addr uint64)

Source from the content-addressed store, hash-verified

590// the elfMapping field is set. It populates the base and isData fields and
591// returns an error.
592func (f *file) computeBase(addr uint64) error {
593 if f == nil || f.m == nil {
594 return nil
595 }
596 if addr < f.m.start || addr >= f.m.limit {
597 return fmt.Errorf("specified address %x is outside the mapping range [%x, %x] for file %q", addr, f.m.start, f.m.limit, f.name)
598 }
599 ef, err := elfOpen(f.name)
600 if err != nil {
601 return fmt.Errorf("error parsing %s: %v", f.name, err)
602 }
603 defer ef.Close()
604
605 ph, err := f.m.findProgramHeader(ef, addr)
606 if err != nil {
607 return fmt.Errorf("failed to find program header for file %q, ELF mapping %#v, address %x: %v", f.name, *f.m, addr, err)
608 }
609
610 base, err := elfexec.GetBase(&ef.FileHeader, ph, f.m.kernelOffset, f.m.start, f.m.limit, f.m.offset)
611 if err != nil {
612 return err
613 }
614 f.base = base
615 f.isData = ph != nil && ph.Flags&elf.PF_X == 0
616 return nil
617}
618
619func (f *file) Name() string {
620 return f.name

Callers 5

ObjAddrMethod · 0.95
SourceLineMethod · 0.95
TestComputeBaseFunction · 0.95
SourceLineMethod · 0.80
SourceLineMethod · 0.80

Calls 3

GetBaseFunction · 0.92
findProgramHeaderMethod · 0.80
CloseMethod · 0.65

Tested by 1

TestComputeBaseFunction · 0.76