[MIPS] Fix symbols being filtered out from target side of diff if target object contains .NON_MATCHING markers (#250)

* Fix filtering out symbols from the target side that have a symbol with the same name and a `.NON_MATCHING` suffix.

- Target side: Show all the symbols except the `.NON_MATCHING` ones.
- Base side: Ignore all the `.NON_MATCHING` symbols and also ignore the ones with the same name without the suffix

* fmt

* comment

* tests

* fmt tests

* maybe this could fix wasm?

* Fix wasm?

* fmt

* Move `DiffSide` to `diff` mod

* Update the stuff the advisories CI told me to
This commit is contained in:
Anghelo Carvajal
2025-09-02 21:13:29 -04:00
committed by GitHub
parent a138dfa907
commit 6fb4bb8855
13 changed files with 169 additions and 44 deletions

View File

@@ -6,7 +6,9 @@ mod common;
#[cfg(feature = "mips")]
fn read_mips() {
let diff_config = diff::DiffObjConfig { mips_register_prefix: true, ..Default::default() };
let obj = obj::read::parse(include_object!("data/mips/main.c.o"), &diff_config).unwrap();
let obj =
obj::read::parse(include_object!("data/mips/main.c.o"), &diff_config, diff::DiffSide::Base)
.unwrap();
insta::assert_debug_snapshot!(obj);
let symbol_idx = obj.symbols.iter().position(|s| s.name == "ControlEntry").unwrap();
let diff = diff::code::no_diff_code(&obj, symbol_idx, &diff_config).unwrap();
@@ -19,9 +21,19 @@ fn read_mips() {
#[cfg(feature = "mips")]
fn cross_endian_diff() {
let diff_config = diff::DiffObjConfig::default();
let obj_be = obj::read::parse(include_object!("data/mips/code_be.o"), &diff_config).unwrap();
let obj_be = obj::read::parse(
include_object!("data/mips/code_be.o"),
&diff_config,
diff::DiffSide::Base,
)
.unwrap();
assert_eq!(obj_be.endianness, object::Endianness::Big);
let obj_le = obj::read::parse(include_object!("data/mips/code_le.o"), &diff_config).unwrap();
let obj_le = obj::read::parse(
include_object!("data/mips/code_le.o"),
&diff_config,
diff::DiffSide::Base,
)
.unwrap();
assert_eq!(obj_le.endianness, object::Endianness::Little);
let left_symbol_idx = obj_be.symbols.iter().position(|s| s.name == "func_00000000").unwrap();
let right_symbol_idx =
@@ -42,6 +54,11 @@ fn cross_endian_diff() {
#[cfg(feature = "mips")]
fn filter_non_matching() {
let diff_config = diff::DiffObjConfig::default();
let obj = obj::read::parse(include_object!("data/mips/vw_main.c.o"), &diff_config).unwrap();
let obj = obj::read::parse(
include_object!("data/mips/vw_main.c.o"),
&diff_config,
diff::DiffSide::Base,
)
.unwrap();
insta::assert_debug_snapshot!(obj.symbols);
}