tools: Print a note when a U function actually exists and matches

Also fixes the function call check not being as strict as it should be
and fixes several false positives in the function list
This commit is contained in:
Léo Lam
2021-08-04 16:29:32 +02:00
parent e3887d6835
commit 5367d0c85a
3 changed files with 116 additions and 97 deletions
+14 -1
View File
@@ -15,6 +15,19 @@ pub enum Status {
Library,
}
impl Status {
pub fn description(&self) -> &'static str {
match &self {
Status::Matching => "matching",
Status::NonMatchingMinor => "non-matching (minor)",
Status::NonMatchingMajor => "non-matching (major)",
Status::NotDecompiled => "not decompiled",
Status::Wip => "WIP",
Status::Library => "library function",
}
}
}
pub struct Info {
pub addr: u64,
pub size: u32,
@@ -145,7 +158,7 @@ pub fn make_known_function_map(functions: &[Info]) -> FxHashMap<u64, &Info> {
FxHashMap::with_capacity_and_hasher(functions.len(), Default::default());
for function in functions {
if !function.is_decompiled() {
if function.name.is_empty() {
continue;
}
known_functions.insert(function.addr, function);
+13 -7
View File
@@ -27,13 +27,15 @@ fn check_function(
decomp_symtab: &elf::SymbolTableByName,
function: &functions::Info,
) -> Result<bool> {
if !function.is_decompiled() {
return Ok(true);
}
let name = function.name.as_str();
let decomp_fn = elf::get_function_by_name(&decomp_elf, &decomp_symtab, &name);
match function.status {
Status::NotDecompiled if decomp_fn.is_err() => return Ok(true),
Status::Library => return Ok(true),
_ => (),
}
if decomp_fn.is_err() {
let error = decomp_fn.err().unwrap();
ui::print_warning(&format!(
@@ -79,7 +81,10 @@ fn check_function(
}
}
Status::NonMatchingMinor | Status::NonMatchingMajor | Status::Wip => {
Status::NotDecompiled
| Status::NonMatchingMinor
| Status::NonMatchingMajor
| Status::Wip => {
let orig_fn = get_orig_fn()?;
let result = checker
@@ -88,13 +93,14 @@ fn check_function(
if result.is_none() {
ui::print_note(&format!(
"function {} is marked as non-matching but matches",
"function {} is marked as {} but matches",
ui::format_symbol_name(name),
function.status.description(),
));
}
}
Status::NotDecompiled | Status::Library => unreachable!(),
Status::Library => unreachable!(),
};
Ok(true)