|
@ -512,24 +512,28 @@ where |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Find all landing pads by scanning bytes, do not care about
|
|
|
// Find all landing pads by scanning bytes, do not care about
|
|
|
// false location at this moment.
|
|
|
// false location at this moment.
|
|
|
// Looks hacky but it is fast; does not need to be really exact.
|
|
|
// Looks hacky but it is fast; does not need to be really exact.
|
|
|
for i in 0..buf.len() - 2 { |
|
|
if buf.len() > 2 { |
|
|
let op = buf[i]; |
|
|
for i in 0..buf.len() - 2 { |
|
|
if op == gimli::constants::DW_OP_bra.0 || op == gimli::constants::DW_OP_skip.0 { |
|
|
let op = buf[i]; |
|
|
// TODO fix for big-endian
|
|
|
if op == gimli::constants::DW_OP_bra.0 || op == gimli::constants::DW_OP_skip.0 { |
|
|
let offset = i16::from_le_bytes([buf[i + 1], buf[i + 2]]); |
|
|
// TODO fix for big-endian
|
|
|
let origin = i + 3; |
|
|
let offset = i16::from_le_bytes([buf[i + 1], buf[i + 2]]); |
|
|
// Discarding out-of-bounds jumps (also some of falsely detected ops)
|
|
|
let origin = i + 3; |
|
|
if (offset >= 0 && offset as usize + origin <= buf.len()) |
|
|
// Discarding out-of-bounds jumps (also some of falsely detected ops)
|
|
|
|| (offset < 0 && -offset as usize <= origin) |
|
|
if (offset >= 0 && offset as usize + origin <= buf.len()) |
|
|
{ |
|
|
|| (offset < 0 && -offset as usize <= origin) |
|
|
let target = buf.len() as isize - origin as isize - offset as isize; |
|
|
{ |
|
|
jump_targets.insert(target as u64, JumpTargetMarker::new()); |
|
|
let target = buf.len() as isize - origin as isize - offset as isize; |
|
|
|
|
|
jump_targets.insert(target as u64, JumpTargetMarker::new()); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
while !pc.is_empty() { |
|
|
while !pc.is_empty() { |
|
|
let unread_bytes = pc.len().into_u64(); |
|
|
let unread_bytes = pc.len().into_u64(); |
|
|
if let Some(marker) = jump_targets.get(&unread_bytes) { |
|
|
if let Some(marker) = jump_targets.get(&unread_bytes) { |
|
|