Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions objdiff-core/src/arch/mips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,13 @@ impl ArchMips {
ignored_symbols.insert(obj_symbol.index().0);
// Only remove the prefixless symbols if we are on the Base side of the diff,
// to allow diffing against target objects that contain `.NON_MATCHING` markers.
if diff_side == DiffSide::Base
&& let Some(target_symbol) = object.symbol_by_name(prefix)
{
ignored_symbols.insert(target_symbol.index().0);
if diff_side == DiffSide::Base {
for candidate in object.symbols() {
let Ok(candidate_name) = candidate.name() else { continue };
if candidate_name == prefix {
ignored_symbols.insert(candidate.index().0);
}
}
}
}
}
Expand Down
26 changes: 26 additions & 0 deletions objdiff-core/tests/arch_mips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,29 @@ fn ee_gcc_mdebug_line_numbers() {
assert_eq!(text_section.line_info.get(&144), Some(&13));
assert_eq!(text_section.line_info.len(), 10);
}

#[test]
#[cfg(feature = "mips")]
fn filter_non_matching_with_undef_symbol() {
let diff_config = diff::DiffObjConfig::default();
let obj = obj::read::parse(
include_object!("data/mips/non_matching_undef.o"),
&diff_config,
diff::DiffSide::Base,
)
.unwrap();

let defined_foo = obj
.symbols
.iter()
.find(|s| s.name == "foo" && s.section.is_some())
.expect("defined foo symbol present");
assert!(
defined_foo.flags.contains(obj::SymbolFlag::Ignored),
"defined foo symbol should be ignored when a same-named undefined symbol exists"
);

let marker =
obj.symbols.iter().find(|s| s.name == "foo.NON_MATCHING").expect("marker symbol present");
assert!(marker.flags.contains(obj::SymbolFlag::Ignored));
}
Binary file added objdiff-core/tests/data/mips/non_matching_undef.o
Binary file not shown.
Loading