Skip to content

Commit f8e7478

Browse files
committed
Fix data reloc diffing when the reloc points to an in-function static symbol
1 parent 88cc76d commit f8e7478

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

objdiff-core/src/diff/data.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@ pub fn diff_bss_symbol(
3535
))
3636
}
3737

38+
fn symbol_name_matches(left_name: &str, right_name: &str) -> bool {
39+
// Match Metrowerks symbol$1234 against symbol$2345
40+
if let Some((prefix, suffix)) = left_name.split_once('$') {
41+
if !suffix.chars().all(char::is_numeric) {
42+
return false;
43+
}
44+
if let Some((p, s)) = right_name.split_once('$') {
45+
prefix == p && s.chars().all(char::is_numeric)
46+
} else {
47+
false
48+
}
49+
} else {
50+
left_name == right_name
51+
}
52+
}
53+
3854
fn reloc_eq(
3955
left_obj: &Object,
4056
right_obj: &Object,
@@ -45,8 +61,8 @@ fn reloc_eq(
4561
return false;
4662
}
4763

48-
let symbol_name_addend_matches =
49-
left.symbol.name == right.symbol.name && left.relocation.addend == right.relocation.addend;
64+
let symbol_name_addend_matches = symbol_name_matches(&left.symbol.name, &right.symbol.name)
65+
&& left.relocation.addend == right.relocation.addend;
5066
match (left.symbol.section, right.symbol.section) {
5167
(Some(sl), Some(sr)) => {
5268
// Match if section and name+addend or address match

0 commit comments

Comments
 (0)