FindTextProgHeader finds the program segment header containing the .text section or nil if the segment cannot be found.
(f *elf.File)
| 285 | // FindTextProgHeader finds the program segment header containing the .text |
| 286 | // section or nil if the segment cannot be found. |
| 287 | func FindTextProgHeader(f *elf.File) *elf.ProgHeader { |
| 288 | for _, s := range f.Sections { |
| 289 | if s.Name == ".text" { |
| 290 | // Find the LOAD segment containing the .text section. |
| 291 | for _, p := range f.Progs { |
| 292 | if p.Type == elf.PT_LOAD && p.Flags&elf.PF_X != 0 && s.Addr >= p.Vaddr && s.Addr < p.Vaddr+p.Memsz { |
| 293 | return &p.ProgHeader |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | return nil |
| 299 | } |
| 300 | |
| 301 | // ProgramHeadersForMapping returns the program segment headers that overlap |
| 302 | // the runtime mapping with file offset mapOff and memory size mapSz. We skip |
no outgoing calls
no test coverage detected
searching dependent graphs…