update rust crate

This commit is contained in:
2024-08-17 16:20:28 +02:00
parent 670fa334db
commit 2167e0512a
88 changed files with 20508 additions and 1741 deletions

View File

@@ -6,4 +6,4 @@ edition = "2021"
[dependencies]
binaryninja = {path="../../../"}
gimli = "0.28"
gimli = "0.31"

View File

@@ -20,6 +20,7 @@ use binaryninja::{
binaryview::{BinaryView, BinaryViewBase, BinaryViewExt},
databuffer::DataBuffer,
Endianness,
settings::Settings,
};
use std::{ffi::CString, rc::Rc};
@@ -52,6 +53,19 @@ pub fn is_raw_dwo_dwarf(view: &BinaryView) -> bool {
}
}
pub fn can_use_debuginfod(view: &BinaryView) -> bool {
has_build_id_section(view) &&
Settings::new("")
.get_bool("network.enableDebuginfod", Some(view), None)
}
pub fn has_build_id_section(view: &BinaryView) -> bool {
if let Ok(raw_view) = view.raw_view() {
return raw_view.section_by_name(".note.gnu.build-id").is_ok()
}
false
}
pub fn is_valid(view: &BinaryView) -> bool {
is_non_dwo_dwarf(view)
|| is_raw_non_dwo_dwarf(view)
@@ -88,23 +102,37 @@ pub fn create_section_reader<'a, Endian: 'a + Endianity>(
if let Some(data_var) = view
.data_variables()
.iter()
.find(|var| var.address == symbol.address())
.find(|var| var.address() == symbol.address())
{
// TODO : This should eventually be wrapped by some DataView sorta thingy thing, like how python does it
let data_type = data_var.type_with_confidence().contents;
let data = view.read_vec(data_var.address, data_type.width() as usize);
let data_type = data_var.t();
let data = view.read_vec(data_var.address(), data_type.width() as usize);
let element_type = data_type.element_type().unwrap().contents;
if let Some(current_section_header) = data
.chunks(element_type.width() as usize)
.find(|section_header| {
endian.read_u64(&section_header[24..32]) == section.start()
if view.address_size() == 4 {
endian.read_u32(&section_header[16..20]) as u64 == section.start()
}
else {
endian.read_u64(&section_header[24..32]) == section.start()
}
})
{
if (endian.read_u64(&current_section_header[8..16]) & 2048) != 0 {
let section_flags = if view.address_size() == 4 {
endian.read_u32(&current_section_header[8..12]) as u64
}
else {
endian.read_u64(&current_section_header[8..16])
};
// If the section has the compressed bit set
if (section_flags & 2048) != 0 {
// Get section, trim header, decompress, return
let offset = section.start() + 24;
let len = section.len() - 24;
let compressed_header_size = view.address_size()*3;
let offset = section.start() + compressed_header_size as u64;
let len = section.len() - compressed_header_size;
if let Ok(buffer) = view.read_buffer(offset, len) {
use std::ptr;