(&mut self, bv: &BinaryView, _debug_info: &mut DebugInfo)
| 595 | } |
| 596 | |
| 597 | pub(crate) fn post_process(&mut self, bv: &BinaryView, _debug_info: &mut DebugInfo) -> &Self { |
| 598 | // When originally resolving names, we need to check: |
| 599 | // If there's already a name from binja that's "more correct" than what we found (has more namespaces) |
| 600 | // If there's no name for the DIE, but there's a linkage name that's resolved in binja to a usable name |
| 601 | // This is no longer true, because DWARF doesn't provide platform information for functions, so we at least need to post-process thumb functions |
| 602 | |
| 603 | for func in &mut self.functions { |
| 604 | // If the function's raw name already exists in the binary... |
| 605 | if let Some(raw_name) = &func.raw_name { |
| 606 | if let Some(symbol) = bv.symbol_by_raw_name(raw_name) { |
| 607 | // Link mangled names without addresses to existing symbols in the binary |
| 608 | if func.address.is_none() && func.raw_name.is_some() { |
| 609 | // DWARF doesn't contain GOT info, so remove any entries there...they will be wrong (relying on Binja's mechanisms for the GOT is good ) |
| 610 | if symbol.sym_type() != SymbolType::ImportAddress { |
| 611 | func.address = Some(symbol.address() - bv.start()); |
| 612 | } |
| 613 | } |
| 614 | |
| 615 | if let Some(full_name) = &func.full_name { |
| 616 | let func_full_name = full_name; |
| 617 | let symbol_full_name = symbol.full_name(); |
| 618 | |
| 619 | // If our name has fewer namespaces than the existing name, assume we lost the namespace info |
| 620 | if simplify_str_to_fqn(func_full_name, true).items.len() |
| 621 | < simplify_str_to_fqn(symbol_full_name.clone(), true) |
| 622 | .items |
| 623 | .len() |
| 624 | { |
| 625 | func.full_name = Some(symbol_full_name.to_string()); |
| 626 | } |
| 627 | } |
| 628 | } |
| 629 | } |
| 630 | |
| 631 | if let Some(address) = func.address.as_mut() { |
| 632 | let (diff, overflowed) = bv.start().overflowing_sub(bv.original_image_base()); |
| 633 | if !overflowed { |
| 634 | *address = (*address).overflowing_add(diff).0; // rebase the address |
| 635 | let existing_functions = bv.functions_at(*address); |
| 636 | match existing_functions.len().cmp(&1) { |
| 637 | Ordering::Greater => { |
| 638 | warn!("Multiple existing functions at address {address:08x}. One or more functions at this address may have the wrong platform information. Please report this binary."); |
| 639 | } |
| 640 | Ordering::Equal => { |
| 641 | func.platform = Some(existing_functions.get(0).platform()) |
| 642 | } |
| 643 | Ordering::Less => {} |
| 644 | } |
| 645 | } |
| 646 | } |
| 647 | } |
| 648 | |
| 649 | self |
| 650 | } |
| 651 | |
| 652 | pub(crate) fn commit_info(&self, debug_info: &mut DebugInfo) { |
| 653 | self.commit_types(debug_info); |
no test coverage detected