From 88bd86b2e0cb7198f01e655961152afecc11a285 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Thu, 18 Dec 2025 14:35:47 -0500 Subject: [PATCH] Combine .init sections separately from .text sections --- objdiff-core/src/obj/read.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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(()) }