Fix section ordering with many same-named sections

Before, this was comparing, for example, `.text-2`
with `.text-10` with standard string comparison,
yielding `.text-10` before `.text-2`.

Instead, this simply uses a stable sort by name,
which preserves the relative ordering of sections.
This commit is contained in:
2025-03-10 21:51:54 -06:00
parent ffb38d1bb0
commit 5898d7aebf
4 changed files with 227 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
use objdiff_core::{diff, obj};
use objdiff_core::{diff, diff::display::SymbolFilter, obj};
mod common;
@@ -40,3 +40,18 @@ fn read_x86_64() {
let output = common::display_diff(&obj, &diff, symbol_idx, &diff_config);
insta::assert_snapshot!(output);
}
#[test]
#[cfg(feature = "x86")]
fn display_section_ordering() {
let diff_config = diff::DiffObjConfig::default();
let obj = obj::read::parse(include_object!("data/x86/basenode.obj"), &diff_config).unwrap();
let obj_diff =
diff::diff_objs(Some(&obj), None, None, &diff_config, &diff::MappingConfig::default())
.unwrap()
.left
.unwrap();
let section_display =
diff::display::display_sections(&obj, &obj_diff, SymbolFilter::None, false, false, false);
insta::assert_debug_snapshot!(section_display);
}