Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions crates/r2dec/src/analysis/use_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1955,10 +1955,8 @@ fn arg_slot_for_value_ref(
..
},
..
} => {
if root.var != value_ref.var {
return arg_slot_for_value_ref(info, root, env, arg_slot_map, depth + 1);
}
} if root.var != value_ref.var => {
return arg_slot_for_value_ref(info, root, env, arg_slot_map, depth + 1);
}
_ => {}
}
Expand Down
12 changes: 6 additions & 6 deletions crates/r2dec/src/fold/op_lower/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,12 +918,12 @@ impl<'a> FoldingContext<'a> {
branches_to_exit = true;
}
}
SSAOp::Store { addr, .. } => {
if branches_to_exit || self.is_current_return_context_candidate(block.addr) {
let offset = self.stack_slot_offset_for_var(addr);
if offset.is_some() {
return offset;
}
SSAOp::Store { addr, .. }
if branches_to_exit || self.is_current_return_context_candidate(block.addr) =>
{
let offset = self.stack_slot_offset_for_var(addr);
if offset.is_some() {
return offset;
}
}
_ => {}
Expand Down
5 changes: 1 addition & 4 deletions crates/r2ssa/src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2076,10 +2076,7 @@ fn canonicalize_value_root(root: &SSAVar, roots: &BTreeMap<SSAVar, SSAVar>) -> S
let mut current = root.clone();
let mut seen = HashSet::new();

loop {
let Some(next) = roots.get(&current) else {
break;
};
while let Some(next) = roots.get(&current) {
if *next == current || !seen.insert(current.clone()) {
break;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/r2ssa/src/phi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl PhiPlacement {
let mut placement = Self::new();

let mut defs_by_name: Vec<(&String, &HashSet<u64>)> = defs.iter().collect();
defs_by_name.sort_unstable_by(|(lhs, _), (rhs, _)| lhs.cmp(rhs));
defs_by_name.sort_unstable_by_key(|(lhs, _)| *lhs);

for (var_name, def_blocks) in defs_by_name {
let mut def_list: Vec<u64> = def_blocks.iter().copied().collect();
Expand Down
24 changes: 11 additions & 13 deletions crates/r2ssa/src/semantic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,16 +456,16 @@ fn collect_access_summaries(
uses.push(location);
defs.push(location);
}
SSAOp::Call { .. } | SSAOp::CallInd { .. } => {
if call_sites.by_inst.contains_key(&inst_id) {
let location = MemoryLocation {
object: escaped_unknown,
offset: 0,
size: 0,
};
uses.push(location);
defs.push(location);
}
SSAOp::Call { .. } | SSAOp::CallInd { .. }
if call_sites.by_inst.contains_key(&inst_id) =>
{
let location = MemoryLocation {
object: escaped_unknown,
offset: 0,
size: 0,
};
uses.push(location);
defs.push(location);
}
_ => {}
}
Expand Down Expand Up @@ -899,10 +899,8 @@ fn canonical_value_root<'a>(facts: Option<&'a DecompilePrepFacts>, var: &'a SSAV
fn const_value(var: &SSAVar) -> Option<u64> {
let value_str = if let Some(value) = var.name.strip_prefix("const:") {
value
} else if let Some(value) = var.name.strip_prefix("ram:") {
value
} else {
return None;
var.name.strip_prefix("ram:")?
};
let value_str = value_str.split('_').next().unwrap_or(value_str);
if let Some(dec) = value_str
Expand Down
32 changes: 12 additions & 20 deletions crates/r2sym/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,19 +430,12 @@ impl<'ctx> SymValue<'ctx> {
bits: lo_bits,
..
},
) => {
if new_bits <= 64 {
let new_value = (*hi << *lo_bits) | *lo;
Self::Concrete {
value: new_value,
bits: new_bits,
taint,
}
} else {
let hi_bv = self.to_bv(ctx);
let lo_bv = other.to_bv(ctx);
let new_ast = hi_bv.concat(&lo_bv);
Self::symbolic_tainted(new_ast, new_bits, taint)
) if new_bits <= 64 => {
let new_value = (*hi << *lo_bits) | *lo;
Self::Concrete {
value: new_value,
bits: new_bits,
taint,
}
}
_ => {
Expand Down Expand Up @@ -577,17 +570,16 @@ impl<'ctx> SymValue<'ctx> {
},
) => {
let result_bits = (*bits).max(*b_bits);
if *b == 0 {
Self::Unknown {
match a.checked_div(*b) {
Some(value) => Self::Concrete {
value,
bits: result_bits,
taint,
}
} else {
Self::Concrete {
value: *a / *b,
},
None => Self::Unknown {
bits: result_bits,
taint,
}
},
}
}
_ => {
Expand Down
8 changes: 4 additions & 4 deletions r2plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -894,11 +894,11 @@ pub extern "C" fn r2il_block_jump(block: *const R2ILBlock) -> u64 {
match op {
R2ILOp::Branch { target }
| R2ILOp::Call { target }
| R2ILOp::CBranch { target, .. } => {
| R2ILOp::CBranch { target, .. }
// Only return if target is a constant (direct jump)
if target.space == r2il::SpaceId::Const || target.space == r2il::SpaceId::Ram {
return target.offset;
}
if target.space == r2il::SpaceId::Const || target.space == r2il::SpaceId::Ram =>
{
return target.offset;
}
_ => {}
}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.93.0"
channel = "1.97.1"
components = ["rustfmt", "clippy"]