@@ -6,8 +6,8 @@ use crate::{
6
6
diff:: {
7
7
code:: { diff_code, no_diff_code, process_code_symbol} ,
8
8
data:: {
9
- diff_bss_symbol, diff_data_section, diff_data_symbol, diff_generic_section ,
10
- no_diff_symbol,
9
+ diff_bss_section , diff_bss_symbol, diff_data_section, diff_data_symbol,
10
+ diff_generic_section , no_diff_symbol,
11
11
} ,
12
12
} ,
13
13
obj:: { ObjInfo , ObjIns , ObjSection , ObjSectionKind , ObjSymbol , SymbolRef } ,
@@ -483,7 +483,7 @@ pub fn diff_objs(
483
483
let left_section = & left_obj. sections [ left_section_idx] ;
484
484
let right_section = & right_obj. sections [ right_section_idx] ;
485
485
match section_kind {
486
- ObjSectionKind :: Code | ObjSectionKind :: Bss => {
486
+ ObjSectionKind :: Code => {
487
487
let left_section_diff = left_out. section_diff ( left_section_idx) ;
488
488
let right_section_diff = right_out. section_diff ( right_section_idx) ;
489
489
let ( left_diff, right_diff) = diff_generic_section (
@@ -507,6 +507,18 @@ pub fn diff_objs(
507
507
left_out. section_diff_mut ( left_section_idx) . merge ( left_diff) ;
508
508
right_out. section_diff_mut ( right_section_idx) . merge ( right_diff) ;
509
509
}
510
+ ObjSectionKind :: Bss => {
511
+ let left_section_diff = left_out. section_diff ( left_section_idx) ;
512
+ let right_section_diff = right_out. section_diff ( right_section_idx) ;
513
+ let ( left_diff, right_diff) = diff_bss_section (
514
+ left_section,
515
+ right_section,
516
+ left_section_diff,
517
+ right_section_diff,
518
+ ) ?;
519
+ left_out. section_diff_mut ( left_section_idx) . merge ( left_diff) ;
520
+ right_out. section_diff_mut ( right_section_idx) . merge ( right_diff) ;
521
+ }
510
522
}
511
523
}
512
524
}
@@ -546,8 +558,8 @@ fn matching_symbols(
546
558
for ( symbol_idx, symbol) in section. symbols . iter ( ) . enumerate ( ) {
547
559
let symbol_match = SymbolMatch {
548
560
left : Some ( SymbolRef { section_idx, symbol_idx } ) ,
549
- right : find_symbol ( right, symbol, section) ,
550
- prev : find_symbol ( prev, symbol, section) ,
561
+ right : find_symbol ( right, symbol, section, Some ( & right_used ) ) ,
562
+ prev : find_symbol ( prev, symbol, section, None ) ,
551
563
section_kind : section. kind ,
552
564
} ;
553
565
matches. push ( symbol_match) ;
@@ -579,7 +591,7 @@ fn matching_symbols(
579
591
matches. push ( SymbolMatch {
580
592
left : None ,
581
593
right : Some ( symbol_ref) ,
582
- prev : find_symbol ( prev, symbol, section) ,
594
+ prev : find_symbol ( prev, symbol, section, None ) ,
583
595
section_kind : section. kind ,
584
596
} ) ;
585
597
}
@@ -604,6 +616,7 @@ fn find_symbol(
604
616
obj : Option < & ObjInfo > ,
605
617
in_symbol : & ObjSymbol ,
606
618
in_section : & ObjSection ,
619
+ used : Option < & HashSet < SymbolRef > > ,
607
620
) -> Option < SymbolRef > {
608
621
let obj = obj?;
609
622
// Try to find an exact name match
@@ -641,13 +654,21 @@ fn find_symbol(
641
654
if section. kind != in_section. kind {
642
655
continue ;
643
656
}
644
- if let Some ( symbol_idx) = section. symbols . iter ( ) . position ( |symbol| {
645
- if let Some ( ( p, s) ) = symbol. name . split_once ( '$' ) {
646
- prefix == p && s. chars ( ) . all ( char:: is_numeric)
647
- } else {
648
- false
649
- }
650
- } ) {
657
+ if let Some ( ( symbol_idx, _) ) =
658
+ section. symbols . iter ( ) . enumerate ( ) . find ( |& ( symbol_idx, symbol) | {
659
+ if used
660
+ . map ( |u| u. contains ( & SymbolRef { section_idx, symbol_idx } ) )
661
+ . unwrap_or ( false )
662
+ {
663
+ return false ;
664
+ }
665
+ if let Some ( ( p, s) ) = symbol. name . split_once ( '$' ) {
666
+ prefix == p && s. chars ( ) . all ( char:: is_numeric)
667
+ } else {
668
+ false
669
+ }
670
+ } )
671
+ {
651
672
return Some ( SymbolRef { section_idx, symbol_idx } ) ;
652
673
}
653
674
}
0 commit comments