summaryrefslogtreecommitdiff
path: root/plugins/warp/src
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-07-15 06:11:11 -0400
committerMason Reed <mason@vector35.com>2025-07-15 12:34:43 -0400
commitd6c098813fde016e225c4ee072f38cd69d9783f0 (patch)
treed60f2339a21652e779ec84041512c00c73b803ab /plugins/warp/src
parent4a49ba509bdc0b4ffa650fc8461738c2085161c7 (diff)
[WARP] Fallback to using segment information for relocatable ranges
This previously was not allowed as the information would sometimes include a zero based segment, however this is still preferable in the case of firmware, where sections will not be available by default. This improves the usability of WARP with firmware by removing the requirement of filling section information prior to function analysis.
Diffstat (limited to 'plugins/warp/src')
-rw-r--r--plugins/warp/src/lib.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/plugins/warp/src/lib.rs b/plugins/warp/src/lib.rs
index 39f39e1c..dd94ada0 100644
--- a/plugins/warp/src/lib.rs
+++ b/plugins/warp/src/lib.rs
@@ -393,11 +393,28 @@ pub fn is_address_relocatable(relocatable_regions: &[Range<u64>], address: u64)
/// Currently, this is all the sections, however, this might be refined later.
pub fn relocatable_regions(view: &BinaryView) -> Vec<Range<u64>> {
// NOTE: We cannot use segments here as there will be a zero-based segment.
- view.sections()
+ let mut ranges: Vec<_> = view
+ .sections()
.iter()
.map(|s| Range {
start: s.start(),
end: s.end(),
})
- .collect()
+ .collect();
+
+ // If the only section available is the synthetic one, fallback to using the segments.
+ // NOTE: This should only happen for firmware, and it should be _fine_ considering that we
+ // do not use segments for the case where we are based at some zero offset. The user should have
+ // based the image somewhere reasonably.
+ // TODO: Restrict this to only when image base is above some value?
+ if ranges.len() <= 1 {
+ let segment_ranges = view
+ .segments()
+ .iter()
+ .map(|s| s.address_range())
+ .collect::<Vec<_>>();
+ ranges.extend(segment_ranges);
+ }
+
+ ranges
}