MCPcopy Index your code
hub / github.com/encounter/objdiff / map_relocations

Function map_relocations

objdiff-core/src/obj/read.rs:597–638  ·  view source on GitHub ↗
(
    arch: &dyn Arch,
    obj_file: &object::File,
    sections: &mut [Section],
    section_indices: &[usize],
    symbol_indices: &[usize],
)

Source from the content-addressed store, hash-verified

595}
596
597fn map_relocations(
598 arch: &dyn Arch,
599 obj_file: &object::File,
600 sections: &mut [Section],
601 section_indices: &[usize],
602 symbol_indices: &[usize],
603) -> Result<()> {
604 // Generate a list of symbols for each section
605 let mut ordered_symbols =
606 Vec::<Vec<object::Symbol>>::with_capacity(obj_file.sections().count() + 1);
607 for symbol in obj_file.symbols() {
608 let Some(section_index) = symbol.section_index() else {
609 continue;
610 };
611 if symbol.kind() == object::SymbolKind::Section {
612 continue;
613 }
614 if section_index.0 >= ordered_symbols.len() {
615 ordered_symbols.resize_with(section_index.0 + 1, Vec::new);
616 }
617 ordered_symbols[section_index.0].push(symbol);
618 }
619 // Sort symbols by address and size
620 for vec in &mut ordered_symbols {
621 vec.sort_by(|a, b| a.address().cmp(&b.address()).then(a.size().cmp(&b.size())));
622 }
623 // Map relocations for each section. Section-relative relocations use the ordered symbols list
624 // to find a better target symbol, if available.
625 for obj_section in obj_file.sections() {
626 let section = &mut sections[section_indices[obj_section.index().0]];
627 if section.kind != SectionKind::Unknown {
628 section.relocations = map_section_relocations(
629 arch,
630 obj_file,
631 &obj_section,
632 symbol_indices,
633 &ordered_symbols,
634 )?;
635 }
636 }
637 Ok(())
638}
639
640fn perform_data_flow_analysis(obj: &mut Object, config: &DiffObjConfig) -> Result<()> {
641 // If neither of these settings are on, no flow analysis to perform

Callers 1

parseFunction · 0.85

Calls 4

map_section_relocationsFunction · 0.85
pushMethod · 0.80
cmpMethod · 0.80
indexMethod · 0.80

Tested by

no test coverage detected