(
sections: &mut [Section],
symbols: &mut [Symbol],
config: &DiffObjConfig,
)
| 888 | } |
| 889 | |
| 890 | fn combine_sections( |
| 891 | sections: &mut [Section], |
| 892 | symbols: &mut [Symbol], |
| 893 | config: &DiffObjConfig, |
| 894 | ) -> Result<()> { |
| 895 | let mut data_sections = BTreeMap::<String, Vec<usize>>::new(); |
| 896 | let mut text_sections = BTreeMap::<String, Vec<usize>>::new(); |
| 897 | for (i, section) in sections.iter().enumerate() { |
| 898 | let base_name = section |
| 899 | .name |
| 900 | .get(1..) |
| 901 | .and_then(|s| s.rfind(['$', '.'])) |
| 902 | .and_then(|i| section.name.get(..i + 1)) |
| 903 | .unwrap_or(§ion.name); |
| 904 | match section.kind { |
| 905 | SectionKind::Data | SectionKind::Bss => { |
| 906 | data_sections.entry(base_name.to_string()).or_default().push(i); |
| 907 | } |
| 908 | SectionKind::Code => { |
| 909 | text_sections.entry(base_name.to_string()).or_default().push(i); |
| 910 | } |
| 911 | _ => {} |
| 912 | } |
| 913 | } |
| 914 | if config.combine_data_sections { |
| 915 | for (combined_name, mut section_indices) in data_sections { |
| 916 | do_combine_sections(sections, symbols, &mut section_indices, combined_name)?; |
| 917 | } |
| 918 | } |
| 919 | if config.combine_text_sections { |
| 920 | for (combined_name, mut section_indices) in text_sections { |
| 921 | do_combine_sections(sections, symbols, &mut section_indices, combined_name)?; |
| 922 | } |
| 923 | } |
| 924 | Ok(()) |
| 925 | } |
| 926 | |
| 927 | fn do_combine_sections( |
| 928 | sections: &mut [Section], |
no test coverage detected