@@ -687,8 +687,7 @@ fn find_symbol(
687
687
if is_symbol_compiler_generated_literal ( in_symbol)
688
688
&& matches ! ( section_kind, SectionKind :: Data | SectionKind :: Bss )
689
689
{
690
- let mut closest_match_symbol_idx = None ;
691
- let mut closest_match_percent = 0.0 ;
690
+ let mut matching_symbol_idx = None ;
692
691
for ( symbol_idx, symbol) in unmatched_symbols ( obj, used) {
693
692
let Some ( section_index) = symbol. section else {
694
693
continue ;
@@ -701,31 +700,27 @@ fn find_symbol(
701
700
}
702
701
match section_kind {
703
702
SectionKind :: Data => {
704
- // For data, we try to pick the first symbol that matches 100%.
705
- // If no symbol is a perfect match, pick whichever matches the closest.
703
+ // For data, pick the first symbol that has the exact matching bytes and relocations.
706
704
if let Ok ( ( left_diff, _right_diff) ) =
707
705
diff_data_symbol ( in_obj, obj, in_symbol_idx, symbol_idx)
708
706
&& let Some ( match_percent) = left_diff. match_percent
709
- && match_percent > closest_match_percent
707
+ && match_percent == 100.0
710
708
{
711
- closest_match_symbol_idx = Some ( symbol_idx) ;
712
- closest_match_percent = match_percent;
713
- if match_percent == 100.0 {
714
- break ;
715
- }
709
+ matching_symbol_idx = Some ( symbol_idx) ;
710
+ break ;
716
711
}
717
712
}
718
713
SectionKind :: Bss => {
719
- // For BSS, we simply pick the first symbol that has the exact matching size.
714
+ // For BSS, pick the first symbol that has the exact matching size.
720
715
if in_symbol. size == symbol. size {
721
- closest_match_symbol_idx = Some ( symbol_idx) ;
716
+ matching_symbol_idx = Some ( symbol_idx) ;
722
717
break ;
723
718
}
724
719
}
725
720
_ => unreachable ! ( ) ,
726
721
}
727
722
}
728
- return closest_match_symbol_idx ;
723
+ return matching_symbol_idx ;
729
724
}
730
725
731
726
// Try to find an exact name match
0 commit comments