ROSE  0.9.10.91
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
SgAsmFunction Class Reference

Description

Represents a synthesized function.

A function is a collection of blocks holding instructions (basic blocks) or static data. Instructions might have references to addresses or data which are described by symbols (not to be confused with the binary's symbol table) in the function's symbol table (get_symbol_table). Functions do not explicitly exist in a binary, but are synthesized by ROSE as part of the disassembly and partitioning steps. The individual instructions and/or individual static data areas need not cover a contiguous region of the address space. Some synthesized functions will likely not be a "function" or "produceure" in the strict sense of those words due to such factors as compiler optimizations, hand-coded routines, exception handling, non-local branching, shortcomings of ROSE's partitioning solvers, etc. In any case, each function will have one primary entry address. Although the AST requires that every function have its own basic block children, which have their own instructions (definition of "tree" data structures), logically two functions might share basic blocks, although this is uncommon.

Warning: Although currently basic blocks are direct children of function nodes in the AST, this may change in a future version of ROSE as new node types are introduced to describe scopes and control structures.

Definition at line 3179 of file binaryInstruction.C.

Inheritance diagram for SgAsmFunction:
Inheritance graph
[legend]
Collaboration diagram for SgAsmFunction:
Collaboration graph
[legend]

Classes

class  NodeSelector
 Selection functor for SgAsmFunction::get_extent(). More...
 

Public Types

enum  MayReturn {
  RET_UNKNOWN,
  RET_NEVER,
  RET_SOMETIMES,
  RET_ALWAYS
}
 Whether a function returns. More...
 
enum  FunctionReason {
  FUNC_NONE = 0x00000000,
  FUNC_EXCEPTION_HANDLER = 0x00008000,
  FUNC_ENTRY_POINT = 0x00010000,
  FUNC_CALL_TARGET = 0x00020000,
  FUNC_CALL_INSN = 0x00040000,
  FUNC_EH_FRAME = 0x00080000,
  FUNC_SYMBOL = 0x00100000,
  FUNC_PATTERN = 0x00200000,
  FUNC_GRAPH = 0x00400000,
  FUNC_USERDEF = 0x00800000,
  FUNC_PADDING = 0x01000000,
  FUNC_DISCONT = 0x02000000,
  FUNC_INSNHEAD = 0x04000000,
  FUNC_IMPORT = 0x08000000,
  FUNC_LEFTOVERS = 0x10000000,
  FUNC_INTRABLOCK = 0x20000000,
  FUNC_THUNK = 0x40000000,
  FUNC_EXPORT = 0x80000000,
  FUNC_DEFAULT = 0xefff80ff,
  FUNC_MISCMASK = 0x000000ff,
  FUNC_INTERPADFUNC = 1,
  FUNC_PESCRAMBLER_DISPATCH = 2,
  FUNC_CONFIGURED = 3,
  FUNC_CMDLINE = 4,
  FUNC_SCAN_RO_DATA = 5,
  FUNC_INSN_RO_DATA = 6
}
 Reasons why an instruction might be considered the beginning of a function. More...
 
enum  function_kind_enum {
  e_unknown = 0,
  e_standard = 1,
  e_library = 2,
  e_imported = 3,
  e_thunk = 4,
  e_last
}
 Constants for the "function_kind" property. More...
 
- Public Types inherited from SgAsmSynthesizedDeclaration
enum  { static_variant = V_SgAsmSynthesizedDeclaration }
 static variant value
 
typedef SgAsmStatement base_node_type
 
- Public Types inherited from SgNode
enum  { static_variant = V_SgNode }
 static variant value
 

Public Member Functions

int nrOfValidInstructions (std::vector< SgNode * > &succs) ROSE_DEPRECATED("use modern CFG classes instead")
 
void append_statement (SgAsmStatement *)
 Adds statement to end of statement list. More...
 
void remove_statement (SgAsmStatement *statement)
 Erases statement from statement list. More...
 
void append_dest (SgAsmStatement *instruction) ROSE_DEPRECATED("apparently not used anywhere")
 
void remove_children ()
 Removes all statements. More...
 
SgAsmBlockget_entry_block () const
 Function entry basic block. More...
 
std::string reason_str (bool pad) const
 Returns a very short string describing the reason mask. More...
 
size_t get_extent (AddressIntervalSet *emap=NULL, rose_addr_t *lo_addr=NULL, rose_addr_t *hi_addr=NULL, NodeSelector *selector=NULL)
 Returns information about the function addresses. More...
 
bool get_sha1 (uint8_t digest[20], NodeSelector *selector=NULL)
 Computes the SHA1 message digest for the bytes of a function. More...
 
const std::string & get_name () const
 Property: Name. More...
 
void set_name (const std::string &)
 Property: Name. More...
 
unsigned get_reason () const
 Property: Reason that function exists. More...
 
void set_reason (unsigned)
 Property: Reason that function exists. More...
 
const std::string & get_reasonComment () const
 Property: Additional function existance reason comment. More...
 
void set_reasonComment (const std::string &)
 Property: Additional function existance reason comment. More...
 
function_kind_enum get_function_kind () const
 Property: Kind of function. More...
 
void set_function_kind (function_kind_enum)
 Property: Kind of function. More...
 
MayReturn get_may_return () const
 Property: Whether a function could return to its caller.
 
void set_may_return (MayReturn)
 Property: Whether a function could return to its caller.
 
const std::string & get_name_md5 () const
 Property: Hash of the function. More...
 
void set_name_md5 (const std::string &)
 Property: Hash of the function. More...
 
const SgAsmStatementPtrList & get_statementList () const
 Property: Statements that make up a function. More...
 
void set_statementList (const SgAsmStatementPtrList &)
 Property: Statements that make up a function. More...
 
rose_addr_t get_entry_va () const
 Property: Primary entry address. More...
 
void set_entry_va (rose_addr_t)
 Property: Primary entry address. More...
 
SgSymbolTableget_symbol_table () const
 Property: Symbol table. More...
 
void set_symbol_table (SgSymbolTable *)
 Property: Symbol table. More...
 
int64_t get_stackDelta () const
 Property: Net effect of function on the stack pointer. More...
 
void set_stackDelta (int64_t)
 Property: Net effect of function on the stack pointer. More...
 
const std::string & get_callingConvention () const
 Property: Primary calling convention. More...
 
void set_callingConvention (const std::string &)
 Property: Primary calling convention. More...
 
- Public Member Functions inherited from SgAsmSynthesizedDeclaration
virtual SgNodecopy (SgCopyHelp &help) const ROSE_OVERRIDE
 This function clones the current IR node object recursively or not, depending on the argument. More...
 
virtual std::string class_name () const ROSE_OVERRIDE
 returns a string representing the class name
 
virtual VariantT variantT () const ROSE_OVERRIDE
 returns new style SageIII enum values
 
void * operator new (size_t size)
 returns pointer to newly allocated IR node
 
void operator delete (void *pointer, size_t size)
 deallocated memory for IR node (returns memory to memory pool for reuse)
 
virtual std::vector< SgNode * > get_traversalSuccessorContainer () ROSE_OVERRIDE
 container of pointers to AST successor nodes used in the traversal overridden in every class by generated implementation
 
virtual std::vector< std::string > get_traversalSuccessorNamesContainer () ROSE_OVERRIDE
 container of names of variables or container indices used used in the traversal to access AST successor nodes overridden in every class by generated implementation
 
virtual size_t get_numberOfTraversalSuccessors () ROSE_OVERRIDE
 return number of children in the traversal successor list
 
virtual SgNodeget_traversalSuccessorByIndex (size_t idx) ROSE_OVERRIDE
 index-based access to traversal successors by index number
 
virtual size_t get_childIndex (SgNode *child) ROSE_OVERRIDE
 index-based access to traversal successors by child node
 
virtual RTIReturnType roseRTI () ROSE_OVERRIDE
 return C++ Runtime-Time-Information
 
virtual const char * sage_class_name () const ROSE_OVERRIDE ROSE_DEPRECATED_FUNCTION
 
void executeVisitorMemberFunction (ROSE_VisitorPattern &visitor)
 FOR INTERNAL USE Support for visitor pattern.
 
virtual void accept (ROSE_VisitorPattern &visitor) ROSE_OVERRIDE
 support for the classic visitor pattern done in GoF
 
virtual bool isInMemoryPool () ROSE_OVERRIDE
 FOR INTERNAL USE This is used in internal tests to verify that all IR nodes are allocated from the heap. More...
 
virtual void checkDataMemberPointersIfInMemoryPool () ROSE_OVERRIDE
 FOR INTERNAL USE This is used in internal tests to verify that all IR nodes are allocated from the heap. More...
 
virtual std::vector< std::pair< SgNode *, std::string > > returnDataMemberPointers () const ROSE_OVERRIDE
 FOR INTERNAL USE Returns STL vector of pairs of SgNode* and strings for use in AST tools More...
 
virtual void processDataMemberReferenceToPointers (ReferenceToPointerHandler *) ROSE_OVERRIDE
 FOR INTERNAL USE Processes pairs of references to SgNode* and strings for use in AST tools More...
 
virtual long getChildIndex (SgNode *childNode) const ROSE_OVERRIDE
 FOR INTERNAL USE Returns a unique index value for the childNode in the list of children at this IR node. More...
 
 SgAsmSynthesizedDeclaration (const SgAsmSynthesizedDeclarationStorageClass &source)
 IR node constructor to support AST File I/O.
 
SgAsmSynthesizedDeclarationaddRegExpAttribute (std::string s, AstRegExAttribute *a)
 Support for AST matching using regular expression. More...
 
 SgAsmSynthesizedDeclaration (rose_addr_t address=0)
 
- Public Member Functions inherited from SgAsmStatement
rose_addr_t get_address () const
 Property: Starting virtual address. More...
 
void set_address (rose_addr_t)
 Property: Starting virtual address. More...
 
const std::string & get_comment () const
 Property: Commentary.
 
void set_comment (const std::string &)
 Property: Commentary.
 
- Public Member Functions inherited from SgNode
void * operator new (size_t size)
 returns pointer to newly allocated IR node
 
void operator delete (void *pointer, size_t size)
 deallocated memory for IR node (returns memory to memory pool for reuse)
 
void executeVisitorMemberFunction (ROSE_VisitorPattern &visitor)
 FOR INTERNAL USE Support for visitor pattern.
 
 SgNode (const SgNodeStorageClass &source)
 IR node constructor to support AST File I/O.
 
SgNodeaddRegExpAttribute (std::string s, AstRegExAttribute *a)
 Support for AST matching using regular expression. More...
 
void set_isModified (bool isModified)
 All nodes in the AST contain a isModified flag used to track changes to the AST. More...
 
void set_containsTransformation (bool containsTransformation)
 Many nodes can hide other AST nodes and we need to track when outer nodes contain modified nodes even if they are not themselves modified. More...
 
bool get_isModified () const
 Acess function for isModified flag. More...
 
bool get_containsTransformation () const
 Acess function for containsTransformation flag. More...
 
void set_parent (SgNode *parent)
 All nodes in the AST contain a reference to a parent node. More...
 
SgNodeget_parent () const
 Access function for parent node. More...
 
bool isChild (SgNode *node) const
 Query function for if the input IR nodes is a child of the current IR node.
 
virtual std::string unparseToString (SgUnparse_Info *info) const
 This function unparses the AST node (excluding comments and unnecessary white space)
 
std::string unparseToString () const
 
std::string unparseToCompleteString ()
 This function unparses the AST node (including comments and white space) More...
 
int variant () const ROSE_DEPRECATED_FUNCTION
 Older version function returns enum value "NODE". More...
 
virtual void addNewAttribute (std::string s, AstAttribute *a)
 Add a new attribute represented by the named string.
 
virtual AstAttribute * getAttribute (std::string s) const
 Returns attribute of name 's'.
 
virtual void updateAttribute (std::string s, AstAttribute *a)
 Replace existing attribute of name 's' with new AstAttribute.
 
virtual void setAttribute (std::string s, AstAttribute *a)
 This is a wrapper function with the following semantics: if no attribute of name 's' exists then addNewAttribute(s,a); is called, otherwise updateAttribute(s,a); is called.
 
virtual void removeAttribute (std::string s)
 Remove attribute of name 's' if present.
 
virtual bool attributeExists (std::string s) const
 Tests if attribute of name 's' is present.
 
virtual int numberOfAttributes () const
 Returns the number of attributes on this IR node.
 
virtual AstAttributeMechanism * get_attributeMechanism () const
 FOR INTERNAL USE Access function; if an attribute exists then a pointer to it is returned, else error. More...
 
virtual void set_attributeMechanism (AstAttributeMechanism *a)
 FOR INTERNAL USE Access function; sets poiner to value AstAttributeMechanism. More...
 
virtual void fixupCopy (SgNode *copy, SgCopyHelp &help) const
 
virtual Sg_File_Infoget_file_info (void) const
 File information containing filename, line number, column number, and if the SgNode is a part of a new transformation, etc.
 
virtual Sg_File_Infoget_startOfConstruct (void) const
 New function interface for Sg_File_Info data stores starting location of contruct (typically the opening brace or first letter of keyword).
 
virtual Sg_File_Infoget_endOfConstruct (void) const
 New function interface for Sg_File_Info data stores ending location of contruct (typically the closing brace).
 
VirtualCFG::CFGNode cfgForBeginning ()
 Returns the CFG node for just before this AST node.
 
VirtualCFG::CFGNode cfgForEnd ()
 Returns the CFG node for just after this AST node.
 
virtual unsigned int cfgIndexForEnd () const
 Determine the CFG index for the end of this construct.
 
virtual bool cfgIsIndexInteresting (unsigned int index) const
 Determine whether a particular CFG node index is "interesting" for this kind of node.
 
virtual unsigned int cfgFindChildIndex (SgNode *n)
 Find the index of n in this node's CFG children.
 
virtual unsigned int cfgFindNextChildIndex (SgNode *n)
 Find the index just after n in this node's CFG children.
 
virtual std::vector< VirtualCFG::CFGEdgecfgOutEdges (unsigned int index=false)
 Find the out edges of a CFG node – internal version.
 
virtual std::vector< VirtualCFG::CFGEdgecfgInEdges (unsigned int index=false)
 Find the in edges of a CFG node – internal version.
 
int numberOfNodesInSubtree ()
 Computes the number of nodes in the defined subtree of the AST. More...
 
int depthOfSubtree ()
 Computes the depth of the current defined subtree of the AST. More...
 
SgNodeget_freepointer () const
 
void set_freepointer (SgNode *freepointer)
 
virtual ~SgNode ()
 This is the destructor. More...
 
 SgNode ()
 This is the constructor. More...
 
bool get_isVisited () const ROSE_DEPRECATED_FUNCTION
 DOCS IN HEADER: Access function for p_isVisited flag used previously by the AST traversals. More...
 
void set_isVisited (bool isVisited) ROSE_DEPRECATED_FUNCTION
 Access function for p_isVisited flag used previously by the AST traversals. More...
 

Static Public Member Functions

static std::string reason_key (const std::string &prefix="")
 Multi-line description of function reason keys from unparser. More...
 
static std::string reason_str (bool pad, unsigned reason)
 Class method that converts a reason bit vector to a human-friendly string. More...
 
- Static Public Member Functions inherited from SgAsmSynthesizedDeclaration
static size_t numberOfNodes ()
 ROSETTA generated delete operator: deletes all non-traversed members. More...
 
static size_t memoryUsage ()
 Returns the size in bytes of the total memory allocated for all IR nodes of this type.
 
static void traverseMemoryPoolNodes (ROSE_VisitTraversal &visit)
 FOR INTERNAL USE Support for visitor pattern over all IR nodes by type of IR node.
 
static void traverseMemoryPoolVisitorPattern (ROSE_VisitorPattern &visitor)
 FOR INTERNAL USE Support for visitor pattern.
 
static void visitRepresentativeNode (ROSE_VisitTraversal &visit)
 FOR INTERNAL USE Support for type-based traversal.
 
static SgAsmSynthesizedDeclarationbuild_node_from_nonlist_children (rose_addr_t address=0)
 
- Static Public Member Functions inherited from SgNode
static size_t numberOfNodes ()
 ROSETTA generated delete operator: deletes all non-traversed members. More...
 
static size_t memoryUsage ()
 Returns the size in bytes of the total memory allocated for all IR nodes of this type.
 
static void traverseMemoryPoolNodes (ROSE_VisitTraversal &visit)
 FOR INTERNAL USE Support for visitor pattern over all IR nodes by type of IR node.
 
static void traverseMemoryPoolVisitorPattern (ROSE_VisitorPattern &visitor)
 FOR INTERNAL USE Support for visitor pattern.
 
static void visitRepresentativeNode (ROSE_VisitTraversal &visit)
 FOR INTERNAL USE Support for type-based traversal.
 
static std::vector< std::string > buildCommandLineToSubstituteTransformationFile (const std::vector< std::string > &argv, std::string newFileName)
 Command line support for this compilation The command line is saved as a static variable so that it will be available to support the rewrite mechanism. More...
 
static std::vector< VariantT > getClassHierarchySubTreeFunction (VariantT v)
 
static void getClassHierarchySubTreeFunction (VariantT v, std::vector< VariantT > &)
 
static std::map< SgNode *, std::string > & get_globalMangledNameMap ()
 Access function for performance optimizing global mangled name map. More...
 
static void clearGlobalMangledNameMap ()
 Support to clear the performance optimizing global mangled name map.
 
static std::map< std::string, int > & get_shortMangledNameCache ()
 Access function for lower level optimizing of global mangled name map. More...
 
static std::map< SgNode *, std::string > & get_globalQualifiedNameMapForNames ()
 Access function for name qualification support (for names). More...
 
static void set_globalQualifiedNameMapForNames (const std::map< SgNode *, std::string > &X)
 Access function for name qualification support (for names). More...
 
static std::map< SgNode *, std::string > & get_globalQualifiedNameMapForTypes ()
 Access function for name qualification support (for type). More...
 
static void set_globalQualifiedNameMapForTypes (const std::map< SgNode *, std::string > &X)
 Access function for name qualification support (for type). More...
 
static std::map< SgNode *, std::string > & get_globalQualifiedNameMapForTemplateHeaders ()
 Access function for name qualification support (for template headers in template declarations). More...
 
static void set_globalQualifiedNameMapForTemplateHeaders (const std::map< SgNode *, std::string > &X)
 Access function for name qualification support (for template headers in template declarations). More...
 
static std::map< SgNode *, std::string > & get_globalTypeNameMap ()
 Access function for name qualification support (for names of types). More...
 
static void set_globalTypeNameMap (const std::map< SgNode *, std::string > &X)
 Access function for name qualification support (for names of types). More...
 
static SgFunctionTypeTableget_globalFunctionTypeTable ()
 Access function for symbol table specific to function types.
 
static void set_globalFunctionTypeTable (SgFunctionTypeTable *globalFunctionTypeTable)
 Access function for symbol table specific to function types.
 
static SgTypeTableget_globalTypeTable ()
 Access function for symbol table specific to non-function types.
 
static void set_globalTypeTable (SgTypeTable *globalTypeTable)
 Access function for symbol table specific to non-function types.
 
static SgNodebuild_node_from_nonlist_children ()
 

Additional Inherited Members

- Protected Member Functions inherited from SgNode
virtual void post_construction_initialization ()
 Final initialization for constructors This function is called at the end of generated constructors to allow the specification writer to add special initialization functions or tests. Default is to do nothing. Otherwise it should be overridden in the spec file, in NewHeaderCode/NewOutlinedCode.
 
- Protected Attributes inherited from SgNode
SgNodep_parent
 This is the pointer to the parent IR node in the AST. More...
 
bool p_isModified
 Records if IR node has been modified (data members reset). More...
 
bool p_containsTransformation
 
SgNodep_freepointer
 This is the pointer to the chain of previously freed objects.
 
- Static Protected Attributes inherited from SgNode
static SgFunctionTypeTablep_globalFunctionTypeTable
 Pointer to symbol table specific to function types.
 
static SgTypeTablep_globalTypeTable
 
static std::map< SgNode *, std::string > p_globalMangledNameMap
 Cache of mangled names to avoid regeneration of previously build mangled names or parts of mangled names. This is a performance optimization.
 
static std::map< std::string, int > p_shortMangledNameCache
 STL map used as a cache to shorten generated mangled names. This is mostly a space optimization ofr mangled names of templates.
 
static std::map< SgNode *, std::string > p_globalQualifiedNameMapForNames
 
static std::map< SgNode *, std::string > p_globalQualifiedNameMapForTypes
 
static std::map< SgNode *, std::string > p_globalQualifiedNameMapForTemplateHeaders
 
static std::map< SgNode *, std::string > p_globalTypeNameMap
 

Member Enumeration Documentation

Whether a function returns.

Enumerator
RET_UNKNOWN 

It is unknown whether this function ever returns or not.

RET_NEVER 

This function is known to never return.

RET_SOMETIMES 

This function may return or not, depending on how it is called.

RET_ALWAYS 

This function returns each time it is called.

Definition at line 3415 of file binaryInstruction.C.

Reasons why an instruction might be considered the beginning of a function.

These bit flags are also used by the instruction partitioner (Partitioner class) to determine what heuristics are used when partitioning instructions into functions.

Enumerator
FUNC_NONE 

Used for initialization; not a bit flag.

FUNC_EXCEPTION_HANDLER 

Function for handling an exception.

FUNC_ENTRY_POINT 

An entry point specified in the file header.

FUNC_CALL_TARGET 

Target of a function call instruction sequence in the CFG.

When used as a partitioning heuristic, the partitioner will create new functions when it discovers a call-like sequence while traversing the CFG.

FUNC_CALL_INSN 

Target of call, possibly not in the CFG (see Partitioner::mark_call_insns).

When used as a partitioning heuristic, the partitioner will search all available instructions for instances of call-like instructions and define a function for each target. The function entry points added in this way become initial nodes of the CFG which is used by some of the other function discovery methods, including FUNC_CALL_TARGET.

FUNC_EH_FRAME 

Address mentioned in the ELF .eh_frame section.

FUNC_SYMBOL 

Address of a function symbol in a symbol table.

FUNC_PATTERN 

Appears to be a function based on pattern of instructions.

When used as a partitioning heuristic, the partitioner will search through all available instructions and create function entry points. The function entry points are added to the CFG which is used by some of the other function discovery methods.

FUNC_GRAPH 

Implied by inter-basicblock branching.

When used as a partitioning heuristic, the partitioner creates a new function when it discovers, by CFG traversal, that two different functions branch to a common basic block. The block in common becomes a new function under this rule.

FUNC_USERDEF 

User-defined algorithm.

See Partitioner::addFunctionDetector().

FUNC_PADDING 

Created to represent NOP padding between other functions.

When used as a partitioning heuristic, the partitioner searches for padding after all CFG-based analysis has completed. Padding can consist of either NOP instructions or zero bytes. The former requires that instructions at the interfunction addresses have been disassembled.

FUNC_DISCONT 

Blocks of function are not contiguous in memory.

This is not a partitioner heuristic, but rather only an indication of whether the function's basic blocks occupy contiguous memory locations.

FUNC_INSNHEAD 

Initial instructions not in any other function.

(UNUSED?)

FUNC_IMPORT 

Functions dynamically linked.

For ELF containers, these are the entries in the procedure lookup table (PLT). When used as a partitioning heuristic, the partitioner will scan the PLT and define a function for each entry.

FUNC_LEFTOVERS 

Generated function to hold blocks that are otherwise not part of any function.

If this bit is turned off then the instruction Partitioner will delete instructions that it couldn't assign to a function.

FUNC_INTRABLOCK 

Function contains basic blocks that were inserted by searching the address space between the blocks discovered by analyzing the control flow.

Blocks added by this algorithm do not take control flow into account, and therefore, the global control flow graph (CFG) may have edges into the middle of such blocks, or such blocks may have edges into the middle of other blocks, including inter-function edges. Also, blocks added by this method might not represent true instructions, but rather data that was disassembled as instructions.

FUNC_THUNK 

Function is a thunk.

Thunks are small pieces of code whose only purpose is to branch to another function. Depending on how the disassembler and partitioner are run, a thunk can exist either as its own function or the thunk's instructions will be subsumed by the called function. The partitioner only sets this flag for functions that are created due to the thunk recognition pass; other functions that don't have this bit set might also be thunks, and functions that have this bit set might not be a thunk. The Partitioner::is_thunk() method will return true for functions whose content looks like a thunk.

FUNC_EXPORT 

Exported function.

These are the functions that appear in a PE export table.

FUNC_DEFAULT 

Default value for Partitioner class.

FUNC_MISCMASK 

Miscellaneous.

These are all the other special purpose function detectors that are implemented in the Partitioner. Each one is identified by an eight-bit integer stored in the low order bits. Only one such reason can be stored at a time. These are not used to control which partitioning heuristics to use, but rather to indicate which one (of possibly many) that detected the function.

FUNC_INTERPADFUNC 

Detected by Partitioner::FindInterPadFunctions, which looks for unassigned space between two inter-function padding blocks and makes the first such address the beginning of one of these functions.

FUNC_PESCRAMBLER_DISPATCH 

Dispatcher function for code generated by pescrambler.

FUNC_CONFIGURED 

Function is defined in a configuration file.

FUNC_CMDLINE 

Function mentioned on the command-line.

FUNC_SCAN_RO_DATA 

Address was found in read-only data area by scanning the data.

FUNC_INSN_RO_DATA 

Address was found in read-only data referenced by an existing instruction.

Definition at line 3425 of file binaryInstruction.C.

Constants for the "function_kind" property.

Definition at line 3580 of file binaryInstruction.C.

Member Function Documentation

const std::string& SgAsmFunction::get_name ( ) const

Property: Name.

The optional string name of a function.

void SgAsmFunction::set_name ( const std::string &  )

Property: Name.

The optional string name of a function.

unsigned SgAsmFunction::get_reason ( ) const

Property: Reason that function exists.

This is a bit vector of enum constants that describe why this function was created. See SgAsmFunction::FunctionReason for details.

void SgAsmFunction::set_reason ( unsigned  )

Property: Reason that function exists.

This is a bit vector of enum constants that describe why this function was created. See SgAsmFunction::FunctionReason for details.

const std::string& SgAsmFunction::get_reasonComment ( ) const

Property: Additional function existance reason comment.

This reason comment gets filled in automatically by certain function analyses. It's a free-form string that contains additional information about why this function exists and is used in conjunction with the get_reason property.

void SgAsmFunction::set_reasonComment ( const std::string &  )

Property: Additional function existance reason comment.

This reason comment gets filled in automatically by certain function analyses. It's a free-form string that contains additional information about why this function exists and is used in conjunction with the get_reason property.

function_kind_enum SgAsmFunction::get_function_kind ( ) const

Property: Kind of function.

This enum constant describes the kind of function. See SgAsmFunction::function_kind_enum for details.

void SgAsmFunction::set_function_kind ( function_kind_enum  )

Property: Kind of function.

This enum constant describes the kind of function. See SgAsmFunction::function_kind_enum for details.

const std::string& SgAsmFunction::get_name_md5 ( ) const

Property: Hash of the function.

This is unused by ROSE, but can be set by users to identify a function by hash string.

void SgAsmFunction::set_name_md5 ( const std::string &  )

Property: Hash of the function.

This is unused by ROSE, but can be set by users to identify a function by hash string.

const SgAsmStatementPtrList& SgAsmFunction::get_statementList ( ) const

Property: Statements that make up a function.

The "statements" of a function are things like instructions, static data blocks, etc.

void SgAsmFunction::set_statementList ( const SgAsmStatementPtrList &  )

Property: Statements that make up a function.

The "statements" of a function are things like instructions, static data blocks, etc.

rose_addr_t SgAsmFunction::get_entry_va ( ) const

Property: Primary entry address.

Every function has one primary entry address that uniquely identifies the function in the AST. This is the starting address of the function's entry instruction. The abbreviation "va" means "virtual address".

Referenced by Rose::BinaryAnalysis::ControlFlow::fixup_fcall_fret().

void SgAsmFunction::set_entry_va ( rose_addr_t  )

Property: Primary entry address.

Every function has one primary entry address that uniquely identifies the function in the AST. This is the starting address of the function's entry instruction. The abbreviation "va" means "virtual address".

SgSymbolTable* SgAsmFunction::get_symbol_table ( ) const

Property: Symbol table.

A ROSE symbol table associated with this function. This is not the same as the symbol table that appears in the binary specimen, such as ELF or PE symbol tables.

void SgAsmFunction::set_symbol_table ( SgSymbolTable )

Property: Symbol table.

A ROSE symbol table associated with this function. This is not the same as the symbol table that appears in the binary specimen, such as ELF or PE symbol tables.

int64_t SgAsmFunction::get_stackDelta ( ) const

Property: Net effect of function on the stack pointer.

Net effect that this function has on the machine's stack pointer register. For most x86 Linux ELF specimens the net effect is to pop the return address from the stack, thus +4 for 32-bit specimens and +8 for 64-bit specimens.

If the stack delta analysis has not run or could not determine a constant stack delta, then the special value SgAsmInstruction::INVALID_STACK_DELTA is used.

void SgAsmFunction::set_stackDelta ( int64_t  )

Property: Net effect of function on the stack pointer.

Net effect that this function has on the machine's stack pointer register. For most x86 Linux ELF specimens the net effect is to pop the return address from the stack, thus +4 for 32-bit specimens and +8 for 64-bit specimens.

If the stack delta analysis has not run or could not determine a constant stack delta, then the special value SgAsmInstruction::INVALID_STACK_DELTA is used.

const std::string& SgAsmFunction::get_callingConvention ( ) const

Property: Primary calling convention.

This is the name of the primary calling convention for this function. When the semantics of the function match multiple calling convention definitions, this property holds the "best" one for some definition of "best". It is also possible for the semantics to not match any calling convention definition in which case this property is empty. It is also empty if the calling convention analysis was not performed.

void SgAsmFunction::set_callingConvention ( const std::string &  )

Property: Primary calling convention.

This is the name of the primary calling convention for this function. When the semantics of the function match multiple calling convention definitions, this property holds the "best" one for some definition of "best". It is also possible for the semantics to not match any calling convention definition in which case this property is empty. It is also empty if the calling convention analysis was not performed.

void SgAsmFunction::append_statement ( SgAsmStatement )

Adds statement to end of statement list.

void SgAsmFunction::remove_statement ( SgAsmStatement statement)

Erases statement from statement list.

If the specified statement is found in the list of statements then it is erased without being deleted.

void SgAsmFunction::remove_children ( )

Removes all statements.

Clears the statement list without deleting any of them.

SgAsmBlock* SgAsmFunction::get_entry_block ( ) const

Function entry basic block.

Returns the basic block that represents the function primary entry point. Returns null for a function that contains no instructions.

Referenced by Rose::BinaryAnalysis::ControlFlow::build_cg_from_ast(), and Rose::BinaryAnalysis::FunctionCall::build_cg_from_cfg().

static std::string SgAsmFunction::reason_key ( const std::string &  prefix = "")
static

Multi-line description of function reason keys from unparser.

Returns a string that describes what the one-letter function reasons mean in the unparser output.

std::string SgAsmFunction::reason_str ( bool  pad) const

Returns a very short string describing the reason mask.

static std::string SgAsmFunction::reason_str ( bool  pad,
unsigned  reason 
)
static

Class method that converts a reason bit vector to a human-friendly string.

The second argument is the bit vector of SgAsmFunction::FunctionReason bits.

size_t SgAsmFunction::get_extent ( AddressIntervalSet emap = NULL,
rose_addr_t *  lo_addr = NULL,
rose_addr_t *  hi_addr = NULL,
NodeSelector selector = NULL 
)

Returns information about the function addresses.

Every non-empty function has a minimum (inclusive) and maximum (exclusive) address which are returned by reference, but not all functions own all the bytes within that range of addresses. Therefore, the exact bytes are returned by adding them to the optional ExtentMap argument. This function returns the number of nodes (instructions and static data items) in the function. If the function contains no nodes then extents is not modified and the low and high addresses are both set to zero.

If an selector functor is provided, then only nodes for which it returns true are considered part of the function. This can be used for such things as filtering out data blocks that are marked as padding. For example:

class NotPadding: public SgAsmFunction::NodeSelector {
public:
virtual bool operator()(SgNode *node) {
SgAsmStaticData *data = isSgAsmStaticData(node);
SgAsmBlock *block = SageInterface::getEnclosingNode<SgAsmBlock>(data);
return !data || !block || block->get_reason()!=SgAsmBlock::BLK_PADDING;
}
} notPadding;
function->get_extent(&extents, NULL, NULL, &notPadding);

Here's another example that calculates the extent of only the padding data, based on the negation of the filter in the previous example:

class OnlyPadding: public NotPadding {
public:
virtual bool operator()(SgNode *node) {
return !NotPadding::operator()(node);
}
} onlyPadding;
function->get_extent(&extents, NULL, NULL, &onlyPadding);
bool SgAsmFunction::get_sha1 ( uint8_t  digest[20],
NodeSelector selector = NULL 
)

Computes the SHA1 message digest for the bytes of a function.

Returns true if the SHA1 is available, false if the message digest cannot be computed because the prerequisite gcrypt functions are not available. The optional selector argument can be used to limit the digest to only certain nodes of the function; by default, all instructions and static data are accumulated.


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