| 1070 | } |
| 1071 | |
| 1072 | pub fn parse(data: &[u8], config: &DiffObjConfig, diff_side: DiffSide) -> Result<Object> { |
| 1073 | let obj_file = object::File::parse(data)?; |
| 1074 | let mut arch = new_arch(&obj_file, diff_side)?; |
| 1075 | let split_meta = parse_split_meta(&obj_file)?; |
| 1076 | let (mut sections, section_indices) = |
| 1077 | map_sections(arch.as_ref(), &obj_file, split_meta.as_ref())?; |
| 1078 | let (mut symbols, symbol_indices) = map_symbols( |
| 1079 | arch.as_ref(), |
| 1080 | &obj_file, |
| 1081 | §ions, |
| 1082 | §ion_indices, |
| 1083 | split_meta.as_ref(), |
| 1084 | config, |
| 1085 | )?; |
| 1086 | map_relocations(arch.as_ref(), &obj_file, &mut sections, §ion_indices, &symbol_indices)?; |
| 1087 | parse_line_info(&obj_file, &mut sections, §ion_indices, data)?; |
| 1088 | if config.combine_data_sections || config.combine_text_sections { |
| 1089 | combine_sections(&mut sections, &mut symbols, config)?; |
| 1090 | } |
| 1091 | add_section_symbols(§ions, &mut symbols); |
| 1092 | arch.post_init(§ions, &symbols, &symbol_indices); |
| 1093 | let mut obj = Object { |
| 1094 | arch, |
| 1095 | endianness: obj_file.endianness(), |
| 1096 | symbols, |
| 1097 | sections, |
| 1098 | split_meta, |
| 1099 | #[cfg(feature = "std")] |
| 1100 | path: None, |
| 1101 | #[cfg(feature = "std")] |
| 1102 | timestamp: None, |
| 1103 | flow_analysis_results: Default::default(), |
| 1104 | }; |
| 1105 | |
| 1106 | // Need to construct the obj first so that we have a convinient package to |
| 1107 | // pass to flow analysis. Then the flow analysis will mutate obj adding |
| 1108 | // additional data to it. |
| 1109 | perform_data_flow_analysis(&mut obj, config)?; |
| 1110 | Ok(obj) |
| 1111 | } |
| 1112 | |
| 1113 | #[cfg(feature = "std")] |
| 1114 | pub fn has_function(obj_path: &std::path::Path, symbol_name: &str) -> Result<bool> { |