ROSE 0.11.145.147
|
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 (symbolTable property). 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 16099 of file binaryInstruction.C.
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_THUNK_TARGET = 0x00004000 , 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 SgNode | |
enum | { static_variant = V_SgNode } |
static variant value More... | |
enum | { static_variant = V_SgNode } |
static variant value More... | |
Public Member Functions | |
SgAsmStatementPtrList const & | get_dest () const |
void | set_dest (SgAsmStatementPtrList const &) |
size_t const & | get_cachedVertex () const |
void | set_cachedVertex (size_t const &) |
void | appendStatement (SgAsmStatement *) |
Adds statement to end of statement list. | |
void | removeStatement (SgAsmStatement *statement) |
Erases statement from statement list. | |
SgAsmBlock * | get_entryBlock () const |
Function entry basic block. | |
std::string | reasonString (bool pad) const |
Returns a very short string describing the reason mask. | |
size_t | get_extent (Rose::BinaryAnalysis::AddressIntervalSet *emap=NULL, rose_addr_t *lo_addr=NULL, rose_addr_t *hi_addr=NULL, NodeSelector *selector=NULL) |
Returns information about the function addresses. | |
bool | get_sha1 (uint8_t digest[20], NodeSelector *selector=NULL) |
Computes the SHA1 message digest for the bytes of a function. | |
function_kind_enum | get_function_kind () const |
void | set_function_kind (function_kind_enum) |
MayReturn | get_may_return () const |
void | set_may_return (MayReturn) |
const std::string & | get_name_md5 () const |
void | set_name_md5 (const std::string &) |
rose_addr_t | get_entry_va () const |
void | set_entry_va (rose_addr_t) |
SgSymbolTable * | get_symbol_table () const |
void | set_symbol_table (SgSymbolTable *) |
size_t | get_cached_vertex () const |
void | set_cached_vertex (size_t) |
void | append_statement (SgAsmStatement *) |
void | remove_statement (SgAsmStatement *statement) |
SgAsmBlock * | get_entry_block () const |
std::string | reason_str (bool) const |
virtual | ~SgAsmFunction () |
Destructor. | |
SgAsmFunction () | |
Default constructor. | |
SgAsmFunction (rose_addr_t const &address, std::string const &name, unsigned const &reason, SgAsmFunction::function_kind_enum const &functionKind) | |
Constructor. | |
std::string const & | get_name () const |
Property: Name. | |
void | set_name (std::string const &) |
Property: Name. | |
unsigned const & | get_reason () const |
Property: Reason that function exists. | |
void | set_reason (unsigned const &) |
Property: Reason that function exists. | |
std::string const & | get_reasonComment () const |
Property: Additional function existance reason comment. | |
void | set_reasonComment (std::string const &) |
Property: Additional function existance reason comment. | |
SgAsmFunction::function_kind_enum const & | get_functionKind () const |
Property: Kind of function. | |
void | set_functionKind (SgAsmFunction::function_kind_enum const &) |
Property: Kind of function. | |
SgAsmFunction::MayReturn const & | get_mayReturn () const |
Property: Whether a function could return to its caller. | |
void | set_mayReturn (SgAsmFunction::MayReturn const &) |
Property: Whether a function could return to its caller. | |
std::string const & | get_nameMd5 () const |
Property: Hash of the function. | |
void | set_nameMd5 (std::string const &) |
Property: Hash of the function. | |
SgAsmStatementPtrList const & | get_statementList () const |
Property: Statements that make up a function. | |
SgAsmStatementPtrList & | get_statementList () |
Property: Statements that make up a function. | |
void | set_statementList (SgAsmStatementPtrList const &) |
Property: Statements that make up a function. | |
rose_addr_t const & | get_entryVa () const |
Property: Primary entry address. | |
void | set_entryVa (rose_addr_t const &) |
Property: Primary entry address. | |
SgSymbolTable *const & | get_symbolTable () const |
Property: Symbol table. | |
void | set_symbolTable (SgSymbolTable *const &) |
Property: Symbol table. | |
int64_t const & | get_stackDelta () const |
Property: Net effect of function on the stack pointer. | |
void | set_stackDelta (int64_t const &) |
Property: Net effect of function on the stack pointer. | |
std::string const & | get_callingConvention () const |
Property: Primary calling convention. | |
void | set_callingConvention (std::string const &) |
Property: Primary calling convention. | |
Public Member Functions inherited from SgAsmSynthesizedDeclaration | |
virtual | ~SgAsmSynthesizedDeclaration () |
Destructor. | |
Public Member Functions inherited from SgAsmStatement | |
virtual | ~SgAsmStatement () |
Destructor. | |
rose_addr_t const & | get_address () const |
Property: Starting virtual address. | |
void | set_address (rose_addr_t const &) |
Property: Starting virtual address. | |
std::string const & | get_comment () const |
Property: Commentary. | |
void | set_comment (std::string const &) |
Property: Commentary. | |
Public Member Functions inherited from SgAsmNode | |
virtual | ~SgAsmNode () |
Destructor. | |
Sawyer::Attribute::Storage const & | attributes () const |
Attribute storage. | |
Sawyer::Attribute::Storage & | attributes () |
Attribute storage. | |
Public Member Functions inherited from SgNode | |
virtual SgNode * | copy (SgCopyHelp &help) const |
virtual std::string | class_name () const |
returns a string representing the class name | |
virtual VariantT | variantT () const |
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) | |
void | operator delete (void *pointer) |
virtual size_t | get_numberOfTraversalSuccessors () |
return number of children in the traversal successor list | |
virtual SgNode * | get_traversalSuccessorByIndex (size_t idx) |
index-based access to traversal successors by index number | |
virtual size_t | get_childIndex (SgNode *child) |
index-based access to traversal successors by child node | |
virtual const char * | sage_class_name () const |
generates string representing the class name: (e.g. for SgNode returns "SgNode"). | |
void | executeVisitorMemberFunction (ROSE_VisitorPattern &visitor) |
FOR INTERNAL USE Support for visitor pattern. | |
virtual void | accept (ROSE_VisitorPattern &visitor) |
support for the classic visitor pattern done in GoF | |
virtual bool | isInMemoryPool () |
FOR INTERNAL USE This is used in internal tests to verify that all IR nodes are allocated from the heap. | |
virtual void | checkDataMemberPointersIfInMemoryPool () |
FOR INTERNAL USE This is used in internal tests to verify that all IR nodes are allocated from the heap. | |
virtual std::vector< std::pair< SgNode *, std::string > > | returnDataMemberPointers () const |
FOR INTERNAL USE Returns STL vector of pairs of SgNode* and strings for use in AST tools | |
virtual void | processDataMemberReferenceToPointers (ReferenceToPointerHandler *) |
FOR INTERNAL USE Processes pairs of references to SgNode* and strings for use in AST tools | |
virtual long | getChildIndex (SgNode *childNode) const |
FOR INTERNAL USE Returns a unique index value for the childNode in the list of children at this IR node. | |
SgNode (const SgNodeStorageClass &source) | |
IR node constructor to support AST File I/O. | |
SgNode * | addRegExpAttribute (std::string s, AstRegExAttribute *a) |
Support for AST matching using regular expression. | |
void | set_isModified (bool isModified) |
All nodes in the AST contain a isModified flag used to track changes to the AST. | |
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. | |
bool | get_isModified () const |
Acess function for isModified flag. | |
bool | get_containsTransformation () const |
Acess function for containsTransformation flag. | |
SgNode * | get_raw_parent () const |
Access function for direct access to uncomputed value of parent node. | |
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 |
int | variant () const |
Older version function returns enum value "NODE". | |
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. | |
virtual void | set_attributeMechanism (AstAttributeMechanism *a) |
FOR INTERNAL USE Access function; sets poiner to value AstAttributeMechanism. | |
virtual void | fixupCopy_scopes (SgNode *copy, SgCopyHelp &help) const |
virtual void | fixupCopy_symbols (SgNode *copy, SgCopyHelp &help) const |
virtual void | fixupCopy_references (SgNode *copy, SgCopyHelp &help) const |
virtual Sg_File_Info * | get_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_Info * | get_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_Info * | get_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::CFGEdge > | cfgOutEdges (unsigned int index=false) |
Find the out edges of a CFG node – internal version. | |
virtual std::vector< VirtualCFG::CFGEdge > | cfgInEdges (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. | |
int | depthOfSubtree () |
Computes the depth of the current defined subtree of the AST. | |
template<class T > | |
T * | initParentPointer (T *child, SgNode *parent) |
Generated for tree edge data member initializations. | |
SgNode * | get_freepointer () const |
void | set_freepointer (SgNode *freepointer) |
virtual | ~SgNode () |
This is the destructor. | |
SgNode () | |
This is the constructor. | |
virtual SgNode * | copy (SgCopyHelp &help) const |
virtual std::string | class_name () const |
returns a string representing the class name | |
virtual VariantT | variantT () const |
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) | |
void | operator delete (void *pointer) |
virtual std::vector< SgNode * > | get_traversalSuccessorContainer () |
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 () |
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 () |
return number of children in the traversal successor list | |
virtual SgNode * | get_traversalSuccessorByIndex (size_t idx) |
index-based access to traversal successors by index number | |
virtual size_t | get_childIndex (SgNode *child) |
index-based access to traversal successors by child node | |
virtual RTIReturnType | roseRTI () |
return C++ Runtime-Time-Information | |
virtual const char * | sage_class_name () const |
void | executeVisitorMemberFunction (ROSE_VisitorPattern &visitor) |
FOR INTERNAL USE Support for visitor pattern. | |
virtual void | accept (ROSE_VisitorPattern &visitor) |
support for the classic visitor pattern done in GoF | |
virtual bool | isInMemoryPool () |
FOR INTERNAL USE This is used in internal tests to verify that all IR nodes are allocated from the heap. | |
virtual void | checkDataMemberPointersIfInMemoryPool () |
FOR INTERNAL USE This is used in internal tests to verify that all IR nodes are allocated from the heap. | |
virtual std::vector< std::pair< SgNode *, std::string > > | returnDataMemberPointers () const |
FOR INTERNAL USE Returns STL vector of pairs of SgNode* and strings for use in AST tools | |
virtual void | processDataMemberReferenceToPointers (ReferenceToPointerHandler *) |
FOR INTERNAL USE Processes pairs of references to SgNode* and strings for use in AST tools | |
virtual long | getChildIndex (SgNode *childNode) const |
FOR INTERNAL USE Returns a unique index value for the childNode in the list of children at this IR node. | |
SgNode (const SgNodeStorageClass &source) | |
IR node constructor to support AST File I/O. | |
SgNode * | addRegExpAttribute (std::string s, AstRegExAttribute *a) |
Support for AST matching using regular expression. | |
void | set_isModified (bool isModified) |
All nodes in the AST contain a isModified flag used to track changes to the AST. | |
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. | |
bool | get_isModified () const |
Acess function for isModified flag. | |
bool | get_containsTransformation () const |
Acess function for containsTransformation flag. | |
void | set_parent (SgNode *parent) |
All nodes in the AST contain a reference to a parent node. | |
SgNode * | get_parent () const |
Access function for parent node. | |
SgNode * | get_raw_parent () const |
Access function for direct access to uncomputed value of parent node. | |
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) | |
int | variant () const |
bool | get_isVisited () const |
DOCS IN HEADER: Access function for p_isVisited flag used previously by the AST traversals. | |
void | set_isVisited (bool isVisited) |
Access function for p_isVisited flag used previously by the AST traversals. | |
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. | |
virtual void | set_attributeMechanism (AstAttributeMechanism *a) |
FOR INTERNAL USE Access function; sets poiner to value AstAttributeMechanism. | |
virtual void | fixupCopy_scopes (SgNode *copy, SgCopyHelp &help) const |
virtual void | fixupCopy_symbols (SgNode *copy, SgCopyHelp &help) const |
virtual void | fixupCopy_references (SgNode *copy, SgCopyHelp &help) const |
virtual Sg_File_Info * | get_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_Info * | get_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_Info * | get_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::CFGEdge > | cfgOutEdges (unsigned int index=false) |
Find the out edges of a CFG node – internal version. | |
virtual std::vector< VirtualCFG::CFGEdge > | cfgInEdges (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. | |
int | depthOfSubtree () |
Computes the depth of the current defined subtree of the AST. | |
template<class T > | |
T * | initParentPointer (T *child, SgNode *parent) |
Generated for tree edge data member initializations. | |
SgNode * | get_freepointer () const |
void | set_freepointer (SgNode *freepointer) |
virtual std::vector< SgNode * > | get_traversalSuccessorContainer () |
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 () |
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 RTIReturnType | roseRTI () |
return C++ Runtime-Time-Information | |
void | set_parent (SgNode *parent) |
All nodes in the AST contain a reference to a parent node. | |
SgNode * | get_parent () const |
Access function for parent node. | |
std::string | unparseToCompleteString () |
This function unparses the AST node (including comments and white space) | |
bool | get_isVisited () const |
DOCS IN HEADER: Access function for p_isVisited flag used previously by the AST traversals. | |
void | set_isVisited (bool isVisited) |
Access function for p_isVisited flag used previously by the AST traversals. | |
template<class T > | |
std::enable_if< std::is_pointer< T >::value, void >::type | changeChildPointer (T &edge, T const &child) |
Set a child edge in a tree to point to a specific child. | |
template<class T > | |
std::enable_if<!std::is_pointer< T >::value, void >::type | changeChildPointer (T &edge, T const &child) |
Set a child edge in a tree to point to a specific child. | |
template<class T > | |
std::enable_if< std::is_pointer< T >::value, void >::type | changeChildPointer (T &edge, T const &child) |
Set a child edge in a tree to point to a specific child. | |
template<class T > | |
std::enable_if<!std::is_pointer< T >::value, void >::type | changeChildPointer (T &edge, T const &child) |
Set a child edge in a tree to point to a specific child. | |
Static Public Member Functions | |
static std::string | reasonKey (const std::string &prefix="") |
Multi-line description of function reason keys from unparser. | |
static std::string | reasonString (bool pad, unsigned reason) |
Class method that converts a reason bit vector to a human-friendly string. | |
static std::string | reason_key (const std::string &prefix="") |
static std::string | reason_str (bool, unsigned) |
Static Public Member Functions inherited from SgNode | |
static void | deleteMemoryPool () |
static size_t | numberOfNodes () |
Returns the total number of IR nodes of this type. | |
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 SgNode * | getNodeByNodeId (VariantT variantT, size_t poolIdx, size_t itemIdx) |
Find a node by its variant type, pool index, and item index. | |
static SgNode * | getNodeByNodeIdInternal (size_t poolIdx, size_t itemIdx) |
FOR INTERNAL USE Find an SgNode from its memory pool and location therin. | |
static std::string | getNodeIdString (SgNode *sgnode) |
compute the NodeId for a particular SgNode*. | |
static std::string | getNodeIdStringInternal (SgNode *sgnode) |
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. | |
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. | |
static void | clearGlobalMangledNameMap () |
Support to clear the performance optimizing global mangled name map. | |
static std::map< std::string, uint64_t > & | get_shortMangledNameCache () |
Access function for lower level optimizing of global mangled name map. | |
static std::map< SgNode *, std::string > & | get_globalQualifiedNameMapForNames () |
Access function for name qualification support (for names). | |
static void | set_globalQualifiedNameMapForNames (const std::map< SgNode *, std::string > &X) |
Access function for name qualification support (for names). | |
static std::map< SgNode *, std::string > & | get_globalQualifiedNameMapForTypes () |
Access function for name qualification support (for type). | |
static void | set_globalQualifiedNameMapForTypes (const std::map< SgNode *, std::string > &X) |
Access function for name qualification support (for type). | |
static std::map< SgNode *, std::map< SgNode *, std::string > > & | get_globalQualifiedNameMapForMapsOfTypes () |
Access function for name qualification support (for maps of types). | |
static void | set_globalQualifiedNameMapForMapsOfTypes (const std::map< SgNode *, std::map< SgNode *, std::string > > &X) |
Access function for name qualification support (for maps of types). | |
static std::map< SgNode *, std::string > & | get_globalQualifiedNameMapForTemplateHeaders () |
Access function for name qualification support (for template headers in template declarations). | |
static void | set_globalQualifiedNameMapForTemplateHeaders (const std::map< SgNode *, std::string > &X) |
Access function for name qualification support (for template headers in template declarations). | |
static std::map< SgNode *, std::string > & | get_globalTypeNameMap () |
Access function for name qualification support (for names of types). | |
static void | set_globalTypeNameMap (const std::map< SgNode *, std::string > &X) |
Access function for name qualification support (for names of types). | |
static SgFunctionTypeTable * | get_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 SgTypeTable * | get_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 VariantT | variantFromPool (SgNode const *n) |
template<class T > | |
static std::enable_if< std::is_base_of< SgNode, T >::value, T * >::type | createAndParent (SgNode *parent) |
Allocate and return a new node after setting its parent. | |
static void | deleteMemoryPool () |
static size_t | numberOfNodes () |
Returns the total number of IR nodes of this type. | |
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 SgNode * | getNodeByNodeId (VariantT variantT, size_t poolIdx, size_t itemIdx) |
Find a node by its variant type, pool index, and item index. | |
static SgNode * | getNodeByNodeIdInternal (size_t poolIdx, size_t itemIdx) |
FOR INTERNAL USE Find an SgNode from its memory pool and location therin. | |
static std::string | getNodeIdString (SgNode *sgnode) |
compute the NodeId for a particular SgNode*. | |
static std::string | getNodeIdStringInternal (SgNode *sgnode) |
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. | |
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. | |
static void | clearGlobalMangledNameMap () |
Support to clear the performance optimizing global mangled name map. | |
static std::map< std::string, uint64_t > & | get_shortMangledNameCache () |
Access function for lower level optimizing of global mangled name map. | |
static std::map< SgNode *, std::string > & | get_globalQualifiedNameMapForNames () |
Access function for name qualification support (for names). | |
static void | set_globalQualifiedNameMapForNames (const std::map< SgNode *, std::string > &X) |
Access function for name qualification support (for names). | |
static std::map< SgNode *, std::string > & | get_globalQualifiedNameMapForTypes () |
Access function for name qualification support (for type). | |
static void | set_globalQualifiedNameMapForTypes (const std::map< SgNode *, std::string > &X) |
Access function for name qualification support (for type). | |
static std::map< SgNode *, std::map< SgNode *, std::string > > & | get_globalQualifiedNameMapForMapsOfTypes () |
Access function for name qualification support (for maps of types). | |
static void | set_globalQualifiedNameMapForMapsOfTypes (const std::map< SgNode *, std::map< SgNode *, std::string > > &X) |
Access function for name qualification support (for maps of types). | |
static std::map< SgNode *, std::string > & | get_globalQualifiedNameMapForTemplateHeaders () |
Access function for name qualification support (for template headers in template declarations). | |
static void | set_globalQualifiedNameMapForTemplateHeaders (const std::map< SgNode *, std::string > &X) |
Access function for name qualification support (for template headers in template declarations). | |
static std::map< SgNode *, std::string > & | get_globalTypeNameMap () |
Access function for name qualification support (for names of types). | |
static void | set_globalTypeNameMap (const std::map< SgNode *, std::string > &X) |
Access function for name qualification support (for names of types). | |
static SgFunctionTypeTable * | get_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 SgTypeTable * | get_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 VariantT | variantFromPool (SgNode const *n) |
template<class T > | |
static std::enable_if< std::is_base_of< SgNode, T >::value, T * >::type | createAndParent (SgNode *parent) |
Allocate and return a new node after setting its parent. | |
Protected Member Functions | |
void | initializeProperties () |
Initialize all properties that have explicit initial values. | |
Protected Member Functions inherited from SgAsmSynthesizedDeclaration | |
SgAsmSynthesizedDeclaration () | |
Default constructor. | |
SgAsmSynthesizedDeclaration (rose_addr_t const &address) | |
Constructor. | |
void | initializeProperties () |
Initialize all properties that have explicit initial values. | |
Protected Member Functions inherited from SgAsmStatement | |
SgAsmStatement () | |
Default constructor. | |
SgAsmStatement (rose_addr_t const &address) | |
Constructor. | |
void | initializeProperties () |
Initialize all properties that have explicit initial values. | |
Protected Member Functions inherited from SgAsmNode | |
SgAsmNode () | |
Default constructor. | |
void | initializeProperties () |
Initialize all properties that have explicit initial values. | |
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. | |
virtual void | destructorHelper () |
This gets called by all Rosebud-generated destructors. | |
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. | |
virtual void | destructorHelper () |
This gets called by all Rosebud-generated destructors. | |
virtual void | debugSerializationBegin (const char *className) |
Called by generated serializers. | |
virtual void | debugSerializationEnd (const char *className) |
Called by generated serializers. | |
virtual void | debugSerializationBegin (const char *className) |
Called by generated serializers. | |
virtual void | debugSerializationEnd (const char *className) |
Called by generated serializers. | |
Additional Inherited Members | |
Protected Attributes inherited from SgNode | |
SgNode * | p_parent |
This is the pointer to the parent IR node in the AST. | |
bool | p_isModified |
Records if IR node has been modified (data members reset). | |
bool | p_containsTransformation |
SgNode * | p_freepointer |
This is the pointer to the chain of previously freed objects. | |
Static Protected Attributes inherited from SgNode | |
static std::vector< std::tuple< unsigned char *, unsigned, VariantT > > | all_pools |
static SgFunctionTypeTable * | p_globalFunctionTypeTable |
Pointer to symbol table specific to function types. | |
static SgTypeTable * | p_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, uint64_t > | 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 |
static std::map< SgNode *, std::map< SgNode *, std::string > > | p_globalQualifiedNameMapForMapsOfTypes |
Whether a function returns.
Definition at line 16212 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_THUNK_TARGET | Function is the target of a thunk. |
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 16222 of file binaryInstruction.C.
Constants for the "function_kind" property.
Definition at line 16309 of file binaryInstruction.C.
std::string const & SgAsmFunction::get_name | ( | ) | const |
Property: Name.
The optional string name of a function.
Referenced by Rose::BinaryAnalysis::ControlFlow::write_graphviz().
void SgAsmFunction::set_name | ( | std::string const & | ) |
Property: Name.
The optional string name of a function.
unsigned const & 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 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.
std::string const & 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 reason property.
void SgAsmFunction::set_reasonComment | ( | std::string 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 reason property.
SgAsmFunction::function_kind_enum const & SgAsmFunction::get_functionKind | ( | ) | const |
Property: Kind of function.
This enum constant describes the kind of function. See SgAsmFunction::function_kind_enum for details.
void SgAsmFunction::set_functionKind | ( | SgAsmFunction::function_kind_enum const & | ) |
Property: Kind of function.
This enum constant describes the kind of function. See SgAsmFunction::function_kind_enum for details.
std::string const & SgAsmFunction::get_nameMd5 | ( | ) | 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_nameMd5 | ( | std::string const & | ) |
Property: Hash of the function.
This is unused by ROSE, but can be set by users to identify a function by hash string.
SgAsmStatementPtrList const & SgAsmFunction::get_statementList | ( | ) | const |
Property: Statements that make up a function.
The "statements" of a function are things like instructions, static data blocks, etc.
SgAsmStatementPtrList & SgAsmFunction::get_statementList | ( | ) |
Property: Statements that make up a function.
The "statements" of a function are things like instructions, static data blocks, etc.
void SgAsmFunction::set_statementList | ( | SgAsmStatementPtrList const & | ) |
Property: Statements that make up a function.
The "statements" of a function are things like instructions, static data blocks, etc.
rose_addr_t const & SgAsmFunction::get_entryVa | ( | ) | 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::FunctionCall::build_cg_from_ast(), Rose::BinaryAnalysis::ControlFlow::fixup_fcall_fret(), and Rose::BinaryAnalysis::ControlFlow::write_graphviz().
void SgAsmFunction::set_entryVa | ( | rose_addr_t 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".
SgSymbolTable *const & SgAsmFunction::get_symbolTable | ( | ) | 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_symbolTable | ( | SgSymbolTable *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.
int64_t const & 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 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.
std::string const & 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 | ( | std::string 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::removeStatement | ( | 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.
SgAsmBlock * SgAsmFunction::get_entryBlock | ( | ) | 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 |
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.
|
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 | ( | Rose::BinaryAnalysis::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:
Here's another example that calculates the extent of only the padding data, based on the negation of the filter in the previous example:
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.
|
protected |
Initialize all properties that have explicit initial values.
This function is mostly for use in user-defined constructors where the user desires to initialize all the properties but does not know the names of the data members that store the property values. This function initializes the properties that have explicit initializations within this class, but does not recursively initialize base classes.