| 770 | } |
| 771 | |
| 772 | pub fn display_sections( |
| 773 | obj: &Object, |
| 774 | diff: &ObjectDiff, |
| 775 | filter: SymbolFilter<'_>, |
| 776 | show_hidden_symbols: bool, |
| 777 | show_mapped_symbols: bool, |
| 778 | reverse_fn_order: bool, |
| 779 | ) -> Vec<SectionDisplay> { |
| 780 | let mut mapping = BTreeSet::new(); |
| 781 | let is_mapping_symbol = if let SymbolFilter::Mapping(_, _) = filter { |
| 782 | for mapping_diff in &diff.mapping_symbols { |
| 783 | let symbol = &obj.symbols[mapping_diff.symbol_index]; |
| 784 | if !symbol_matches_filter( |
| 785 | symbol, |
| 786 | &mapping_diff.symbol_diff, |
| 787 | filter, |
| 788 | show_hidden_symbols, |
| 789 | ) { |
| 790 | continue; |
| 791 | } |
| 792 | if !show_mapped_symbols { |
| 793 | let symbol_diff = &diff.symbols[mapping_diff.symbol_index]; |
| 794 | if symbol_diff.target_symbol.is_some() { |
| 795 | continue; |
| 796 | } |
| 797 | } |
| 798 | mapping.insert((symbol.section, mapping_diff.symbol_index)); |
| 799 | } |
| 800 | true |
| 801 | } else { |
| 802 | for (symbol_idx, (symbol, symbol_diff)) in obj.symbols.iter().zip(&diff.symbols).enumerate() |
| 803 | { |
| 804 | if !symbol_matches_filter(symbol, symbol_diff, filter, show_hidden_symbols) { |
| 805 | continue; |
| 806 | } |
| 807 | mapping.insert((symbol.section, symbol_idx)); |
| 808 | } |
| 809 | false |
| 810 | }; |
| 811 | let num_sections = mapping.iter().map(|(section_idx, _)| *section_idx).dedup().count(); |
| 812 | let mut sections = Vec::with_capacity(num_sections); |
| 813 | for (section_idx, group) in &mapping.iter().chunk_by(|(section_idx, _)| *section_idx) { |
| 814 | let mut symbols = group |
| 815 | .map(|&(_, symbol)| SectionDisplaySymbol { symbol, is_mapping_symbol }) |
| 816 | .collect::<Vec<_>>(); |
| 817 | if let Some(section_idx) = section_idx { |
| 818 | let section = &obj.sections[section_idx]; |
| 819 | if section.kind == SectionKind::Unknown { |
| 820 | // Skip unknown and hidden sections |
| 821 | continue; |
| 822 | } |
| 823 | let section_diff = &diff.sections[section_idx]; |
| 824 | let reverse_fn_order = section.kind == SectionKind::Code && reverse_fn_order; |
| 825 | if reverse_fn_order { |
| 826 | symbols.sort_by(|a, b| { |
| 827 | let a = &obj.symbols[a.symbol]; |
| 828 | let b = &obj.symbols[b.symbol]; |
| 829 | section_symbol_sort(a, b) |