Unverified Commit 060884e9 by Enkelmann Committed by GitHub

Fix control flow for sequences of conditional assignments (#337)

parent 5621a04c
0.7-dev
====
0.6 (2022-06) 0.6 (2022-06)
==== ====
......
...@@ -128,7 +128,7 @@ dependencies = [ ...@@ -128,7 +128,7 @@ dependencies = [
[[package]] [[package]]
name = "cwe_checker" name = "cwe_checker"
version = "0.6.0" version = "0.7.0-dev"
dependencies = [ dependencies = [
"cwe_checker_lib", "cwe_checker_lib",
"directories", "directories",
...@@ -151,7 +151,7 @@ dependencies = [ ...@@ -151,7 +151,7 @@ dependencies = [
[[package]] [[package]]
name = "cwe_checker_lib" name = "cwe_checker_lib"
version = "0.6.0" version = "0.7.0-dev"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"apint", "apint",
......
[package] [package]
name = "cwe_checker" name = "cwe_checker"
version = "0.6.0" version = "0.7.0-dev"
authors = ["Nils-Edvin Enkelmann <nils-edvin.enkelmann@fkie.fraunhofer.de>"] authors = ["Nils-Edvin Enkelmann <nils-edvin.enkelmann@fkie.fraunhofer.de>"]
edition = "2021" edition = "2021"
......
[package] [package]
name = "cwe_checker_lib" name = "cwe_checker_lib"
version = "0.6.0" version = "0.7.0-dev"
authors = ["Nils-Edvin Enkelmann <nils-edvin.enkelmann@fkie.fraunhofer.de>"] authors = ["Nils-Edvin Enkelmann <nils-edvin.enkelmann@fkie.fraunhofer.de>"]
edition = "2021" edition = "2021"
......
use super::*; use super::*;
use crate::utils::log::LogMessage;
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
/// Contains implementation of the block duplication normalization pass.
mod block_duplication_normalization; mod block_duplication_normalization;
use crate::utils::log::LogMessage;
use block_duplication_normalization::*; use block_duplication_normalization::*;
/// Contains implementation of the propagate control flow normalization pass.
mod propagate_control_flow;
use propagate_control_flow::*;
/// The `Project` struct is the main data structure representing a binary. /// The `Project` struct is the main data structure representing a binary.
/// ///
...@@ -225,7 +230,10 @@ impl Project { ...@@ -225,7 +230,10 @@ impl Project {
/// - Duplicate blocks so that if a block is contained in several functions, each function gets its own unique copy. /// - Duplicate blocks so that if a block is contained in several functions, each function gets its own unique copy.
/// - Propagate input expressions along variable assignments. /// - Propagate input expressions along variable assignments.
/// - Replace trivial expressions like `a XOR a` with their result. /// - Replace trivial expressions like `a XOR a` with their result.
/// - Remove dead register assignments /// - Remove dead register assignments.
/// - Propagate the control flow along chains of conditionals with the same condition.
/// - Substitute bitwise `AND` and `OR` operations with the stack pointer
/// in cases where the result is known due to known stack pointer alignment.
#[must_use] #[must_use]
pub fn normalize(&mut self) -> Vec<LogMessage> { pub fn normalize(&mut self) -> Vec<LogMessage> {
let mut logs = let mut logs =
...@@ -234,6 +242,7 @@ impl Project { ...@@ -234,6 +242,7 @@ impl Project {
self.propagate_input_expressions(); self.propagate_input_expressions();
self.substitute_trivial_expressions(); self.substitute_trivial_expressions();
crate::analysis::dead_variable_elimination::remove_dead_var_assignments(self); crate::analysis::dead_variable_elimination::remove_dead_var_assignments(self);
propagate_control_flow(self);
logs.append( logs.append(
crate::analysis::stack_alignment_substitution::substitute_and_on_stackpointer(self) crate::analysis::stack_alignment_substitution::substitute_and_on_stackpointer(self)
.unwrap_or_default() .unwrap_or_default()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment