diff options
| author | KyleMiles <krm504@nyu.edu> | 2024-05-15 13:15:04 -0400 |
|---|---|---|
| committer | KyleMiles <krm504@nyu.edu> | 2024-05-15 13:17:12 -0400 |
| commit | fb893038862ad045d8ad1c624e0e954042a2f01a (patch) | |
| tree | 235f5c1915e53db9ea19777a86b529cd0e920d01 /rust/examples | |
| parent | 13b0493430910d53c3cd68935a1692521b796c31 (diff) | |
DWARF Import : Add support for variable arguments
Diffstat (limited to 'rust/examples')
| -rw-r--r-- | rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs | 8 | ||||
| -rw-r--r-- | rust/examples/dwarf/dwarf_import/src/functions.rs | 13 |
2 files changed, 11 insertions, 10 deletions
diff --git a/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs b/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs index 537051c8..4db125c4 100644 --- a/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs +++ b/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs @@ -47,6 +47,7 @@ pub(crate) struct FunctionInfoBuilder { pub(crate) address: Option<u64>, pub(crate) parameters: Vec<Option<(String, TypeUID)>>, pub(crate) platform: Option<Ref<Platform>>, + pub(crate) variable_arguments: bool, } impl FunctionInfoBuilder { @@ -188,6 +189,7 @@ impl DebugInfoBuilder { return_type: Option<TypeUID>, address: Option<u64>, parameters: Vec<Option<(String, TypeUID)>>, + variable_arguments: bool, ) { // Raw names should be the primary key, but if they don't exist, use the full name // TODO : Consider further falling back on address/architecture @@ -211,6 +213,7 @@ impl DebugInfoBuilder { address, parameters, platform: None, + variable_arguments, }); } } @@ -325,10 +328,7 @@ impl DebugInfoBuilder { }) .collect(); - // TODO : Handle - let variable_parameters = false; - - binaryninja::types::Type::function(&return_type, ¶meters, variable_parameters) + binaryninja::types::Type::function(&return_type, ¶meters, function.variable_arguments) } fn commit_functions(&self, debug_info: &mut DebugInfo) { diff --git a/rust/examples/dwarf/dwarf_import/src/functions.rs b/rust/examples/dwarf/dwarf_import/src/functions.rs index 1d8879a0..016c4033 100644 --- a/rust/examples/dwarf/dwarf_import/src/functions.rs +++ b/rust/examples/dwarf/dwarf_import/src/functions.rs @@ -23,14 +23,15 @@ fn get_parameters<R: Reader<Offset = usize>>( entry: &DebuggingInformationEntry<R>, debug_info_builder_context: &DebugInfoBuilderContext<R>, debug_info_builder: &mut DebugInfoBuilder, -) -> Vec<Option<(String, TypeUID)>> { +) -> (Vec<Option<(String, TypeUID)>>, bool) { if !entry.has_children() { - vec![] + (vec![], false) } else { // We make a new tree from the current entry to iterate over its children let mut sub_die_tree = unit.entries_tree(Some(entry.offset())).unwrap(); let root = sub_die_tree.root().unwrap(); + let mut variable_arguments = false; let mut result = vec![]; let mut children = root.children(); while let Some(child) = children.next().unwrap() { @@ -53,11 +54,11 @@ fn get_parameters<R: Reader<Offset = usize>>( result.push(None) } } - constants::DW_TAG_unspecified_parameters => (), + constants::DW_TAG_unspecified_parameters => variable_arguments = true, _ => (), } } - result + (result, variable_arguments) } } @@ -72,7 +73,7 @@ pub(crate) fn parse_function_entry<R: Reader<Offset = usize>>( let raw_name = get_raw_name(unit, entry, debug_info_builder_context); let return_type = get_type(unit, entry, debug_info_builder_context, debug_info_builder); let address = get_start_address(unit, entry, debug_info_builder_context); - let parameters = get_parameters(unit, entry, debug_info_builder_context, debug_info_builder); + let (parameters, variable_arguments) = get_parameters(unit, entry, debug_info_builder_context, debug_info_builder); - debug_info_builder.insert_function(full_name, raw_name, return_type, address, parameters); + debug_info_builder.insert_function(full_name, raw_name, return_type, address, parameters, variable_arguments); } |
