mirror of
https://github.com/encounter/objdiff.git
synced 2025-08-03 18:55:43 +00:00
parent
dd653329f5
commit
c917cad5f0
@ -19,4 +19,4 @@ authors = ["Luke Street <luke@street.dev>"]
|
||||
edition = "2024"
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/encounter/objdiff"
|
||||
rust-version = "1.85"
|
||||
rust-version = "1.88"
|
||||
|
@ -205,10 +205,18 @@ fn infer_symbol_sizes(symbols: &mut [Symbol], sections: &[Section]) {
|
||||
}
|
||||
iter_idx += 1;
|
||||
};
|
||||
let next_address = next_symbol.map(|s| s.address).unwrap_or_else(|| {
|
||||
let section = §ions[section_idx];
|
||||
section.address + section.size
|
||||
});
|
||||
let section = §ions[section_idx];
|
||||
let mut next_address =
|
||||
next_symbol.map(|s| s.address).unwrap_or_else(|| section.address + section.size);
|
||||
if section.kind == SectionKind::Code {
|
||||
// For functions, trim any trailing 4-byte zeroes from the end (padding, nops)
|
||||
while next_address > symbol.address + 4
|
||||
&& let Some(data) = section.data_range(next_address - 4, 4)
|
||||
&& data == [0u8; 4]
|
||||
{
|
||||
next_address -= 4;
|
||||
}
|
||||
}
|
||||
let new_size = next_address.saturating_sub(symbol.address);
|
||||
if new_size > 0 {
|
||||
let symbol = &mut symbols[symbol_idx];
|
||||
@ -218,7 +226,7 @@ fn infer_symbol_sizes(symbols: &mut [Symbol], sections: &[Section]) {
|
||||
}
|
||||
// Set symbol kind if unknown and size is non-zero
|
||||
if symbol.kind == SymbolKind::Unknown {
|
||||
symbol.kind = match sections[section_idx].kind {
|
||||
symbol.kind = match section.kind {
|
||||
SectionKind::Code => SymbolKind::Function,
|
||||
SectionKind::Data | SectionKind::Bss => SymbolKind::Object,
|
||||
_ => SymbolKind::Unknown,
|
||||
|
Loading…
x
Reference in New Issue
Block a user