mirror of
https://github.com/encounter/decomp-toolkit.git
synced 2025-12-12 14:46:17 +00:00
Working rel make & more
- Added `elf info` - Improved `rel info` - Colored output for `shasum` - Fix section `rename` in RELs - Added padding symbols to avoid linker issues - Automatically set symbols to "active" in .comment output
This commit is contained in:
@@ -166,13 +166,8 @@ impl AnalyzerState {
|
||||
pub fn detect_functions(&mut self, obj: &ObjInfo) -> Result<()> {
|
||||
// Apply known functions from extab
|
||||
for (&addr, &size) in &obj.known_functions {
|
||||
let (section_index, _) = obj
|
||||
.sections
|
||||
.at_address(addr)
|
||||
.context(format!("Function {:#010X} outside of any section", addr))?;
|
||||
let addr_ref = SectionAddress::new(section_index, addr);
|
||||
self.function_entries.insert(addr_ref);
|
||||
self.function_bounds.insert(addr_ref, Some(addr_ref + size));
|
||||
self.function_entries.insert(addr);
|
||||
self.function_bounds.insert(addr, Some(addr + size));
|
||||
}
|
||||
// Apply known functions from symbols
|
||||
for (_, symbol) in obj.symbols.by_kind(ObjSymbolKind::Function) {
|
||||
|
||||
@@ -201,7 +201,11 @@ impl AnalysisPass for FindRelCtorsDtors {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
log::debug!("Found .ctors and .dtors: {:?}", possible_sections);
|
||||
log::debug!(
|
||||
"Found .ctors and .dtors: {}, {}",
|
||||
possible_sections[0].0,
|
||||
possible_sections[1].0
|
||||
);
|
||||
let ctors_section_index = possible_sections[0].0;
|
||||
state.known_sections.insert(ctors_section_index, ".ctors".to_string());
|
||||
state.known_symbols.insert(SectionAddress::new(ctors_section_index, 0), ObjSymbol {
|
||||
@@ -311,7 +315,11 @@ impl AnalysisPass for FindRelRodataData {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
log::debug!("Found .rodata and .data: {:?}", possible_sections);
|
||||
log::debug!(
|
||||
"Found .rodata and .data: {}, {}",
|
||||
possible_sections[0].0,
|
||||
possible_sections[1].0
|
||||
);
|
||||
let rodata_section_index = possible_sections[0].0;
|
||||
state.known_sections.insert(rodata_section_index, ".rodata".to_string());
|
||||
|
||||
|
||||
@@ -264,6 +264,8 @@ fn apply_ctors_signatures(obj: &mut ObjInfo) -> Result<()> {
|
||||
align: None,
|
||||
common: false,
|
||||
autogenerated: true,
|
||||
skip: false,
|
||||
rename: None,
|
||||
})?;
|
||||
}
|
||||
Ok(())
|
||||
@@ -362,6 +364,8 @@ fn apply_dtors_signatures(obj: &mut ObjInfo) -> Result<()> {
|
||||
align: None,
|
||||
common: false,
|
||||
autogenerated: true,
|
||||
skip: false,
|
||||
rename: None,
|
||||
})?;
|
||||
}
|
||||
}
|
||||
@@ -439,6 +443,5 @@ pub fn apply_signatures_post(obj: &mut ObjInfo) -> Result<()> {
|
||||
apply_signature(obj, symbol_addr, &signature)?;
|
||||
}
|
||||
}
|
||||
log::debug!("Done!");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ fn check_sequence(
|
||||
|
||||
impl FunctionSlices {
|
||||
pub fn end(&self) -> Option<SectionAddress> {
|
||||
self.blocks.last_key_value().map(|(_, &end)| end).flatten()
|
||||
self.blocks.last_key_value().and_then(|(_, &end)| end)
|
||||
}
|
||||
|
||||
pub fn start(&self) -> Option<SectionAddress> {
|
||||
@@ -404,7 +404,7 @@ impl FunctionSlices {
|
||||
// Likely __noreturn
|
||||
}
|
||||
(None, Some(e)) => {
|
||||
log::info!("{:#010X?}", self);
|
||||
log::warn!("{:#010X?}", self);
|
||||
bail!("Unpaired epilogue {:#010X}", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,8 +403,9 @@ impl Tracker {
|
||||
from: SectionAddress,
|
||||
addr: u32,
|
||||
) -> Option<SectionAddress> {
|
||||
if let Some((&start, &end)) = obj.blocked_ranges.range(..=from.address).next_back() {
|
||||
if from.address >= start && from.address < end {
|
||||
if let Some((&start, &end)) = obj.blocked_ranges.range(..=from).next_back() {
|
||||
if from.section == start.section && from.address >= start.address && from.address < end
|
||||
{
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user