#include <Cxx_Grammar.h>
Inheritance diagram for SgAsmGenericFile:


Public Types | |
| typedef SgAsmExecutableFileFormat | base_node_type |
| ADDRSP_MEMORY = 0x0001 | |
| ADDRSP_FILE = 0x0002 | |
| ADDRSP_ALL = 0x0003 | |
| ELASTIC_NONE = 0 | |
| ELASTIC_UNREF = 1 | |
| ELASTIC_HOLE = 2 | |
| static_variant = V_SgAsmGenericFile | |
| enum | AddressSpace { ADDRSP_MEMORY = 0x0001, ADDRSP_FILE = 0x0002, ADDRSP_ALL = 0x0003 } |
| enum | Elasticity { ELASTIC_NONE = 0, ELASTIC_UNREF = 1, ELASTIC_HOLE = 2 } |
| enum | { static_variant = V_SgAsmGenericFile } |
| static variant value More... | |
Public Member Functions | |
| virtual SgNode * | copy (SgCopyHelp &help) const |
| SgAsmGenericFile () | |
| virtual | ~SgAsmGenericFile () |
| SgAsmGenericFile * | parse (std::string file_name) |
| Loads file contents into memory. | |
| void | reallocate () |
| Call this before unparsing to make sure everything is consistent. | |
| void | unparse (std::ostream &) const |
| Mirror image of parsing an executable file. | |
| void | extend_to_eof (std::ostream &) const |
| Extend the output file by writing the last byte if it hasn't been written yet. | |
| void | dump (FILE *) const |
| void | dump_all (bool in_cwd=true, const char *ext=NULL) |
| Print text file containing all known information about a binary file. | |
| void | dump_all (const std::string &dumpname) |
| Print text file containing all known information about a binary file. | |
| const ExtentMap & | get_unreferenced_extents () const |
| Returns the parts of the file that have never been referenced. | |
| void | mark_referenced_extent (rose_addr_t start_rva, rose_addr_t size) |
| Marks part of a file as having been referenced if we are tracking references. | |
| void | set_data_converter (DataConverter *dc) |
| DataConverter * | get_data_converter () const |
| rose_addr_t | get_current_size () const |
| Returns current size of file based on section with highest ending address. | |
| rose_addr_t | get_orig_size () const |
| Returns original size of file, based on file system. | |
| size_t | read_content (rose_addr_t offset, void *dst_buf, rose_addr_t size, bool strict=true) |
| Reads data from a file. | |
| size_t | read_content (const MemoryMap *map, rose_addr_t va, void *dst_buf, rose_addr_t size, bool strict=true) |
| Reads data from a file. | |
| std::string | read_content_str (const MemoryMap *map, rose_addr_t va, bool strict=true) |
| Reads a string from a file. | |
| std::string | read_content_str (rose_addr_t abs_offset, bool strict=true) |
| Reads a string from a file. | |
| const SgFileContentList & | content () |
| SgFileContentList | content (rose_addr_t offset, rose_addr_t size) |
| Returns a vector that points to part of the file content without actually ever reading or otherwise referencing the file content until the vector elements are referenced. | |
| SgAsmGenericSectionPtrList | get_mapped_sections () const |
| Returns list of all sections in the file that are memory mapped, including headers and holes. | |
| SgAsmGenericSectionPtrList | get_sections (bool include_holes=true) const |
| Returns list of all sections in the file (including headers, holes, etc). | |
| SgAsmGenericSectionPtrList | get_sections_by_id (int id) const |
| Returns sections having specified ID across all headers, including headers and holes. | |
| SgAsmGenericSectionPtrList | get_sections_by_name (std::string, char sep='\0') const |
| Returns all sections having specified name across all headers, including headers and holes. | |
| SgAsmGenericSectionPtrList | get_sections_by_offset (rose_addr_t offset, rose_addr_t size) const |
| Returns all sections that contain all of the specified portion of the file across all headers, including headers and holes. | |
| SgAsmGenericSectionPtrList | get_sections_by_rva (rose_addr_t rva) const |
| Returns all sections that are mapped to include the specified relative virtual address across all headers, including headers and holes. | |
| SgAsmGenericSectionPtrList | get_sections_by_va (rose_addr_t va) const |
| Returns all sections that are mapped to include the specified virtual address across all headers, including headers and holes. | |
| SgAsmGenericSection * | get_section_by_id (int id, size_t *nfound=0) const |
| Returns the pointer to section with the specified ID across all headers only if there's exactly one match. | |
| SgAsmGenericSection * | get_section_by_name (const std::string &, char sep=0, size_t *nfound=0) const |
| Returns pointer to the section with the specified name, or NULL if there isn't exactly one match. | |
| SgAsmGenericSection * | get_section_by_offset (rose_addr_t offset, rose_addr_t size, size_t *nfound=0) const |
| Returns single section that contains all of the specified portion of the file across all headers, including headers and holes. | |
| SgAsmGenericSection * | get_section_by_rva (rose_addr_t rva, size_t *nfound=0) const |
| Returns single section that is mapped to include the specified relative virtual file address across all headers, including headers and holes. | |
| SgAsmGenericSection * | get_section_by_va (rose_addr_t va, size_t *nfound=0) const |
| Returns single section that is mapped to include the specified virtual address across all headers. | |
| SgAsmGenericSection * | get_best_section_by_va (rose_addr_t va, size_t *nfound=0) const |
| Similar to get_section_by_va() except when more than one section contains the specified virtual address we choose the "best" one. | |
| void | shift_extend (SgAsmGenericSection *s, rose_addr_t sa, rose_addr_t sn) |
| void | shift_extend (SgAsmGenericSection *, rose_addr_t sa, rose_addr_t sn, AddressSpace, Elasticity) |
| Shifts (to a higher offset) and/or enlarges the specified section, S, taking all other sections into account. | |
| rose_addr_t | get_next_section_offset (rose_addr_t offset) |
| Given a file address, return the file offset of the following section(s). | |
| void | add_hole (SgAsmGenericSection *) |
| Adds a new hole to the file. | |
| void | remove_hole (SgAsmGenericSection *) |
| Removes a hole from the list of holes in a file. | |
| void | fill_holes () |
| Synthesizes "hole" sections to describe the parts of the file that are not yet referenced by other sections. | |
| void | unfill_holes () |
| Deletes "hole" sections. | |
| void | add_header (SgAsmGenericHeader *) |
| Adds a new header to the file. | |
| void | remove_header (SgAsmGenericHeader *) |
| Removes a header from the header list in a file. | |
| SgAsmGenericHeader * | get_header (SgAsmGenericFormat::ExecFamily) |
| Returns the header for the specified format. | |
| const char * | format_name () const |
| Return a string describing the file format. | |
| const SgAsmGenericFormat::fileDetails & | get_sb () |
| void | set_sb (const SgAsmGenericFormat::fileDetails &sb) |
| SgAsmGenericSection * | get_best_possible_section_by_va (rose_addr_t va) |
| Appears to be the same as SgAsmGenericFile::get_best_section_by_va() except it excludes sections named "ELF Segment Table". | |
| virtual std::string | class_name () const |
| Copies AST (whole subtree, depending on the SgCopyHelp class 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 () |
| FOR INTERNAL USE within ROSE traverals mechanism only. | |
| virtual std::vector< std::string > | get_traversalSuccessorNamesContainer () |
| FOR INTERNAL USE within ROSE traverals mechanism only. | |
| virtual size_t | get_numberOfTraversalSuccessors () |
| virtual SgNode * | get_traversalSuccessorByIndex (size_t idx) |
| virtual size_t | get_childIndex (SgNode *child) |
| virtual RTIReturnType | roseRTI () |
| FOR INTERNAL USE Access to Runtime Type Information (RTI) for this IR nodes. | |
| virtual const char * | sage_class_name () const ROSE_DEPRECATED_FUNCTION |
| void | executeVisitorMemberFunction (ROSE_VisitorPattern &visitor) |
| FOR INTERNAL USE Support for visitor pattern. | |
| virtual void | accept (ROSE_VisitorPattern &visitor) |
| DXN (08/09/2010): 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. | |
| SgAsmGenericFile (const SgAsmGenericFileStorageClass &source) | |
| SgAsmGenericFile * | addRegExpAttribute (std::string s, AstRegExAttribute *a) |
| Support for AST matching using regular expression. | |
| std::string | get_name () const |
| void | set_name (std::string name) |
| int | get_fd () const |
| void | set_fd (int fd) |
| SgFileContentList | get_data () const |
| void | set_data (SgFileContentList data) |
| SgAsmGenericHeaderList * | get_headers () const |
| void | set_headers (SgAsmGenericHeaderList *headers) |
| SgAsmGenericSectionList * | get_holes () const |
| void | set_holes (SgAsmGenericSectionList *holes) |
| bool | get_truncate_zeros () const |
| void | set_truncate_zeros (bool truncate_zeros) |
| bool | get_tracking_references () const |
| void | set_tracking_references (bool tracking_references) |
| ExtentMap | get_referenced_extents () const |
| void | set_referenced_extents (ExtentMap referenced_extents) |
| bool | get_neuter () const |
| void | set_neuter (bool neuter) |
Static Public Member Functions | |
| static SgAsmGenericSection * | best_section_by_va (const SgAsmGenericSectionPtrList §ions, rose_addr_t va) |
| Definition for "best" as used by SgAsmGenericFile::get_best_section_by_va() and SgAsmGenericHeader::get_best_section_by_va(). | |
| 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. | |
| 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. | |
Protected Attributes | |
| std::string | p_name |
| int | p_fd |
| SgAsmGenericFormat::fileDetails | p_sb |
| SgFileContentList | p_data |
| SgAsmGenericHeaderList * | p_headers |
| SgAsmGenericSectionList * | p_holes |
| bool | p_truncate_zeros |
| bool | p_tracking_references |
| ExtentMap | p_referenced_extents |
| bool | p_neuter |
Private Member Functions | |
| void | ctor () |
| Non-parsing constructor. | |
Private Attributes | |
| ExtentMap * | p_unreferenced_cache |
| DataConverter * | p_data_converter |
Friends | |
| class | AST_FILE_IO |
| class | SgAsmGenericFileStorageClass |
| class | AstSpecificDataManagingClass |
| class | AstSpecificDataManagingClassStorageClass |
| SgAsmGenericFile * | isSgAsmGenericFile (SgNode *s) |
| Casts pointer from base class to derived class. | |
| const SgAsmGenericFile * | isSgAsmGenericFile (const SgNode *s) |
| Casts pointer from base class to derived class (for const pointers). | |
| SgAsmGenericFile * | SgAsmGenericFile_getPointerFromGlobalIndex (unsigned long globalIndex) |
| Constructor for use by AST File I/O MechanismTypedef used for low level memory access. Typedef used to hold memory addresses as values. Methods to find the pointer to a global and local index. | |
| unsigned long | SgAsmGenericFile_getNumberOfValidNodesAndSetGlobalIndexInFreepointer (unsigned long) |
| Get the size of the memory pool. | |
| void | SgAsmGenericFile_clearMemoryPool () |
| void | SgAsmGenericFile_extendMemoryPoolForFileIO (unsigned long) |
| void | SgAsmGenericFile_getNextValidPointer (std::pair< SgAsmGenericFile *, std::vector< unsigned char * >::const_iterator > &) |
| void | SgAsmGenericFile_resetValidFreepointers () |
Reimplemented from SgAsmExecutableFileFormat.
| SgAsmGenericFile::SgAsmGenericFile | ( | ) | [inline] |
| SgAsmGenericFile::~SgAsmGenericFile | ( | ) | [virtual] |
| SgAsmGenericFile::SgAsmGenericFile | ( | const SgAsmGenericFileStorageClass & | source | ) |
| virtual SgNode* SgAsmGenericFile::copy | ( | SgCopyHelp & | help | ) | const [virtual] |
Reimplemented from SgAsmExecutableFileFormat.
| SgAsmGenericFile * SgAsmGenericFile::parse | ( | std::string | file_name | ) |
Loads file contents into memory.
| void SgAsmGenericFile::reallocate | ( | ) |
Call this before unparsing to make sure everything is consistent.
| void SgAsmGenericFile::unparse | ( | std::ostream & | f | ) | const |
Mirror image of parsing an executable file.
The result (unless the AST has been modified) should be identical to the original file. If the file's neuter property is true, then rather than creating a binary file, the output will contain a note indicating that the neuter property is set. This is intended to prevent ASTs that represent malicious binaries from accidently being used to create the binary.
| void SgAsmGenericFile::extend_to_eof | ( | std::ostream & | ) | const |
Extend the output file by writing the last byte if it hasn't been written yet.
| void SgAsmGenericFile::dump | ( | FILE * | ) | const |
| void SgAsmGenericFile::dump_all | ( | bool | in_cwd = true, |
|
| const char * | ext = NULL | |||
| ) |
Print text file containing all known information about a binary file.
If in_cwd is set, then the file is created in the current working directory rather than the directory containing the binary file (the default is to create the file in the current working directory). If ext is non-null then these characters are added to the end of the binary file name. The default null pointer causes the string ".dump" to be appended to the file name.
| void SgAsmGenericFile::dump_all | ( | const std::string & | dumpname | ) |
Print text file containing all known information about a binary file.
| const ExtentMap & SgAsmGenericFile::get_unreferenced_extents | ( | ) | const |
Returns the parts of the file that have never been referenced.
| void SgAsmGenericFile::mark_referenced_extent | ( | rose_addr_t | start_rva, | |
| rose_addr_t | size | |||
| ) |
Marks part of a file as having been referenced if we are tracking references.
| void SgAsmGenericFile::set_data_converter | ( | DataConverter * | dc | ) | [inline] |
| DataConverter* SgAsmGenericFile::get_data_converter | ( | ) | const [inline] |
| rose_addr_t SgAsmGenericFile::get_current_size | ( | ) | const |
Returns current size of file based on section with highest ending address.
| rose_addr_t SgAsmGenericFile::get_orig_size | ( | ) | const |
Returns original size of file, based on file system.
| size_t SgAsmGenericFile::read_content | ( | rose_addr_t | offset, | |
| void * | dst_buf, | |||
| rose_addr_t | size, | |||
| bool | strict = true | |||
| ) |
Reads data from a file.
Reads up to size bytes of data from the file beginning at the specified byte offset (measured from the beginning of the file), placing the result in dst_buf, and returning the number of bytes read. If the number of bytes read is less than size then one of two things happen: if strict is true (the default) then an SgAsmExecutableFileFormat::ShortRead exception is thrown; otherwise dst_buf is zero padded so that exactly size bytes are always initialized.
| size_t SgAsmGenericFile::read_content | ( | const MemoryMap * | map, | |
| rose_addr_t | start_va, | |||
| void * | dst_buf, | |||
| rose_addr_t | size, | |||
| bool | strict = true | |||
| ) |
Reads data from a file.
Reads up to size bytes of data starting at the specified (absolute) virtual address. The map specifies how virtual addresses are mapped to file offsets. As bytes are read, if we encounter a virtual address that is not mapped we stop reading and do one of two things: if strict is set then a MemoryMap::NotMapped exception is thrown; otherwise the rest of the dst_buf is zero filled and the number of bytes read (not filled) is returned.
| std::string SgAsmGenericFile::read_content_str | ( | const MemoryMap * | map, | |
| rose_addr_t | va, | |||
| bool | strict = true | |||
| ) |
Reads a string from a file.
Returns the string stored at the specified (absolute) virtual address. The returned string contains the bytes beginning at the starting virtual address and continuing until we reach a NUL byte or an address which is not mapped. If we reach an address which is not mapped then one of two things happen: if strict is set then a MemoryMap::NotMapped exception is thrown; otherwise the string is simply terminated. The returned string does not include the NUL byte.
| std::string SgAsmGenericFile::read_content_str | ( | rose_addr_t | offset, | |
| bool | strict = true | |||
| ) |
Reads a string from a file.
Returns the NUL-terminated string stored at the specified relative virtual address. The returned string contains the bytes beginning at the specified starting file offset and continuing until we reach a NUL byte or an invalid file offset. If we reach an invalid file offset one of two things happen: if strict is set (the default) then an SgAsmExecutableFileFormat::ShortRead exception is thrown; otherwise the string is simply terminated. The returned string does not include the NUL byte.
| const SgFileContentList& SgAsmGenericFile::content | ( | ) | [inline] |
| SgFileContentList SgAsmGenericFile::content | ( | rose_addr_t | offset, | |
| rose_addr_t | size | |||
| ) |
Returns a vector that points to part of the file content without actually ever reading or otherwise referencing the file content until the vector elements are referenced.
If the desired extent falls entirely or partially outside the range of data known to the file then throw an SgAsmExecutableFileFormat::ShortRead exception. This function never updates reference tracking lists for the file.
| SgAsmGenericSectionPtrList SgAsmGenericFile::get_mapped_sections | ( | ) | const |
Returns list of all sections in the file that are memory mapped, including headers and holes.
| SgAsmGenericSectionPtrList SgAsmGenericFile::get_sections | ( | bool | include_holes = true |
) | const |
Returns list of all sections in the file (including headers, holes, etc).
| SgAsmGenericSectionPtrList SgAsmGenericFile::get_sections_by_id | ( | int | id | ) | const |
Returns sections having specified ID across all headers, including headers and holes.
| SgAsmGenericSectionPtrList SgAsmGenericFile::get_sections_by_name | ( | std::string | , | |
| char | sep = '\0' | |||
| ) | const |
Returns all sections having specified name across all headers, including headers and holes.
| SgAsmGenericSectionPtrList SgAsmGenericFile::get_sections_by_offset | ( | rose_addr_t | offset, | |
| rose_addr_t | size | |||
| ) | const |
Returns all sections that contain all of the specified portion of the file across all headers, including headers and holes.
| SgAsmGenericSectionPtrList SgAsmGenericFile::get_sections_by_rva | ( | rose_addr_t | rva | ) | const |
Returns all sections that are mapped to include the specified relative virtual address across all headers, including headers and holes.
This uses the preferred mapping of the section rather than the actual mapping.
| SgAsmGenericSectionPtrList SgAsmGenericFile::get_sections_by_va | ( | rose_addr_t | va | ) | const |
Returns all sections that are mapped to include the specified virtual address across all headers, including headers and holes.
This uses the preferred mapping rather than the actual mapping.
| SgAsmGenericSection * SgAsmGenericFile::get_section_by_id | ( | int | id, | |
| size_t * | nfound = 0 | |||
| ) | const |
Returns the pointer to section with the specified ID across all headers only if there's exactly one match.
Headers and holes are included in the results.
| SgAsmGenericSection * SgAsmGenericFile::get_section_by_name | ( | const std::string & | name, | |
| char | sep = 0, |
|||
| size_t * | nfound = 0 | |||
| ) | const |
Returns pointer to the section with the specified name, or NULL if there isn't exactly one match.
Any characters in the name after the first occurrence of SEP are ignored (default is NUL). For instance, if sep=='$' then the following names are all equivalent: .idata, .idata$, and .idata$1
| SgAsmGenericSection * SgAsmGenericFile::get_section_by_offset | ( | rose_addr_t | offset, | |
| rose_addr_t | size, | |||
| size_t * | nfound = 0 | |||
| ) | const |
Returns single section that contains all of the specified portion of the file across all headers, including headers and holes.
| SgAsmGenericSection * SgAsmGenericFile::get_section_by_rva | ( | rose_addr_t | rva, | |
| size_t * | nfound = 0 | |||
| ) | const |
Returns single section that is mapped to include the specified relative virtual file address across all headers, including headers and holes.
| SgAsmGenericSection * SgAsmGenericFile::get_section_by_va | ( | rose_addr_t | va, | |
| size_t * | nfound = 0 | |||
| ) | const |
Returns single section that is mapped to include the specified virtual address across all headers.
See also get_best_section_by_va().
| SgAsmGenericSection * SgAsmGenericFile::get_best_section_by_va | ( | rose_addr_t | va, | |
| size_t * | nfound = 0 | |||
| ) | const |
Similar to get_section_by_va() except when more than one section contains the specified virtual address we choose the "best" one.
All candidates must map the virtual address to the same file address or else we fail (return null and number of candidates). See code below for definition of "best".
| SgAsmGenericSection * SgAsmGenericFile::best_section_by_va | ( | const SgAsmGenericSectionPtrList & | sections, | |
| rose_addr_t | va | |||
| ) | [static] |
Definition for "best" as used by SgAsmGenericFile::get_best_section_by_va() and SgAsmGenericHeader::get_best_section_by_va().
| void SgAsmGenericFile::shift_extend | ( | SgAsmGenericSection * | s, | |
| rose_addr_t | sa, | |||
| rose_addr_t | sn | |||
| ) | [inline] |
| void SgAsmGenericFile::shift_extend | ( | SgAsmGenericSection * | s, | |
| rose_addr_t | sa, | |||
| rose_addr_t | sn, | |||
| AddressSpace | space, | |||
| Elasticity | elasticity | |||
| ) |
Shifts (to a higher offset) and/or enlarges the specified section, S, taking all other sections into account.
The positions of sections are based on their preferred virtual mappings rather than the actual mapping.
The neighborhood(S) is S itself and the set of all sections that overlap or are adjacent to the neighborhood of S, recursively.
The address space can be partitioned into three categories:
The last two categories define parts of the address space that can be optionally elastic--they expand or contract to take up slack or provide space for neighboring sections. This is controlled by the "elasticity" argument.
Note that when elasticity is ELASTIC_HOLE we simply ignore the "hole" sections, effectively removing their addresses from the range of addresses under consideration. This avoids complications that arise when a "hole" overlaps with a real section (due to someone changing offsets in an incompatible manner), but causes the hole offset and size to remain fixed. (FIXME RPM 2008-10-20)
When section S is shifted by 'Sa' bytes and/or enlarged by 'Sn' bytes, other sections are affected as follows: Cat L: Not affected Cat R: Shifted by Sa+Sn if they are in neighborhood(S). Otherwise the amount of shifting depends on the size of the hole right of neighborhood(S). Cat C: Shifted Sa and enlarged Sn. Cat O: If starting address are the same: Shifted Sa If starting address not equal: Englarged Sa+Sn Cat I: Shifted Sa, not enlarged Cat B: Not shifted, but enlarged Sn Cat E: Shifted Sa and enlarged Sn
Generally speaking, the "space" argument should be SgAsmGenericFile::ADDRSP_ALL in order to adjust both file and memory offsets and sizes in a consistent manner.
To change the address and/or size of S without regard to other sections in the same file, use set_offset() and set_size() (for file address space) or set_mapped_preferred_rva() and set_mapped_size() (for memory address space).
| rose_addr_t SgAsmGenericFile::get_next_section_offset | ( | rose_addr_t | offset | ) |
Given a file address, return the file offset of the following section(s).
If there is no following section then return an address of -1 (when signed)
| void SgAsmGenericFile::add_hole | ( | SgAsmGenericSection * | hole | ) |
Adds a new hole to the file.
This is called implicitly by the hole constructor
| void SgAsmGenericFile::remove_hole | ( | SgAsmGenericSection * | ) |
Removes a hole from the list of holes in a file.
| void SgAsmGenericFile::fill_holes | ( | ) |
Synthesizes "hole" sections to describe the parts of the file that are not yet referenced by other sections.
Note that holes are used to represent parts of the original file data, before sections were modified by walking the AST (at this time it is not possible to create a hole outside the original file content).
| void SgAsmGenericFile::unfill_holes | ( | ) |
Deletes "hole" sections.
| void SgAsmGenericFile::add_header | ( | SgAsmGenericHeader * | header | ) |
Adds a new header to the file.
This is called implicitly by the header constructor
| void SgAsmGenericFile::remove_header | ( | SgAsmGenericHeader * | ) |
Removes a header from the header list in a file.
| SgAsmGenericHeader * SgAsmGenericFile::get_header | ( | SgAsmGenericFormat::ExecFamily | ) |
Returns the header for the specified format.
| const char * SgAsmGenericFile::format_name | ( | ) | const |
Return a string describing the file format.
We use the last header so that files like PE, NE, LE, LX, etc. which also have a DOS header report the format of the second (PE, etc.) header rather than the DOS header.
| const SgAsmGenericFormat::fileDetails& SgAsmGenericFile::get_sb | ( | ) | [inline] |
| void SgAsmGenericFile::set_sb | ( | const SgAsmGenericFormat::fileDetails & | sb | ) | [inline] |
| SgAsmGenericSection * SgAsmGenericFile::get_best_possible_section_by_va | ( | rose_addr_t | va | ) |
Appears to be the same as SgAsmGenericFile::get_best_section_by_va() except it excludes sections named "ELF Segment Table".
Perhaps it should be rewritten in terms of the other. (RPM 2008-09-02)
| void SgAsmGenericFile::ctor | ( | ) | [private] |
Non-parsing constructor.
If you're creating an executable from scratch then call this function and you're done. But if you're parsing an existing file then call parse() in order to map the file's contents into memory for parsing.
| virtual std::string SgAsmGenericFile::class_name | ( | ) | const [virtual] |
Copies AST (whole subtree, depending on the SgCopyHelp class returns a string representing the class name.
Reimplemented from SgAsmExecutableFileFormat.
| virtual VariantT SgAsmGenericFile::variantT | ( | ) | const [virtual] |
| void* SgAsmGenericFile::operator new | ( | size_t | size | ) |
| void SgAsmGenericFile::operator delete | ( | void * | pointer, | |
| size_t | size | |||
| ) |
deallocated memory for IR node (returns memory to memory pool for reuse)
Reimplemented from SgAsmExecutableFileFormat.
| void SgAsmGenericFile::operator delete | ( | void * | pointer | ) |
Reimplemented from SgAsmExecutableFileFormat.
| static size_t SgAsmGenericFile::numberOfNodes | ( | ) | [static] |
| static size_t SgAsmGenericFile::memoryUsage | ( | ) | [static] |
Returns the size in bytes of the total memory allocated for all IR nodes of this type.
Reimplemented from SgAsmExecutableFileFormat.
| virtual std::vector<SgNode*> SgAsmGenericFile::get_traversalSuccessorContainer | ( | ) | [virtual] |
FOR INTERNAL USE within ROSE traverals mechanism only.
This function builds and returns a copy of ordered container holding pointers to children of this node in a traversal. It is associated with the definition of a tree that is travered by the AST traversal mechanism; a tree that is embeded in the AST (which is a more general graph). This function is used within the implementation of the AST traversal and has a semantics may change in subtle ways that makes it difficult to use in user code. It can return unexpected data members and thus the order and the number of elements is unpredicable and subject to change.
Reimplemented from SgAsmExecutableFileFormat.
| virtual std::vector<std::string> SgAsmGenericFile::get_traversalSuccessorNamesContainer | ( | ) | [virtual] |
FOR INTERNAL USE within ROSE traverals mechanism only.
This function builds and returns a copy of ordered container holding strings used to name data members that are traversed in the IR node. It is associated with the definition of a tree that is travered by the AST traversal mechanism; a tree that is embeded in the AST (which is a more general graph). This function is used within the implementation of the AST traversal and has a semantics may change in subtle ways that makes it difficult to use in user code. It can return unexpected data members and thus the order and the number of elements is unpredicable and subject to change.
Reimplemented from SgAsmExecutableFileFormat.
| virtual size_t SgAsmGenericFile::get_numberOfTraversalSuccessors | ( | ) | [virtual] |
Reimplemented from SgAsmExecutableFileFormat.
| virtual SgNode* SgAsmGenericFile::get_traversalSuccessorByIndex | ( | size_t | idx | ) | [virtual] |
Reimplemented from SgAsmExecutableFileFormat.
| virtual size_t SgAsmGenericFile::get_childIndex | ( | SgNode * | child | ) | [virtual] |
Reimplemented from SgAsmExecutableFileFormat.
| virtual RTIReturnType SgAsmGenericFile::roseRTI | ( | ) | [virtual] |
FOR INTERNAL USE Access to Runtime Type Information (RTI) for this IR nodes.
This function provides runtime type information for accessing the structure of the current node. It is useful for generating code which would dump out or rebuild IR nodes.
Reimplemented from SgAsmExecutableFileFormat.
| virtual const char* SgAsmGenericFile::sage_class_name | ( | ) | const [virtual] |
returns a C style string (char*) representing the class name
Reimplemented from SgAsmExecutableFileFormat.
| void SgAsmGenericFile::executeVisitorMemberFunction | ( | ROSE_VisitorPattern & | visitor | ) |
| virtual void SgAsmGenericFile::accept | ( | ROSE_VisitorPattern & | visitor | ) | [virtual] |
DXN (08/09/2010): support for the classic visitor pattern done in GoF.
Reimplemented from SgAsmExecutableFileFormat.
| static void SgAsmGenericFile::traverseMemoryPoolNodes | ( | ROSE_VisitTraversal & | visit | ) | [static] |
| static void SgAsmGenericFile::traverseMemoryPoolVisitorPattern | ( | ROSE_VisitorPattern & | visitor | ) | [static] |
| static void SgAsmGenericFile::visitRepresentativeNode | ( | ROSE_VisitTraversal & | visit | ) | [static] |
| virtual bool SgAsmGenericFile::isInMemoryPool | ( | ) | [virtual] |
FOR INTERNAL USE This is used in internal tests to verify that all IR nodes are allocated from the heap.
The AST File I/O depends upon the allocation of IR nodes being from the heap, stack based or global IR nodes should not appear in the AST if it will be written out to a file and read back in. To enforce this concept, this function implements a test to verify that the IR node can be found on the heap and is part of a larger test of the whole AST. This test must pass before the AST can be written out to a file. This is part of a compromise in the design of the AST File I/O to support binary streaming of data to files; for performance. It is also rather difficult, but possible, to build a useful AST with IR nodes allocated on the stack or frm global scope, this test filters out such cased from being used with the AST File I/O mechanism.
Reimplemented from SgAsmExecutableFileFormat.
| virtual void SgAsmGenericFile::checkDataMemberPointersIfInMemoryPool | ( | ) | [virtual] |
FOR INTERNAL USE This is used in internal tests to verify that all IR nodes are allocated from the heap.
The AST File I/O depends upon the allocation of IR nodes being from the heap, stack based or global IR nodes should not appear in the AST if it will be written out to a file and read back in. To enforce this concept, this function implements a test to verify that the IR node can be found on the heap and is part of a larger test of the whole AST. This test must pass before the AST can be written out to a file. This is part of a compromise in the design of the AST File I/O to support binary streaming of data to files; for performance. It is also rather difficult, but possible, to build a useful AST with IR nodes allocated on the stack or frm global scope, this test filters out such cased from being used with the AST File I/O mechanism.
Reimplemented from SgAsmExecutableFileFormat.
| virtual std::vector<std::pair<SgNode*,std::string> > SgAsmGenericFile::returnDataMemberPointers | ( | ) | const [virtual] |
FOR INTERNAL USE Returns STL vector of pairs of SgNode* and strings for use in AST tools
This functions is part of general support for many possible tools to operate on the AST. The forms a list of ALL IR node pointers used by each IR node, and is a supperset of the get_traversalSuccessorContainer(). It is (I think) less than the set of pointers used by the AST file I/O. This is part of work implemented by Andreas, and support tools such as the AST graph generation.
Reimplemented from SgAsmExecutableFileFormat.
| virtual void SgAsmGenericFile::processDataMemberReferenceToPointers | ( | ReferenceToPointerHandler * | ) | [virtual] |
FOR INTERNAL USE Processes pairs of references to SgNode* and strings for use in AST tools
This functions similar to returnDataMemberPointers() except that it passes references to a handler object. As a result there is FAR more damage that can be done by using this function, but it is type-safe. This is provided for support of internal tools that operate on the AST, e.g the AST Merge mechanism.
Reimplemented from SgAsmExecutableFileFormat.
| virtual long SgAsmGenericFile::getChildIndex | ( | SgNode * | childNode | ) | const [virtual] |
FOR INTERNAL USE Returns a unique index value for the childNode in the list of children at this IR node.
This function returns a unique value for the input childNode in set of children at this IR node. Note that a negative value indicates that the input node is not a child. This is the basis for the implementation of the isChild(SgNode*) member function. Data members that are NULL in the IR node are counted internally (so that this function returns value that could be statically defined, and so are not dynamically determined).
Reimplemented from SgAsmExecutableFileFormat.
| SgAsmGenericFile* SgAsmGenericFile::addRegExpAttribute | ( | std::string | s, | |
| AstRegExAttribute * | a | |||
| ) |
Support for AST matching using regular expression.
This support is incomplete and the subject of current research to define RegEx trees to support inexact matching.
Reimplemented from SgAsmExecutableFileFormat.
| std::string SgAsmGenericFile::get_name | ( | ) | const |
| void SgAsmGenericFile::set_name | ( | std::string | name | ) |
| int SgAsmGenericFile::get_fd | ( | ) | const |
| void SgAsmGenericFile::set_fd | ( | int | fd | ) |
| SgFileContentList SgAsmGenericFile::get_data | ( | ) | const |
| void SgAsmGenericFile::set_data | ( | SgFileContentList | data | ) |
| SgAsmGenericHeaderList* SgAsmGenericFile::get_headers | ( | ) | const |
| void SgAsmGenericFile::set_headers | ( | SgAsmGenericHeaderList * | headers | ) |
| SgAsmGenericSectionList* SgAsmGenericFile::get_holes | ( | ) | const |
| void SgAsmGenericFile::set_holes | ( | SgAsmGenericSectionList * | holes | ) |
| bool SgAsmGenericFile::get_truncate_zeros | ( | ) | const |
| void SgAsmGenericFile::set_truncate_zeros | ( | bool | truncate_zeros | ) |
| bool SgAsmGenericFile::get_tracking_references | ( | ) | const |
| void SgAsmGenericFile::set_tracking_references | ( | bool | tracking_references | ) |
| ExtentMap SgAsmGenericFile::get_referenced_extents | ( | ) | const |
| void SgAsmGenericFile::set_referenced_extents | ( | ExtentMap | referenced_extents | ) |
| bool SgAsmGenericFile::get_neuter | ( | ) | const |
| void SgAsmGenericFile::set_neuter | ( | bool | neuter | ) |
friend class AST_FILE_IO [friend] |
Reimplemented from SgAsmExecutableFileFormat.
friend class SgAsmGenericFileStorageClass [friend] |
friend class AstSpecificDataManagingClass [friend] |
Reimplemented from SgAsmExecutableFileFormat.
friend class AstSpecificDataManagingClassStorageClass [friend] |
Reimplemented from SgAsmExecutableFileFormat.
| SgAsmGenericFile* isSgAsmGenericFile | ( | SgNode * | s | ) | [friend] |
Casts pointer from base class to derived class.
| const SgAsmGenericFile* isSgAsmGenericFile | ( | const SgNode * | s | ) | [friend] |
Casts pointer from base class to derived class (for const pointers).
| SgAsmGenericFile* SgAsmGenericFile_getPointerFromGlobalIndex | ( | unsigned long | globalIndex | ) | [friend] |
Constructor for use by AST File I/O MechanismTypedef used for low level memory access. Typedef used to hold memory addresses as values. Methods to find the pointer to a global and local index.
| unsigned long SgAsmGenericFile_getNumberOfValidNodesAndSetGlobalIndexInFreepointer | ( | unsigned | long | ) | [friend] |
Get the size of the memory pool.
It actually returns the size of the whole blocks allocated, no matter they contain valid pointers or not.
| void SgAsmGenericFile_clearMemoryPool | ( | ) | [friend] |
| void SgAsmGenericFile_extendMemoryPoolForFileIO | ( | unsigned | long | ) | [friend] |
| void SgAsmGenericFile_getNextValidPointer | ( | std::pair< SgAsmGenericFile *, std::vector< unsigned char * >::const_iterator > & | ) | [friend] |
| void SgAsmGenericFile_resetValidFreepointers | ( | ) | [friend] |
ExtentMap* SgAsmGenericFile::p_unreferenced_cache [mutable, private] |
DataConverter* SgAsmGenericFile::p_data_converter [private] |
std::string SgAsmGenericFile::p_name [protected] |
int SgAsmGenericFile::p_fd [protected] |
SgFileContentList SgAsmGenericFile::p_data [protected] |
SgAsmGenericHeaderList* SgAsmGenericFile::p_headers [protected] |
SgAsmGenericSectionList* SgAsmGenericFile::p_holes [protected] |
bool SgAsmGenericFile::p_truncate_zeros [protected] |
bool SgAsmGenericFile::p_tracking_references [protected] |
ExtentMap SgAsmGenericFile::p_referenced_extents [protected] |
bool SgAsmGenericFile::p_neuter [protected] |
1.4.7