loadRelocations iterates .rel* sections and extracts relocation entries for sections of interest. Makes sure relocations point at valid sections.
(relSections map[elf.SectionIndex]*elf.Section, symbols []elf.Symbol)
| 337 | // loadRelocations iterates .rel* sections and extracts relocation entries for |
| 338 | // sections of interest. Makes sure relocations point at valid sections. |
| 339 | func (ec *elfCode) loadRelocations(relSections map[elf.SectionIndex]*elf.Section, symbols []elf.Symbol) error { |
| 340 | for idx, relSection := range relSections { |
| 341 | section := ec.sections[idx] |
| 342 | if section == nil { |
| 343 | continue |
| 344 | } |
| 345 | |
| 346 | rels, err := ec.loadSectionRelocations(relSection, symbols) |
| 347 | if err != nil { |
| 348 | return fmt.Errorf("relocation for section %q: %w", section.Name, err) |
| 349 | } |
| 350 | |
| 351 | for _, rel := range rels { |
| 352 | target := ec.sections[rel.Section] |
| 353 | if target == nil { |
| 354 | return fmt.Errorf("section %q: reference to %q in section %s: %w", section.Name, rel.Name, rel.Section, ErrNotSupported) |
| 355 | } |
| 356 | |
| 357 | target.references++ |
| 358 | } |
| 359 | |
| 360 | section.relocations = rels |
| 361 | } |
| 362 | |
| 363 | return nil |
| 364 | } |
| 365 | |
| 366 | // loadProgramSections iterates ec's sections and emits a ProgramSpec |
| 367 | // for each function it finds. |
no test coverage detected