diff --git a/src/analysis/cfa.rs b/src/analysis/cfa.rs index aea65a3..0646cba 100644 --- a/src/analysis/cfa.rs +++ b/src/analysis/cfa.rs @@ -56,6 +56,10 @@ impl SectionAddress { } pub fn is_aligned(self, align: u32) -> bool { self.address & (align - 1) == 0 } + + pub fn wrapping_add(self, rhs: u32) -> Self { + Self { section: self.section, address: self.address.wrapping_add(rhs) } + } } impl Add for SectionAddress { diff --git a/src/analysis/vm.rs b/src/analysis/vm.rs index a84046f..2439f91 100644 --- a/src/analysis/vm.rs +++ b/src/analysis/vm.rs @@ -208,11 +208,11 @@ impl VM { ( GprValue::Address(RelocationTarget::Address(left)), GprValue::Constant(right), - ) => GprValue::Address(RelocationTarget::Address(left + right)), + ) => GprValue::Address(RelocationTarget::Address(left.wrapping_add(right))), ( GprValue::Constant(left), GprValue::Address(RelocationTarget::Address(right)), - ) => GprValue::Address(RelocationTarget::Address(right + left)), + ) => GprValue::Address(RelocationTarget::Address(right.wrapping_add(left))), _ => GprValue::Unknown, }; self.gpr[ins.field_rd() as usize].set_direct(value);