ROSE  0.9.10.89
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Rose::BinaryAnalysis::BestMapAddress Class Reference

Description

Finds best address for mapping code.

This analysis looks at function addresses and function calls to create two lists of addresses: entry addresses and target addresses, respectively. Only function calls using absolute addressing are considered. It then calculates how much the set of entry addresses should be shifted up or down in memory in order to best line up with target addresses. The assumption is that most of the function calls found by disassembling refer to functions that were also disassembled, and that by shifting the entire executable to higher or lower addresses we can get these to match up.

Definition at line 19 of file BinaryBestMapAddress.h.

#include <BinaryBestMapAddress.h>

Collaboration diagram for Rose::BinaryAnalysis::BestMapAddress:
Collaboration graph
[legend]

Classes

class  Exception
 Exceptions for this analysis. More...
 

Public Types

typedef Sawyer::Container::Set< rose_addr_t > AddressSet
 Set of addresses. More...
 

Public Member Functions

 BestMapAddress ()
 Construct an empty analysis. More...
 
void reset ()
 Clear gathered addresses. More...
 
rose_addr_t mask () const
 Property: Mask to use when doing address arithmetic. More...
 
void gatherAddresses (Partitioner2::Engine &engine)
 Gather addresses for future analysis. More...
 
void insertEntryAddress (rose_addr_t va)
 Insert a function entry address. More...
 
void insertTargetAddress (rose_addr_t va)
 Insert a call target address. More...
 
const AddressSetentryAddresses () const
 Returns set of entry addresses. More...
 
const AddressSettargetAddresses () const
 Returns set of target addresses. More...
 
BestMapAddressanalyze (const AddressInterval &restrictEntryAddresses=AddressInterval::whole(), const AddressInterval &restrictTargetAddresses=AddressInterval::whole())
 Analyze the addresses that have been provided. More...
 
const std::vector< rose_addr_t > & bestDeltas () const
 Return the best shift amounts. More...
 
double bestDeltaRatio () const
 How well the best shift amounts performed. More...
 
Progress::Ptr progress () const
 Property: Progress reporter. More...
 
void progress (const Progress::Ptr &p)
 Property: Progress reporter. More...
 
size_t nBits () const
 Property: Number of bits in an address. More...
 
void nBits (size_t n)
 Property: Number of bits in an address. More...
 

Static Public Member Functions

static void initDiagnostics ()
 Initialize diagnostic streams. More...
 

Static Public Attributes

static Diagnostics::Facility mlog
 Facility for emitting diagnostics. More...
 

Member Typedef Documentation

Set of addresses.

Definition at line 33 of file BinaryBestMapAddress.h.

Constructor & Destructor Documentation

Rose::BinaryAnalysis::BestMapAddress::BestMapAddress ( )
inline

Construct an empty analysis.

Definition at line 51 of file BinaryBestMapAddress.h.

Member Function Documentation

void Rose::BinaryAnalysis::BestMapAddress::reset ( )
inline

Clear gathered addresses.

Returns the analysis to its initial state but without clearing any properties that might have been configured. To clear the analysis and reset properties, assign a default constructed analysis.

Note this method is named "reset" instead of "clear" because it doesn't entirely clear the object in the sense that STL "clear" methods clear their objects.

Definition at line 61 of file BinaryBestMapAddress.h.

References Sawyer::Container::Set< T, C, A >::clear(), and Sawyer::Container::Map< K, T, Cmp, Alloc >::clear().

static void Rose::BinaryAnalysis::BestMapAddress::initDiagnostics ( )
static

Initialize diagnostic streams.

This is called automatically by Rose::Diagnostics::initialize.

Progress::Ptr Rose::BinaryAnalysis::BestMapAddress::progress ( ) const
inline

Property: Progress reporter.

Optional progress reporter object. If non-null, then some of the long-running methods will update this object with periodic progress reports.

Definition at line 80 of file BinaryBestMapAddress.h.

void Rose::BinaryAnalysis::BestMapAddress::progress ( const Progress::Ptr p)
inline

Property: Progress reporter.

Optional progress reporter object. If non-null, then some of the long-running methods will update this object with periodic progress reports.

Definition at line 81 of file BinaryBestMapAddress.h.

size_t Rose::BinaryAnalysis::BestMapAddress::nBits ( ) const
inline

Property: Number of bits in an address.

This analysis represents address deltas using the same C data type as addresses, namely rose_addr_t. Therefore, the analysis needs to know the total size of the address space in order to represent negative deltas. The address space size is stored as a power of two.

Functions that have enough information to determine the address space size (such as from a partitioner engine), set this property as part of their operation.

Returns zero if the address size is not yet known. An address space of size one is never valid.

Definition at line 96 of file BinaryBestMapAddress.h.

void Rose::BinaryAnalysis::BestMapAddress::nBits ( size_t  n)

Property: Number of bits in an address.

This analysis represents address deltas using the same C data type as addresses, namely rose_addr_t. Therefore, the analysis needs to know the total size of the address space in order to represent negative deltas. The address space size is stored as a power of two.

Functions that have enough information to determine the address space size (such as from a partitioner engine), set this property as part of their operation.

Returns zero if the address size is not yet known. An address space of size one is never valid.

rose_addr_t Rose::BinaryAnalysis::BestMapAddress::mask ( ) const

Property: Mask to use when doing address arithmetic.

This is the bit mask to use for doing address arithmetic. It has the N low-order bits set, where N is the number of bits stored in the nBits property.

void Rose::BinaryAnalysis::BestMapAddress::gatherAddresses ( Partitioner2::Engine engine)

Gather addresses for future analysis.

Given a configured partitioning engine with a memory map already defined, disassemble and partition the executable areas of the map that fall within the specified interval and create the two lists of addresses used by future analysis. See the class description for details about these lists.

Although calls to this method can be expensive, the progress report associated with this analyzer (if any) is not used; rather, the progress reporting associated with the engine is used instead.

void Rose::BinaryAnalysis::BestMapAddress::insertEntryAddress ( rose_addr_t  va)
inline

Insert a function entry address.

Inserts a function entry address into the set of addresses that will be used during later analysis.

Definition at line 119 of file BinaryBestMapAddress.h.

References Sawyer::Container::Set< T, C, A >::insert().

void Rose::BinaryAnalysis::BestMapAddress::insertTargetAddress ( rose_addr_t  va)
inline

Insert a call target address.

Insert the target address (i.e., the callee) of a function call into the set of addresses that will be used during later analysis.

Definition at line 128 of file BinaryBestMapAddress.h.

References Sawyer::Container::Set< T, C, A >::insert().

const AddressSet& Rose::BinaryAnalysis::BestMapAddress::entryAddresses ( ) const
inline

Returns set of entry addresses.

Definition at line 134 of file BinaryBestMapAddress.h.

const AddressSet& Rose::BinaryAnalysis::BestMapAddress::targetAddresses ( ) const
inline

Returns set of target addresses.

Definition at line 139 of file BinaryBestMapAddress.h.

BestMapAddress& Rose::BinaryAnalysis::BestMapAddress::analyze ( const AddressInterval restrictEntryAddresses = AddressInterval::whole(),
const AddressInterval restrictTargetAddresses = AddressInterval::whole() 
)

Analyze the addresses that have been provided.

Analyses all the previously provided addresses to find the best amounts by which to shift the entry addresses so they line up with the target addresses. Only those entry addresses and target addresses that fall within the specified intervals are used.

This method operates in parallel according to the global setting for the number of threads. That property is normally configured with the –threads command-line switch and stored in CommandlineProcessing::GenericSwitchArgs::threads.

If a progress reporting object has been configured for this analysis, then this method periodically updates it with progress reports.

Returns a reference to the analysis object so for easy chaining to a query.

const std::vector<rose_addr_t>& Rose::BinaryAnalysis::BestMapAddress::bestDeltas ( ) const

Return the best shift amounts.

Returns a list of the best shift amounts. Usually this is a single value, but in the case when multiple shift amounts tie for best, they're all returned.

double Rose::BinaryAnalysis::BestMapAddress::bestDeltaRatio ( ) const

How well the best shift amounts performed.

Returns a ratio between zero and one, inclusive, that indicates how will the best deltas performed. A return value of zero means that shifting the functions by any of the best deltas caused none of the function call targets to line up with functions, and a return value of one means all of them line up.

Member Data Documentation

Diagnostics::Facility Rose::BinaryAnalysis::BestMapAddress::mlog
static

Facility for emitting diagnostics.

Definition at line 36 of file BinaryBestMapAddress.h.


The documentation for this class was generated from the following file: