diff options
| author | Alexander Taylor <alex@vector35.com> | 2024-08-22 19:33:14 -0400 |
|---|---|---|
| committer | Alexander Taylor <alex@vector35.com> | 2024-08-22 19:35:31 -0400 |
| commit | 0af300011820ba28fde1ae8da8ae5a47c1c805ca (patch) | |
| tree | a7d1d1e1358cd5fcec5a6ba36a8ce369a2580cb3 /rust/examples | |
| parent | 3f497bcebd9da0e60a39edcadffbc017a8509b18 (diff) | |
Use add/sub with overflow when rebasing, fix crash.
Found this while testing some MSP430 binaries with the new support being
added. I had the logic correct, but forgot to tell Rust that overflow
was expected.
Diffstat (limited to 'rust/examples')
| -rw-r--r-- | rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs b/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs index 3e5cc1bf..d7ffb8c1 100644 --- a/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs +++ b/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs @@ -533,8 +533,8 @@ impl DebugInfoBuilder { } if let Some(address) = func.address.as_mut() { - let diff = bv.start() - bv.original_image_base(); - *address += diff; // rebase the address + let diff = bv.start().overflowing_sub(bv.original_image_base()).0; + *address = (*address).overflowing_add(diff).0; // rebase the address let existing_functions = bv.functions_at(*address); match existing_functions.len().cmp(&1) { Ordering::Greater => { |
