diff options
| author | Mason Reed <mason@vector35.com> | 2025-05-03 23:15:17 -0400 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2025-05-12 17:45:24 -0400 |
| commit | 6264254065bbae9d89f51cf3330379b7ace09592 (patch) | |
| tree | 9ece1d1739215c2faef2d808ef4fdc019ad527fa /plugins/dwarf | |
| parent | c3fdda9727f5507818e3f55576ad32215a22b0f9 (diff) | |
[Rust] Return `String` instead of `BnString` for cases where lossy conversion can be tolerated
Still need to go and audit all usage, but realistically the most important places to give the user control are with symbols, where the data can come from non utf8 sources
This is still incomplete, I just looked for usage of -> BnString so any other variant was omitted.
Diffstat (limited to 'plugins/dwarf')
| -rw-r--r-- | plugins/dwarf/dwarf_export/src/lib.rs | 7 | ||||
| -rw-r--r-- | plugins/dwarf/shared/src/lib.rs | 2 |
2 files changed, 4 insertions, 5 deletions
diff --git a/plugins/dwarf/dwarf_export/src/lib.rs b/plugins/dwarf/dwarf_export/src/lib.rs index bc159825..d1754d29 100644 --- a/plugins/dwarf/dwarf_export/src/lib.rs +++ b/plugins/dwarf/dwarf_export/src/lib.rs @@ -18,7 +18,6 @@ use binaryninja::{ interaction, interaction::{FormResponses, FormResponses::Index}, rc::Ref, - string::BnString, symbol::SymbolType, types::{MemberAccess, StructureType, Type, TypeClass}, }; @@ -422,7 +421,7 @@ fn export_functions( // Set subprogram DIE attributes dwarf.unit.get_mut(function_die_uid).set( gimli::DW_AT_name, - AttributeValue::String(function.symbol().short_name().as_bytes().to_vec()), + AttributeValue::String(function.symbol().short_name().to_bytes().to_vec()), ); // TODO : (DW_AT_main_subprogram VS DW_TAG_entry_point) @@ -557,7 +556,7 @@ fn export_data_vars( if let Some(symbol) = data_var_sym { dwarf.unit.get_mut(var_die_uid).set( gimli::DW_AT_name, - AttributeValue::String(symbol.full_name().as_bytes().to_vec()), + AttributeValue::String(symbol.full_name().to_bytes().to_vec()), ); if symbol.external() { @@ -756,7 +755,7 @@ fn export_dwarf(bv: &BinaryView) { let arch_name = if let Some(arch) = bv.default_arch() { arch.name() } else { - BnString::new("Unknown") + String::from("Unknown") }; let responses = present_form(arch_name.as_str()); diff --git a/plugins/dwarf/shared/src/lib.rs b/plugins/dwarf/shared/src/lib.rs index b12aeab1..c4ed7937 100644 --- a/plugins/dwarf/shared/src/lib.rs +++ b/plugins/dwarf/shared/src/lib.rs @@ -106,7 +106,7 @@ pub fn create_section_reader<'a, Endian: 'a + Endianity>( if let Some(symbol) = view .symbols() .iter() - .find(|symbol| symbol.full_name().as_str() == "__elf_section_headers") + .find(|symbol| symbol.full_name().to_string_lossy() == "__elf_section_headers") { if let Some(data_var) = view .data_variables() |
