summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2021-08-04 16:29:32 +0200
committerLéo Lam <leo@leolam.fr>2021-08-04 17:37:12 +0200
commit5367d0c85a46400a6856f0a8958c76d66fbc8cce (patch)
treeba6b2072072465726b9817ef27fa5597511f6c39 /tools
parente3887d6835c8a720e91f41c0929815f27e91ab34 (diff)
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
Diffstat (limited to 'tools')
-rw-r--r--tools/viking/src/functions.rs15
-rw-r--r--tools/viking/src/tools/check.rs20
2 files changed, 27 insertions, 8 deletions
diff --git a/tools/viking/src/functions.rs b/tools/viking/src/functions.rs
index 36385ad1..dec84e9c 100644
--- a/tools/viking/src/functions.rs
+++ b/tools/viking/src/functions.rs
@@ -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);
diff --git a/tools/viking/src/tools/check.rs b/tools/viking/src/tools/check.rs
index 1a61904e..11b83fb5 100644
--- a/tools/viking/src/tools/check.rs
+++ b/tools/viking/src/tools/check.rs
@@ -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)