[−][src]Struct p8n_types::Function
A single function in the binary.
A function is a set of basic blocks, with one serving as an entry point. Basic blocks form a control flow graph.
Each function also has a user-changeable name
and a unchangeable uuid
.
Fields
name: Str
Canonical name of the function. Can be anything.
names: Names
Table mapping SSA variable names to integers.
strings: Strings
Table mapping strings to integers.
segments: Segments
Table mapping segments identifiers to integers.
Methods
impl Function
[src]
pub fn new<A: Architecture>(
init: A::Configuration,
start: u64,
region: &Region,
uuid: UUID
) -> Result<Function>
[src]
init: A::Configuration,
start: u64,
region: &Region,
uuid: UUID
) -> Result<Function>
Creates a new function by disassembling from region
starting at start
.
pub fn known_cflow_graph<A>(
init: A::Configuration,
names: Names,
cfg: Vec<(Range<u64>, SmallVec<[(Value, Guard); 2]>)>,
entry: u64,
region: &Region,
uuid: UUID,
name: String
) -> Result<Function> where
A: Architecture,
[src]
init: A::Configuration,
names: Names,
cfg: Vec<(Range<u64>, SmallVec<[(Value, Guard); 2]>)>,
entry: u64,
region: &Region,
uuid: UUID,
name: String
) -> Result<Function> where
A: Architecture,
Disassemble a function with known control flow graph.
pub fn extend<A: Architecture>(
&mut self,
init: A::Configuration,
region: &Region
) -> Result<()>
[src]
&mut self,
init: A::Configuration,
region: &Region
) -> Result<()>
Continues disassembling of region
. The function looks for resolved, indirect control flow
edges.
pub fn entry_point(&self) -> BasicBlockIndex
[src]
Function entry point.
ⓘImportant traits for MnemonicIterator<'a>pub fn mnemonics<'a, Idx: IntoMnemonicRange + Sized>(
&'a self,
idx: Idx
) -> MnemonicIterator<'a>
[src]
&'a self,
idx: Idx
) -> MnemonicIterator<'a>
Iterator over all mnemonics in basic block idx
.
ⓘImportant traits for BasicBlockIterator<'a>pub fn basic_blocks<'a>(&'a self) -> BasicBlockIterator<'a>
[src]
Iterator over all basic blocks in reverse post order.
pub fn cflow_graph<'a>(&'a self) -> &'a Graph<CfgNode, Guard>
[src]
The Functions control flow graph.
pub fn basic_block<'a>(&'a self, idx: BasicBlockIndex) -> &'a BasicBlock
[src]
Returns a reference to the basic block idx
.
pub fn mnemonic<'a>(&'a self, idx: MnemonicIndex) -> &'a Mnemonic
[src]
Returns a reference to the mnemonic idx
.
pub fn uuid<'a>(&'a self) -> &'a UUID
[src]
The functions uuid.
pub fn region<'a>(&'a self) -> &'a UUID
[src]
The functions region.
pub fn statements<'a, Idx: IntoStatementRange + Sized>(
&'a self,
rgn: Idx
) -> StatementsIter<'a>
[src]
&'a self,
rgn: Idx
) -> StatementsIter<'a>
Iterator over all IL statements in rgn
.
pub fn first_address(&self) -> u64
[src]
Lowest address occupied by a basic block. Not neccecarly the entry point.
pub fn entry_address(&self) -> u64
[src]
First address of the functions entry basic block.
pub fn indirect_jumps<'a>(&'a self) -> IndirectJumps<'a>
[src]
Iterator over all indirect, unresolved jumps.
pub fn cflow_graph_mut<'a>(&'a mut self) -> &'a mut Graph<CfgNode, Guard>
[src]
Mutable reference to the control flow graph.
pub fn resolve_indirect_jumps<F: FnMut(&Variable) -> SmallVec<[Constant; 1]>>(
&mut self,
func: F
) -> bool
[src]
&mut self,
func: F
) -> bool
Calls func
on each indirect jump and call instruction and rewrites it to jump/call the
returned concrete addresses.
pub fn rewrite_basic_block<F: FnMut(&mut Statement, &mut Names, &mut Strings, &mut Segments) -> Result<RewriteControl> + Sized>(
&mut self,
basic_block: BasicBlockIndex,
func: F
) -> Result<()>
[src]
&mut self,
basic_block: BasicBlockIndex,
func: F
) -> Result<()>
Iterates thru all statements in basic_block
calling func
one each. The function is
allowed to modify the IL.
pub fn insert_mnemonic(
&mut self,
basic_block: BasicBlockIndex,
pos: usize,
opcode: StrRef,
args: SmallVec<[Value; 3]>,
stmts: Vec<Statement>
) -> Result<()>
[src]
&mut self,
basic_block: BasicBlockIndex,
pos: usize,
opcode: StrRef,
args: SmallVec<[Value; 3]>,
stmts: Vec<Statement>
) -> Result<()>
Inserts a new mnemonic at position pos
inside basic_block
with opcode
and semantics
described by stmts
.
pub fn remove_mnemonic(&mut self, mnemonic: MnemonicIndex) -> Result<()>
[src]
Removes mnemonic
.
pub fn drop_first_mnemonic(
&mut self,
basic_block: BasicBlockIndex
) -> Result<()>
[src]
&mut self,
basic_block: BasicBlockIndex
) -> Result<()>
Removes the first mnemonic of basic_block
. Fails of basic_block
has no mnemonics.
pub fn retain_basic_blocks<F: FnMut(&Function, BasicBlockIndex) -> bool>(
&mut self,
f: F
) -> Result<()>
[src]
&mut self,
f: F
) -> Result<()>
Deletes all basic blocks for which f
returns false
.
pub fn assemble(
name: Str,
names: Names,
segments: Segments,
region: UUID,
strings: Strings,
uuid: UUID,
start: u64,
mnemonics: Vec<(Mnemonic, Vec<Statement>)>,
by_source: HashMap<(u64, usize), Vec<(CfgTarget, Guard)>>,
by_destination: HashMap<(u64, usize), Vec<(CfgTarget, Guard)>>
) -> Result<Function>
[src]
name: Str,
names: Names,
segments: Segments,
region: UUID,
strings: Strings,
uuid: UUID,
start: u64,
mnemonics: Vec<(Mnemonic, Vec<Statement>)>,
by_source: HashMap<(u64, usize), Vec<(CfgTarget, Guard)>>,
by_destination: HashMap<(u64, usize), Vec<(CfgTarget, Guard)>>
) -> Result<Function>
Assembles a new function from a list of mnemonics and control flow edges. Used for deserializing functions.
pub fn pack(&mut self) -> Result<()>
[src]
Compresses the internal representation of the function. Call this if you're running low on memory.
pub fn unpack(&mut self) -> Result<()>
[src]
Uncompresses the function into a faster to process representation.
Trait Implementations
impl Clone for Function
[src]
fn clone(&self) -> Function
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Function
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,