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
impl Project
sourcepub fn get_pointer_bytesize(&self) -> ByteSize
pub fn get_pointer_bytesize(&self) -> ByteSize
Return the size (in bytes) for pointers of the given architecture.
sourcepub fn get_standard_calling_convention(&self) -> Option<&CallingConvention>
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.
sourcepub fn get_specific_calling_convention(
&self,
cconv_name_opt: &Option<String>
) -> Option<&CallingConvention>
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
.
sourcepub fn get_calling_convention(
&self,
extern_symbol: &ExternSymbol
) -> &CallingConvention
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
impl Project
sourcepub fn substitute_trivial_expressions(&mut self)
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.
sourcepub fn normalize_basic(&mut self) -> Vec<LogMessage>
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.
sourcepub fn normalize_optimize(&mut self) -> Vec<LogMessage>
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
andOR
operations with the stack pointer in cases where the result is known due to known stack pointer alignment.
sourcepub fn normalize(&mut self) -> Vec<LogMessage>
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<'de> Deserialize<'de> for Project
impl<'de> Deserialize<'de> for Project
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for Project
impl PartialEq for Project
impl Eq for Project
impl StructuralEq for Project
impl StructuralPartialEq for Project
Auto Trait Implementations§
impl RefUnwindSafe for Project
impl Send for Project
impl Sync for Project
impl Unpin for Project
impl UnwindSafe for Project
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.