When we're selecting a symbol to use as a comparison, we'll create comparisons for all symbols in the other object that match the selected symbol's section and kind. This allows us to display match percentages for all symbols in the other object that could be selected.
(
left_obj: &Object,
left_out: &mut ObjectDiff,
right_obj: &Object,
right_out: &mut ObjectDiff,
mapping_symbol: MappingSymbol,
config: &DiffObjConfig,
)
| 429 | /// symbols in the other object that match the selected symbol's section and kind. This allows |
| 430 | /// us to display match percentages for all symbols in the other object that could be selected. |
| 431 | fn generate_mapping_symbols( |
| 432 | left_obj: &Object, |
| 433 | left_out: &mut ObjectDiff, |
| 434 | right_obj: &Object, |
| 435 | right_out: &mut ObjectDiff, |
| 436 | mapping_symbol: MappingSymbol, |
| 437 | config: &DiffObjConfig, |
| 438 | ) -> Result<()> { |
| 439 | let (base_obj, base_name, target_obj) = match mapping_symbol { |
| 440 | MappingSymbol::Left(name) => (left_obj, name, right_obj), |
| 441 | MappingSymbol::Right(name) => (right_obj, name, left_obj), |
| 442 | }; |
| 443 | let Some(base_symbol_ref) = base_obj.symbol_by_name(base_name) else { |
| 444 | return Ok(()); |
| 445 | }; |
| 446 | let base_section_kind = symbol_section_kind(base_obj, &base_obj.symbols[base_symbol_ref]); |
| 447 | for (target_symbol_index, target_symbol) in target_obj.symbols.iter().enumerate() { |
| 448 | if target_symbol.size == 0 |
| 449 | || target_symbol.flags.contains(SymbolFlag::Ignored) |
| 450 | || symbol_section_kind(target_obj, target_symbol) != base_section_kind |
| 451 | { |
| 452 | continue; |
| 453 | } |
| 454 | let (left_symbol_idx, right_symbol_idx) = match mapping_symbol { |
| 455 | MappingSymbol::Left(_) => (base_symbol_ref, target_symbol_index), |
| 456 | MappingSymbol::Right(_) => (target_symbol_index, base_symbol_ref), |
| 457 | }; |
| 458 | let (left_diff, right_diff) = match base_section_kind { |
| 459 | SectionKind::Code => { |
| 460 | diff_code(left_obj, right_obj, left_symbol_idx, right_symbol_idx, config) |
| 461 | } |
| 462 | SectionKind::Data => { |
| 463 | diff_data_symbol(left_obj, right_obj, left_symbol_idx, right_symbol_idx) |
| 464 | } |
| 465 | SectionKind::Bss | SectionKind::Common => { |
| 466 | diff_bss_symbol(left_obj, right_obj, left_symbol_idx, right_symbol_idx) |
| 467 | } |
| 468 | SectionKind::Unknown => continue, |
| 469 | }?; |
| 470 | match mapping_symbol { |
| 471 | MappingSymbol::Left(_) => right_out.mapping_symbols.push(MappingSymbolDiff { |
| 472 | symbol_index: right_symbol_idx, |
| 473 | symbol_diff: right_diff, |
| 474 | }), |
| 475 | MappingSymbol::Right(_) => left_out |
| 476 | .mapping_symbols |
| 477 | .push(MappingSymbolDiff { symbol_index: left_symbol_idx, symbol_diff: left_diff }), |
| 478 | } |
| 479 | } |
| 480 | Ok(()) |
| 481 | } |
| 482 | |
| 483 | #[derive(Copy, Clone, Eq, PartialEq)] |
| 484 | struct SymbolMatch { |
no test coverage detected