@@ -211,25 +211,25 @@ fn address_eq(left: &ObjSymbol, right: &ObjSymbol) -> bool {
211
211
}
212
212
213
213
fn reloc_eq ( left_reloc : Option < & ObjReloc > , right_reloc : Option < & ObjReloc > ) -> bool {
214
- if let ( Some ( left) , Some ( right) ) = ( left_reloc, right_reloc) {
215
- if left. kind != right. kind {
216
- return false ;
214
+ let ( Some ( left) , Some ( right) ) = ( left_reloc, right_reloc) else {
215
+ return false ;
216
+ } ;
217
+ if left. kind != right. kind {
218
+ return false ;
219
+ }
220
+
221
+ let name_matches = left. target . name == right. target . name ;
222
+ match ( & left. target_section , & right. target_section ) {
223
+ ( Some ( sl) , Some ( sr) ) => {
224
+ // Match if section and name or address match
225
+ sl == sr && ( name_matches || address_eq ( & left. target , & right. target ) )
217
226
}
218
- let name_matches = left. target . name == right. target . name ;
219
- match ( & left. target_section , & right. target_section ) {
220
- ( Some ( sl) , Some ( sr) ) => {
221
- // Match if section and name or address match
222
- sl == sr && ( name_matches || address_eq ( & left. target , & right. target ) )
223
- }
224
- ( Some ( _) , None ) => false ,
225
- ( None , Some ( _) ) => {
226
- // Match if possibly stripped weak symbol
227
- name_matches && right. target . flags . 0 . contains ( ObjSymbolFlags :: Weak )
228
- }
229
- ( None , None ) => name_matches,
227
+ ( Some ( _) , None ) => false ,
228
+ ( None , Some ( _) ) => {
229
+ // Match if possibly stripped weak symbol
230
+ name_matches && right. target . flags . 0 . contains ( ObjSymbolFlags :: Weak )
230
231
}
231
- } else {
232
- false
232
+ ( None , None ) => name_matches,
233
233
}
234
234
}
235
235
@@ -363,48 +363,49 @@ fn find_symbol<'a>(symbols: &'a mut [ObjSymbol], name: &str) -> Option<&'a mut O
363
363
364
364
pub fn diff_objs ( left : & mut ObjInfo , right : & mut ObjInfo , _diff_config : & DiffConfig ) -> Result < ( ) > {
365
365
for left_section in & mut left. sections {
366
- if let Some ( right_section) = find_section ( right, & left_section. name ) {
367
- if left_section. kind == ObjSectionKind :: Code {
368
- for left_symbol in & mut left_section. symbols {
369
- if let Some ( right_symbol) =
370
- find_symbol ( & mut right_section. symbols , & left_symbol. name )
371
- {
372
- left_symbol. diff_symbol = Some ( right_symbol. name . clone ( ) ) ;
373
- right_symbol. diff_symbol = Some ( left_symbol. name . clone ( ) ) ;
374
- diff_code (
375
- left. architecture ,
376
- & left_section. data ,
377
- & right_section. data ,
378
- left_symbol,
379
- right_symbol,
380
- & left_section. relocations ,
381
- & right_section. relocations ,
382
- ) ?;
383
- } else {
384
- no_diff_code (
385
- left. architecture ,
386
- & left_section. data ,
387
- left_symbol,
388
- & left_section. relocations ,
389
- ) ?;
390
- }
366
+ let Some ( right_section) = find_section ( right, & left_section. name ) else {
367
+ continue ;
368
+ } ;
369
+ if left_section. kind == ObjSectionKind :: Code {
370
+ for left_symbol in & mut left_section. symbols {
371
+ if let Some ( right_symbol) =
372
+ find_symbol ( & mut right_section. symbols , & left_symbol. name )
373
+ {
374
+ left_symbol. diff_symbol = Some ( right_symbol. name . clone ( ) ) ;
375
+ right_symbol. diff_symbol = Some ( left_symbol. name . clone ( ) ) ;
376
+ diff_code (
377
+ left. architecture ,
378
+ & left_section. data ,
379
+ & right_section. data ,
380
+ left_symbol,
381
+ right_symbol,
382
+ & left_section. relocations ,
383
+ & right_section. relocations ,
384
+ ) ?;
385
+ } else {
386
+ no_diff_code (
387
+ left. architecture ,
388
+ & left_section. data ,
389
+ left_symbol,
390
+ & left_section. relocations ,
391
+ ) ?;
391
392
}
392
- for right_symbol in & mut right_section . symbols {
393
- if right_symbol . instructions . is_empty ( ) {
394
- no_diff_code (
395
- left . architecture ,
396
- & right_section . data ,
397
- right_symbol ,
398
- & right_section . relocations ,
399
- ) ? ;
400
- }
393
+ }
394
+ for right_symbol in & mut right_section . symbols {
395
+ if right_symbol . instructions . is_empty ( ) {
396
+ no_diff_code (
397
+ left . architecture ,
398
+ & right_section . data ,
399
+ right_symbol ,
400
+ & right_section . relocations ,
401
+ ) ? ;
401
402
}
402
- } else if left_section. kind == ObjSectionKind :: Data {
403
- diff_data ( left_section, right_section) ;
404
- // diff_data_symbols(left_section, right_section)?;
405
- } else if left_section. kind == ObjSectionKind :: Bss {
406
- diff_bss_symbols ( & mut left_section. symbols , & mut right_section. symbols ) ?;
407
403
}
404
+ } else if left_section. kind == ObjSectionKind :: Data {
405
+ diff_data ( left_section, right_section) ;
406
+ // diff_data_symbols(left_section, right_section)?;
407
+ } else if left_section. kind == ObjSectionKind :: Bss {
408
+ diff_bss_symbols ( & mut left_section. symbols , & mut right_section. symbols ) ?;
408
409
}
409
410
}
410
411
diff_bss_symbols ( & mut left. common , & mut right. common ) ?;
0 commit comments