summaryrefslogtreecommitdiff
path: root/rust/examples
diff options
context:
space:
mode:
authorKyleMiles <krm504@nyu.edu>2023-07-10 13:37:01 -0400
committerKyleMiles <krm504@nyu.edu>2023-07-10 13:37:01 -0400
commit02e103c63fb58b9a24ff8d9d4984ac0b5b75cdc8 (patch)
tree93dd45393cfea25ccf66822ecf94411b8042acc3 /rust/examples
parentc549cb94942c955f352f965bda996ffaa34cf56f (diff)
Dwarf import : Resolve multiple data variable definitions for the same location; Resolves Vector35/dwarf_import#19
Diffstat (limited to 'rust/examples')
-rw-r--r--rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs19
1 files changed, 15 insertions, 4 deletions
diff --git a/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs b/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs
index 0cb9ede2..2403c879 100644
--- a/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs
+++ b/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs
@@ -23,6 +23,7 @@ use binaryninja::{
use gimli::{DebuggingInformationEntry, Reader, Unit};
+use log::error;
use std::{
collections::{hash_map::Values, HashMap},
ffi::CString,
@@ -163,10 +164,20 @@ impl DebugInfoBuilder {
}
pub fn add_data_variable(&mut self, address: u64, name: Option<CString>, type_uid: TypeUID) {
- assert!(self
- .data_variables
- .insert(address, (name, type_uid))
- .is_none());
+ if let Some((_existing_name, existing_type_uid)) =
+ self.data_variables.insert(address, (name, type_uid))
+ {
+ let existing_type = self.get_type(existing_type_uid).unwrap().1;
+ let new_type = self.get_type(type_uid).unwrap().1;
+
+ if existing_type_uid != type_uid || existing_type != new_type {
+ error!("DWARF info contains duplicate data variable definition. Overwriting data variable at 0x{:08x} (`{}`) with `{}`",
+ address,
+ self.get_type(existing_type_uid).unwrap().1,
+ self.get_type(type_uid).unwrap().1
+ );
+ }
+ }
}
pub fn set_name(&mut self, die_uid: TypeUID, name: CString) {