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

Function combine_sections

objdiff-core/src/obj/read.rs:890–925  ·  view source on GitHub ↗
(
    sections: &mut [Section],
    symbols: &mut [Symbol],
    config: &DiffObjConfig,
)

Source from the content-addressed store, hash-verified

888}
889
890fn combine_sections(
891 sections: &mut [Section],
892 symbols: &mut [Symbol],
893 config: &DiffObjConfig,
894) -> Result<()> {
895 let mut data_sections = BTreeMap::<String, Vec<usize>>::new();
896 let mut text_sections = BTreeMap::<String, Vec<usize>>::new();
897 for (i, section) in sections.iter().enumerate() {
898 let base_name = section
899 .name
900 .get(1..)
901 .and_then(|s| s.rfind(['$', '.']))
902 .and_then(|i| section.name.get(..i + 1))
903 .unwrap_or(&section.name);
904 match section.kind {
905 SectionKind::Data | SectionKind::Bss => {
906 data_sections.entry(base_name.to_string()).or_default().push(i);
907 }
908 SectionKind::Code => {
909 text_sections.entry(base_name.to_string()).or_default().push(i);
910 }
911 _ => {}
912 }
913 }
914 if config.combine_data_sections {
915 for (combined_name, mut section_indices) in data_sections {
916 do_combine_sections(sections, symbols, &mut section_indices, combined_name)?;
917 }
918 }
919 if config.combine_text_sections {
920 for (combined_name, mut section_indices) in text_sections {
921 do_combine_sections(sections, symbols, &mut section_indices, combined_name)?;
922 }
923 }
924 Ok(())
925}
926
927fn do_combine_sections(
928 sections: &mut [Section],

Callers 1

parseFunction · 0.85

Calls 3

do_combine_sectionsFunction · 0.85
getMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected