From 554709fc9c13d38195de9809dccff7af3ac2944b Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Thu, 29 Aug 2024 17:54:16 -0400 Subject: Don't rebase DWARF info in overflowing situations. This appears to fix a bug in a TriCore unit test for reasons I don't fully understand. --- rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'rust/examples') diff --git a/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs b/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs index d7ffb8c1..140e3af5 100644 --- a/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs +++ b/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs @@ -533,15 +533,17 @@ impl DebugInfoBuilder { } if let Some(address) = func.address.as_mut() { - 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 => { - warn!("Multiple existing functions at address {address:08x}. One or more functions at this address may have the wrong platform information. Please report this binary."); + let (diff, overflowed) = bv.start().overflowing_sub(bv.original_image_base()); + if !overflowed { + *address = (*address).overflowing_add(diff).0; // rebase the address + let existing_functions = bv.functions_at(*address); + match existing_functions.len().cmp(&1) { + Ordering::Greater => { + warn!("Multiple existing functions at address {address:08x}. One or more functions at this address may have the wrong platform information. Please report this binary."); + } + Ordering::Equal => func.platform = Some(existing_functions.get(0).platform()), + Ordering::Less => {} } - Ordering::Equal => func.platform = Some(existing_functions.get(0).platform()), - Ordering::Less => {} } } } -- cgit v1.3.1