ROSE
0.9.6a
|
Callback to create inter-function instruction padding. More...
#include <Partitioner.h>
Public Member Functions | |
FindInsnPadding () | |
virtual bool | operator() (bool enabled, const Args &args) |
The actual callback function. More... | |
Public Member Functions inherited from Partitioner::InsnRangeCallback | |
virtual | ~InsnRangeCallback () |
Public Attributes | |
std::set< X86InstructionKind > | x86_kinds |
Kinds of x86 instructions allowed. More... | |
std::vector< SgUnsignedCharList > | byte_patterns |
Match instructions with specified byte patterns. More... | |
bool | begins_contiguously |
Must immediately follow the end of a function? More... | |
bool | ends_contiguously |
Must immediately precede the beginning of a func? More... | |
size_t | minimum_size |
Minimum size in bytes. More... | |
bool | add_as_data |
If true, create data otherwise create a function. More... | |
size_t | nfound |
Number of padding areas found by this callback. More... | |
Callback to create inter-function instruction padding.
This callback can be passed to the scan_interfunc_insns() method's callback list. Whenever it detects a contiguous sequence of one or more of the specified instructions (in any order) immediately after the end of a function it will either create a new SgAsmFunction::FUNC_INTERPAD function to hold the padding, or add the padding as data to the end of the preceding function.
Here's an example of how to use this (see the post_cfg() method for actual use):
If we want padding to be a sequence of either NOP instructions or INT3 instructions but not a mixture of both, then we would create two callback objects, one for NOP and one for INT3. They can both be added to the callback list for a single invocation of scan_interfunc_insns(), or we can make two separate calls to scan_interfunc_insns(). Likewise, if we had added the zero byte pattern to the first callback instead of creating a second callback, the padding could consist of any combination of NOP, INT3, or zero bytes.
See also FindDataPadding, which doesn't need pre-existing instructions.
Definition at line 1279 of file Partitioner.h.
|
inline |
Definition at line 1288 of file Partitioner.h.
|
virtual |
The actual callback function.
This needs to be defined in subclasses.
Implements Partitioner::InsnRangeCallback.
Definition at line 1959 of file Partitioner.C.
References Partitioner::add_function(), Partitioner::BasicBlock::address(), Partitioner::append(), SgAsmBlock::BLK_PADDING, Partitioner::debug, Partitioner::discard(), Partitioner::Function::entry_va, Partitioner::find_bb_containing(), Partitioner::find_bb_starting(), Partitioner::find_db_starting(), Partitioner::find_instruction(), SgAsmFunction::FUNC_PADDING, Partitioner::BasicBlock::function, Partitioner::Instruction::get_address(), SgAsmx86Instruction::get_kind(), Partitioner::Instruction::get_raw_bytes(), Partitioner::Instruction::get_size(), Partitioner::InsnRangeCallback::Args::insn_begin, Partitioner::InsnRangeCallback::Args::insn_end, Partitioner::InsnRangeCallback::Args::insn_prev, Partitioner::BasicBlock::insns, isSgAsmx86Instruction(), Partitioner::InsnRangeCallback::Args::ninsns, and Partitioner::InsnRangeCallback::Args::partitioner.
std::set<X86InstructionKind> Partitioner::FindInsnPadding::x86_kinds |
Kinds of x86 instructions allowed.
Definition at line 1280 of file Partitioner.h.
std::vector<SgUnsignedCharList> Partitioner::FindInsnPadding::byte_patterns |
Match instructions with specified byte patterns.
Definition at line 1281 of file Partitioner.h.
bool Partitioner::FindInsnPadding::begins_contiguously |
Must immediately follow the end of a function?
Definition at line 1282 of file Partitioner.h.
bool Partitioner::FindInsnPadding::ends_contiguously |
Must immediately precede the beginning of a func?
Definition at line 1283 of file Partitioner.h.
size_t Partitioner::FindInsnPadding::minimum_size |
Minimum size in bytes.
Definition at line 1284 of file Partitioner.h.
bool Partitioner::FindInsnPadding::add_as_data |
If true, create data otherwise create a function.
Definition at line 1285 of file Partitioner.h.
size_t Partitioner::FindInsnPadding::nfound |
Number of padding areas found by this callback.
Definition at line 1286 of file Partitioner.h.