mirror of
https://github.com/encounter/objdiff.git
synced 2025-12-20 02:15:24 +00:00
Improve ARM function size inference
This allows 2-byte padding to be trimmed in ARM functions. Resolves #253
This commit is contained in:
@@ -460,12 +460,16 @@ impl Arch for ArchArm {
|
||||
section: &Section,
|
||||
mut next_address: u64,
|
||||
) -> Result<u64> {
|
||||
// Trim any trailing 4-byte zeroes from the end (padding)
|
||||
while next_address >= symbol.address + 4
|
||||
&& let Some(data) = section.data_range(next_address - 4, 4)
|
||||
&& data == [0u8; 4]
|
||||
// TODO: This should probably check the disasm mode and trim accordingly,
|
||||
// but self.disasm_modes isn't populated until post_init, so it needs a refactor.
|
||||
|
||||
// Trim any trailing 2-byte zeroes from the end (padding)
|
||||
while next_address >= symbol.address + 2
|
||||
&& let Some(data) = section.data_range(next_address - 2, 2)
|
||||
&& data == [0u8; 2]
|
||||
&& section.relocation_at(next_address - 2, 2).is_none()
|
||||
{
|
||||
next_address -= 4;
|
||||
next_address -= 2;
|
||||
}
|
||||
Ok(next_address.saturating_sub(symbol.address))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user