Support matching multiple symbols with signatures

Half of #20
This commit is contained in:
Luke Street 2024-01-06 18:31:33 -07:00
parent 458d0599f5
commit 85e044463e
1 changed files with 11 additions and 10 deletions

View File

@ -1,4 +1,5 @@
use anyhow::{anyhow, Result};
use itertools::Itertools;
use crate::{
analysis::{
@ -203,16 +204,16 @@ const POST_SIGNATURES: &[(&str, &str)] = &[
];
fn apply_signature_for_symbol(obj: &mut ObjInfo, name: &str, sig_str: &str) -> Result<()> {
let Some((_, symbol)) = obj.symbols.by_name(name)? else {
return Ok(());
};
let Some(section_index) = symbol.section else {
return Ok(());
};
let addr = symbol.address as u32;
let section = &obj.sections[section_index];
if let Some(signature) = check_signatures_str(section, addr, sig_str)? {
apply_signature(obj, SectionAddress::new(section_index, addr), &signature)?;
for symbol_idx in obj.symbols.for_name(name).map(|(i, _)| i).collect_vec() {
let symbol = &obj.symbols[symbol_idx];
let Some(section_index) = symbol.section else {
continue;
};
let addr = symbol.address as u32;
let section = &obj.sections[section_index];
if let Some(signature) = check_signatures_str(section, addr, sig_str)? {
apply_signature(obj, SectionAddress::new(section_index, addr), &signature)?;
}
}
Ok(())
}