diff --git a/objdiff-core/src/obj/read.rs b/objdiff-core/src/obj/read.rs index 082e689b..ad231c5f 100644 --- a/objdiff-core/src/obj/read.rs +++ b/objdiff-core/src/obj/read.rs @@ -824,19 +824,16 @@ fn combine_sections( config: &DiffObjConfig, ) -> Result<()> { let mut data_sections = BTreeMap::>::new(); - let mut text_sections = Vec::::new(); + let mut text_sections = BTreeMap::>::new(); for (i, section) in sections.iter().enumerate() { + let base_name = + if let Some(i) = section.name.rfind('$') { §ion.name[..i] } else { §ion.name }; match section.kind { SectionKind::Data | SectionKind::Bss => { - let base_name = if let Some(i) = section.name.rfind('$') { - §ion.name[..i] - } else { - §ion.name - }; data_sections.entry(base_name.to_string()).or_default().push(i); } SectionKind::Code => { - text_sections.push(i); + text_sections.entry(base_name.to_string()).or_default().push(i); } _ => {} } @@ -847,7 +844,9 @@ fn combine_sections( } } if config.combine_text_sections { - do_combine_sections(sections, symbols, &mut text_sections, ".text".to_string())?; + for (combined_name, mut section_indices) in text_sections { + do_combine_sections(sections, symbols, &mut section_indices, combined_name)?; + } } Ok(()) }