@@ -6,7 +6,7 @@ use std::{
6
6
use anyhow:: { anyhow, Result } ;
7
7
use similar:: { capture_diff_slices_deadline, get_diff_ratio, Algorithm } ;
8
8
9
- use super :: code:: section_name_eq;
9
+ use super :: code:: { address_eq , section_name_eq} ;
10
10
use crate :: {
11
11
diff:: { ObjDataDiff , ObjDataDiffKind , ObjDataRelocDiff , ObjSectionDiff , ObjSymbolDiff } ,
12
12
obj:: { ObjInfo , ObjReloc , ObjSection , ObjSymbolFlags , SymbolRef } ,
@@ -41,39 +41,25 @@ pub fn no_diff_symbol(_obj: &ObjInfo, symbol_ref: SymbolRef) -> ObjSymbolDiff {
41
41
ObjSymbolDiff { symbol_ref, target_symbol : None , instructions : vec ! [ ] , match_percent : None }
42
42
}
43
43
44
- fn address_eq ( left : & ObjReloc , right : & ObjReloc ) -> bool {
45
- if right. target . size == 0 && left. target . size != 0 {
46
- // The base relocation is against a pool but the target relocation isn't.
47
- // This can happen in rare cases where the compiler will generate a pool+addend relocation
48
- // in the base, but the one detected in the target is direct with no addend.
49
- // Just check that the final address is the same so these count as a match.
50
- left. target . address as i64 + left. addend == right. target . address as i64 + right. addend
51
- } else {
52
- // But otherwise, if the compiler isn't using a pool, we're more strict and check that the
53
- // target symbol address and relocation addend both match exactly.
54
- left. target . address == right. target . address && left. addend == right. addend
55
- }
56
- }
57
-
58
44
fn reloc_eq ( left_obj : & ObjInfo , right_obj : & ObjInfo , left : & ObjReloc , right : & ObjReloc ) -> bool {
59
45
if left. flags != right. flags {
60
46
return false ;
61
47
}
62
48
63
- let symbol_name_matches = left. target . name == right. target . name ;
49
+ let symbol_name_addend_matches =
50
+ left. target . name == right. target . name && left. addend == right. addend ;
64
51
match ( & left. target . orig_section_index , & right. target . orig_section_index ) {
65
52
( Some ( sl) , Some ( sr) ) => {
66
53
// Match if section and name+addend or address match
67
54
section_name_eq ( left_obj, right_obj, * sl, * sr)
68
- && ( ( symbol_name_matches && left . addend == right . addend ) || address_eq ( left, right) )
55
+ && ( symbol_name_addend_matches || address_eq ( left, right) )
69
56
}
70
57
( Some ( _) , None ) => false ,
71
58
( None , Some ( _) ) => {
72
59
// Match if possibly stripped weak symbol
73
- ( symbol_name_matches && left. addend == right. addend )
74
- && right. target . flags . 0 . contains ( ObjSymbolFlags :: Weak )
60
+ symbol_name_addend_matches && right. target . flags . 0 . contains ( ObjSymbolFlags :: Weak )
75
61
}
76
- ( None , None ) => symbol_name_matches ,
62
+ ( None , None ) => symbol_name_addend_matches ,
77
63
}
78
64
}
79
65
0 commit comments