pub struct Project {
    pub program: Term<Program>,
    pub cpu_architecture: String,
    pub stack_pointer_register: Variable,
    pub calling_conventions: BTreeMap<String, CallingConvention>,
    pub register_set: BTreeSet<Variable>,
    pub datatype_properties: DatatypeProperties,
    pub runtime_memory_image: RuntimeMemoryImage,
}
Expand description

The Project struct is the main data structure representing a binary.

It contains information about the disassembled binary and about the execution environment of the binary.

Fields§

§program: Term<Program>

All (known) executable code of the binary is contained in the program term.

§cpu_architecture: String

The CPU architecture on which the binary is assumed to be executed.

§stack_pointer_register: Variable

The stack pointer register for the given CPU architecture.

§calling_conventions: BTreeMap<String, CallingConvention>

The known calling conventions that may be used for calls to extern functions.

§register_set: BTreeSet<Variable>

The set of all known physical registers for the CPU architecture. Does only contain base registers, i.e. sub registers of other registers are not contained.

§datatype_properties: DatatypeProperties

Contains the properties of C data types. (e.g. size)

§runtime_memory_image: RuntimeMemoryImage

Represents the memory after loading the binary.

Implementations§

source§

impl Project

source

pub fn get_pointer_bytesize(&self) -> ByteSize

Return the size (in bytes) for pointers of the given architecture.

source

pub fn get_standard_calling_convention(&self) -> Option<&CallingConvention>

Try to guess a standard calling convention from the list of calling conventions in the project.

source

pub fn get_specific_calling_convention( &self, cconv_name_opt: &Option<String> ) -> Option<&CallingConvention>

Try to find a specific calling convention in the list of calling conventions in the project. If not given a calling convention (i.e. given None) or the given calling convention name was not found then falls back to get_standard_calling_convention.

source

pub fn get_calling_convention( &self, extern_symbol: &ExternSymbol ) -> &CallingConvention

Return the calling convention associated to the given extern symbol. If the extern symbol has no annotated calling convention then return the standard calling convention of the project instead.

This function panics if no suitable calling convention is found.

source§

impl Project

source

pub fn substitute_trivial_expressions(&mut self)

For all expressions contained in the project, replace trivially computable subexpressions like a XOR a with their result.

source

pub fn normalize_basic(&mut self) -> Vec<LogMessage>

Performs only the normalizations necessary to analyze the project.

Runs only the normalization passes that bring the project to a form in which it can be consumed by the later analyses. Currently those are:

  • Removal of duplicate TIDs. (This is a workaround for a bug in the P-Code-Extractor and should be removed once the bug is fixed.)
  • Replacement of references to nonexisting TIDs with jumps to artificial sink targets in the CFG.
  • Duplication of blocks so that if a block is contained in several functions, each function gets its own unique copy.
  • Replacement of return addresses for calls to non-returning functions with artificial sink targets.

After those passes all of the later analyses can be computed. However, they are expected to run faster if you also run Project::normalize_optimize beforehand.

source

pub fn normalize_optimize(&mut self) -> Vec<LogMessage>

Performs only the optimizing normalization passes.

Project::normalize_basic must be called before this method.

Runs only the optimization passes that transform the program to an equivalent, simpler representation. This step is exprected to improve the speed and precision of later analyses.

Currently, the following optimizations are performed:

  • Propagate input expressions along variable assignments.
  • Replace trivial expressions like a XOR a with their result.
  • 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.
source

pub fn normalize(&mut self) -> Vec<LogMessage>

Run all normalization passes over the project.

Convenience wrapper that calls Project::normalize_basic and Project::normalize_optimize.

Trait Implementations§

source§

impl<'a> AsRef<Project> for Context<'a>

source§

fn as_ref(&self) -> &Project

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for Project

source§

fn clone(&self) -> Project

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Project

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Project

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq for Project

source§

fn eq(&self, other: &Project) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Project

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Project

source§

impl StructuralEq for Project

source§

impl StructuralPartialEq for Project

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,