Decode extab entries as comment in assembly output
This commit is contained in:
parent
71701b5667
commit
281b0f7104
|
@ -395,7 +395,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "decomp-toolkit"
|
name = "decomp-toolkit"
|
||||||
version = "1.0.0"
|
version = "1.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"ar",
|
"ar",
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = "decomp-toolkit"
|
||||||
description = "Yet another GameCube/Wii decompilation toolkit."
|
description = "Yet another GameCube/Wii decompilation toolkit."
|
||||||
authors = ["Luke Street <luke@street.dev>"]
|
authors = ["Luke Street <luke@street.dev>"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
version = "1.0.0"
|
version = "1.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
repository = "https://github.com/encounter/decomp-toolkit"
|
repository = "https://github.com/encounter/decomp-toolkit"
|
||||||
|
|
|
@ -432,9 +432,37 @@ where
|
||||||
write_symbol_name(w, &symbol.name)?;
|
write_symbol_name(w, &symbol.name)?;
|
||||||
writeln!(w)?;
|
writeln!(w)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if entry.kind == SymbolEntryKind::Start && section.name == "extab" {
|
||||||
|
writeln!(w, "/*")?;
|
||||||
|
match parse_extab(symbols, entry, section) {
|
||||||
|
Ok(s) => {
|
||||||
|
for line in s.trim_end().lines() {
|
||||||
|
writeln!(w, " * {}", line)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
log::warn!("Failed to decode extab entry {}: {}", symbol.name, e);
|
||||||
|
writeln!(w, " * Failed to decode extab entry: {}", e)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
writeln!(w, " */")?;
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_extab(symbols: &[ObjSymbol], entry: &SymbolEntry, section: &ObjSection) -> Result<String> {
|
||||||
|
let symbol = &symbols[entry.index];
|
||||||
|
let data = section.symbol_data(symbol)?;
|
||||||
|
let decoded = cwextab::decode_extab(data)?;
|
||||||
|
let function_names = section
|
||||||
|
.relocations
|
||||||
|
.range(symbol.address as u32..(symbol.address + symbol.size) as u32)
|
||||||
|
.map(|(_, reloc)| symbols[reloc.target_symbol].name.clone())
|
||||||
|
.collect_vec();
|
||||||
|
decoded.to_string(function_names).ok_or_else(|| anyhow!("Failed to print extab entry"))
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn write_data<W>(
|
fn write_data<W>(
|
||||||
w: &mut W,
|
w: &mut W,
|
||||||
|
|
Loading…
Reference in New Issue