ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Partitioner::FindInsnPadding Struct Reference

Callback to create inter-function instruction padding. More...

#include <Partitioner.h>

Inheritance diagram for Partitioner::FindInsnPadding:
Collaboration diagram for Partitioner::FindInsnPadding:

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< X86InstructionKindx86_kinds
 Kinds of x86 instructions allowed. More...
 
std::vector< SgUnsignedCharListbyte_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...
 

Detailed Description

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):

// Create the callback object and specify that padding
// consists of any combination of x86 NOP and INT3 instructions.
pad1.x86_kind.insert(x86_nop);
pad1.x86_kind.insert(x86_int3);
// Create a second callback that looks for instructions of
// any architecture that consist of 5 or more zero bytes.
zero.push_back(0x00);
zero.minimum_size = 5;
pad2.byte_patterns.push_back(zero);
// Build the callback list
cblist.append(&pad1);
cblist.append(&pad2);
// Run the callback(s) on the list, invoking them for
// contiguous sequences of instructions that are not yet
// assigned to functions and which appear between two
// functions.

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.

Constructor & Destructor Documentation

Partitioner::FindInsnPadding::FindInsnPadding ( )
inline

Definition at line 1288 of file Partitioner.h.

Member Function Documentation

Member Data Documentation

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.


The documentation for this struct was generated from the following files: