@@ -6,8 +6,8 @@ use crate::{
66 diff:: {
77 code:: { diff_code, no_diff_code, process_code_symbol} ,
88 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,
1111 } ,
1212 } ,
1313 obj:: { ObjInfo , ObjIns , ObjSection , ObjSectionKind , ObjSymbol , SymbolRef } ,
@@ -483,7 +483,7 @@ pub fn diff_objs(
483483 let left_section = & left_obj. sections [ left_section_idx] ;
484484 let right_section = & right_obj. sections [ right_section_idx] ;
485485 match section_kind {
486- ObjSectionKind :: Code | ObjSectionKind :: Bss => {
486+ ObjSectionKind :: Code => {
487487 let left_section_diff = left_out. section_diff ( left_section_idx) ;
488488 let right_section_diff = right_out. section_diff ( right_section_idx) ;
489489 let ( left_diff, right_diff) = diff_generic_section (
@@ -507,6 +507,18 @@ pub fn diff_objs(
507507 left_out. section_diff_mut ( left_section_idx) . merge ( left_diff) ;
508508 right_out. section_diff_mut ( right_section_idx) . merge ( right_diff) ;
509509 }
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+ }
510522 }
511523 }
512524 }
@@ -546,8 +558,8 @@ fn matching_symbols(
546558 for ( symbol_idx, symbol) in section. symbols . iter ( ) . enumerate ( ) {
547559 let symbol_match = SymbolMatch {
548560 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 ) ,
551563 section_kind : section. kind ,
552564 } ;
553565 matches. push ( symbol_match) ;
@@ -579,7 +591,7 @@ fn matching_symbols(
579591 matches. push ( SymbolMatch {
580592 left : None ,
581593 right : Some ( symbol_ref) ,
582- prev : find_symbol ( prev, symbol, section) ,
594+ prev : find_symbol ( prev, symbol, section, None ) ,
583595 section_kind : section. kind ,
584596 } ) ;
585597 }
@@ -604,6 +616,7 @@ fn find_symbol(
604616 obj : Option < & ObjInfo > ,
605617 in_symbol : & ObjSymbol ,
606618 in_section : & ObjSection ,
619+ used : Option < & HashSet < SymbolRef > > ,
607620) -> Option < SymbolRef > {
608621 let obj = obj?;
609622 // Try to find an exact name match
@@ -641,13 +654,21 @@ fn find_symbol(
641654 if section. kind != in_section. kind {
642655 continue ;
643656 }
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+ {
651672 return Some ( SymbolRef { section_idx, symbol_idx } ) ;
652673 }
653674 }
0 commit comments