HeaderForFileOffset attempts to identify a unique program header that includes the given file offset. It returns an error if it cannot identify a unique header.
(headers []*elf.ProgHeader, fileOffset uint64)
| 356 | // includes the given file offset. It returns an error if it cannot identify a |
| 357 | // unique header. |
| 358 | func HeaderForFileOffset(headers []*elf.ProgHeader, fileOffset uint64) (*elf.ProgHeader, error) { |
| 359 | var ph *elf.ProgHeader |
| 360 | for _, h := range headers { |
| 361 | if fileOffset >= h.Off && fileOffset < h.Off+h.Memsz { |
| 362 | if ph != nil { |
| 363 | // Assuming no other bugs, this can only happen if we have two or |
| 364 | // more small program segments that fit on the same page, and a |
| 365 | // segment other than the last one includes uninitialized data, or |
| 366 | // if the debug binary used for symbolization is stripped of some |
| 367 | // sections, so segment file sizes are smaller than memory sizes. |
| 368 | return nil, fmt.Errorf("found second program header (%#v) that matches file offset %x, first program header is %#v. Is this a stripped binary, or does the first program segment contain uninitialized data?", *h, fileOffset, *ph) |
| 369 | } |
| 370 | ph = h |
| 371 | } |
| 372 | } |
| 373 | if ph == nil { |
| 374 | return nil, fmt.Errorf("no program header matches file offset %x", fileOffset) |
| 375 | } |
| 376 | return ph, nil |
| 377 | } |
no outgoing calls
searching dependent graphs…