2#ifndef ROSE_SgAsmGenericHeader_H
3#define ROSE_SgAsmGenericHeader_H
5#include <Cxx_GrammarDeclarations.h>
6#include <SgAsmGenericSection.h>
27#include <Rose/BinaryAnalysis/ByteOrder.h>
28#include <Rose/BinaryAnalysis/RelativeVirtualAddress.h>
29#include <sageContainer.h>
30#include <SgAsmGenericFormat.h>
32#ifdef ROSE_SgAsmGenericHeader_IMPL
33#include <SgAsmGenericDLLList.h>
34#include <SgAsmGenericSectionList.h>
45#if !defined(DOCUMENTATION)
60#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
62 friend class boost::serialization::access;
68 s & BOOST_SERIALIZATION_NVP(p_executableFormat);
69 s & BOOST_SERIALIZATION_NVP(p_magic);
70 s & BOOST_SERIALIZATION_NVP(p_isa);
71 s & BOOST_SERIALIZATION_NVP(p_baseVa);
72 s & BOOST_SERIALIZATION_NVP(p_entryRvas);
73 s & BOOST_SERIALIZATION_NVP(p_dlls);
74 s & BOOST_SERIALIZATION_NVP(p_sections);
91 SgCharList
const& get_magic()
const;
92 SgCharList& get_magic();
93 void set_magic(SgCharList
const&);
109 void set_baseVa(rose_addr_t
const&);
116 SgRVAList
const& get_entryRvas()
const;
117 SgRVAList& get_entryRvas();
118 void set_entryRvas(SgRVAList
const&);
149 virtual void unparse(std::ostream&)
const override;
152 virtual void dump(FILE*,
const char *prefix, ssize_t idx)
const override;
155 virtual const char *formatName()
const;
161 std::vector<SgAsmGenericDLL*>& get_dlls();
167 rose_addr_t get_entryRva()
const;
174 size_t get_wordSize()
const;
185 SgAsmGenericSectionPtrList get_mappedSections()
const;
188 SgAsmGenericSectionPtrList get_sectionsById(
int id)
const;
193 SgAsmGenericSectionPtrList get_sectionsByName(std::string,
char sep=0)
const;
196 SgAsmGenericSectionPtrList get_sectionsByOffset(rose_addr_t offset, rose_addr_t size)
const;
199 SgAsmGenericSectionPtrList get_sectionsByRva(rose_addr_t rva)
const;
207 SgAsmGenericSectionPtrList get_sectionsByVa(rose_addr_t va,
bool use_preferred)
const;
213 SgAsmGenericSection *get_sectionByName(
const std::string&,
char sep=0,
size_t *nfound=0)
const;
216 SgAsmGenericSection *get_sectionByOffset(rose_addr_t offset, rose_addr_t size,
size_t *nfound=0)
const;
229 SgAsmGenericSection *get_sectionByVa(rose_addr_t va,
bool use_preferred,
size_t *nfound=0)
const;
232 SgAsmGenericSection *get_bestSectionByVa(rose_addr_t va,
bool use_preferred,
size_t *nfound=0)
const;
238 SgAsmGenericFormat* get_exec_format() const ROSE_DEPRECATED("use get_executableFormat");
239 void set_exec_format(
SgAsmGenericFormat*) ROSE_DEPRECATED("use set_executableFormat");
240 rose_addr_t get_base_va() const ROSE_DEPRECATED("use get_baseVa");
241 void set_base_va(rose_addr_t) ROSE_DEPRECATED("use set_baseVa");
242 SgRVAList& get_entry_rvas() ROSE_DEPRECATED("use get_entryRvas");
243 const SgRVAList& get_entry_rvas() const ROSE_DEPRECATED("use get_entryRvas");
244 void set_entry_rvas(const SgRVAList&) ROSE_DEPRECATED("use set_entryRvas");
245 virtual const
char *format_name() const ROSE_DEPRECATED("use formatName");
247 rose_addr_t get_entry_rva() const ROSE_DEPRECATED("use get_entryRva");
248 void add_entry_rva(const
Rose::BinaryAnalysis::RelativeVirtualAddress&) ROSE_DEPRECATED("use addEntryRva");
249 size_t get_word_size() const ROSE_DEPRECATED("use get_wordSize");
252 SgAsmGenericSectionPtrList get_mapped_sections() const ROSE_DEPRECATED("use get_mappedSections");
253 SgAsmGenericSectionPtrList get_sections_by_id(
int) const ROSE_DEPRECATED("use get_sectionsById");
254 SgAsmGenericSectionPtrList get_sections_by_name(std::
string,
char=0) const ROSE_DEPRECATED("use get_sectionsByName");
255 SgAsmGenericSectionPtrList get_sections_by_offset(rose_addr_t, rose_addr_t) const ROSE_DEPRECATED("use get_sectionsByOffset");
256 SgAsmGenericSectionPtrList get_sections_by_rva(rose_addr_t) const ROSE_DEPRECATED("use get_sectionsByRva");
257 SgAsmGenericSectionPtrList get_sections_by_va(rose_addr_t,
bool) const ROSE_DEPRECATED("use get_sectionsByVa");
258 SgAsmGenericSection *get_section_by_id(
int,
size_t* =
nullptr) const ROSE_DEPRECATED("use get_sectionById");
259 SgAsmGenericSection *get_section_by_name(const std::
string&,
char=0,
size_t* =
nullptr) const
260 ROSE_DEPRECATED("use get_sectionByName");
261 SgAsmGenericSection *get_section_by_offset(rose_addr_t, rose_addr_t,
size_t* =
nullptr) const
262 ROSE_DEPRECATED("use get_sectionByOffset");
263 SgAsmGenericSection *get_section_by_rva(rose_addr_t,
size_t* =
nullptr) const ROSE_DEPRECATED("use get_sectionByRva");
264 SgAsmGenericSection *get_section_by_va(rose_addr_t,
bool,
size_t* =
nullptr) const ROSE_DEPRECATED("use get_sectionByVa");
265 SgAsmGenericSection *get_best_section_by_va(rose_addr_t,
bool,
size_t* =
nullptr) const ROSE_DEPRECATED("use get_bestSectionByVa");
281 void initializeProperties();
300 virtual std::
string class_name() const override;
303 virtual VariantT variantT() const override;
308 enum { static_variant = V_SgAsmGenericHeader };
323 static const unsigned pool_size;
325 static std::vector<unsigned char *> pools;
330 static unsigned long initializeStorageClassArray(SgAsmGenericHeaderStorageClass *);
333 static void clearMemoryPool();
334 static void deleteMemoryPool();
337 static void extendMemoryPoolForFileIO();
342 static SgAsmGenericHeader * getPointerFromGlobalIndex(AstSpecificDataManagingClass *,
unsigned long);
345 static unsigned long getNumberOfValidNodesAndSetGlobalIndexInFreepointer(
unsigned long);
347 static void resetValidFreepointers();
349 static unsigned long getNumberOfLastValidPointer();
352#if defined(INLINE_FUNCTIONS)
354 inline void *
operator new (
size_t size);
357 void *
operator new (
size_t size);
360 void operator delete (
void* pointer,
size_t size);
363 void operator delete (
void* pointer)
409#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
412 virtual RTIReturnType
roseRTI()
override;
426 virtual const char*
sage_class_name() const override ROSE_DEPRECATED_FUNCTION;
432 virtual int variant() const ROSE_DEPRECATED_FUNCTION;
614 friend class SgAsmGenericHeaderStorageClass;
617 friend class AstSpecificDataManagingClass;
620 friend class AstSpecificDataManagingClassStorageClass;
652#define BUILD_ATERM_SUPPORT 0
653 #if BUILD_ATERM_SUPPORT
654 #ifdef ROSE_USE_ROSE_ATERM_SUPPORT
666 virtual ATerm generate_ATerm()
override;
669 virtual void generate_ATerm_Annotation(ATerm & term)
override;
717SgRVAList p_entryRvas;
Class holding static data and functions supporting File I/O.
Attribute containing a regex expression as a string.
Optionally bound relative virtual address.
List of pointers to other nodes.
Base class for dynamically linked library information.
Base class for binary files.
List of pointers to file sections.
Contiguous region of a file.
virtual void dump(FILE *, const char *prefix, ssize_t idx) const
Print some debugging info.
rose_addr_t get_baseVa() const
Base virtual address for a section.
virtual bool reallocate()
Called prior to unparse to make things consistent.
virtual void unparse(std::ostream &) const
Write a section back to the file.
Supporting class from copy mechanism within ROSE.
This class represents the base class for all IR nodes within Sage III.
virtual size_t get_numberOfTraversalSuccessors()
return number of children in the traversal successor list
virtual RTIReturnType roseRTI()
return C++ Runtime-Time-Information
virtual std::vector< std::string > get_traversalSuccessorNamesContainer()
container of names of variables or container indices used used in the traversal to access AST success...
virtual void debugSerializationEnd(const char *className)
Called by generated serializers.
static std::string getNodeIdString(SgNode *sgnode)
compute the NodeId for a particular SgNode*.
virtual bool isInMemoryPool()
FOR INTERNAL USE This is used in internal tests to verify that all IR nodes are allocated from the he...
int variant() const
Older version function returns enum value "NODE".
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 no...
virtual size_t get_childIndex(SgNode *child)
index-based access to traversal successors by child node
virtual void debugSerializationBegin(const char *className)
Called by generated serializers.
virtual std::vector< SgNode * > get_traversalSuccessorContainer()
container of pointers to AST successor nodes used in the traversal overridden in every class by gener...
static void visitRepresentativeNode(ROSE_VisitTraversal &visit)
FOR INTERNAL USE Support for type-based traversal.
virtual void checkDataMemberPointersIfInMemoryPool()
FOR INTERNAL USE This is used in internal tests to verify that all IR nodes are allocated from the he...
static size_t numberOfNodes()
Returns the total number of IR nodes of this type.
virtual void accept(ROSE_VisitorPattern &visitor)
support for the classic visitor pattern done in GoF
virtual SgNode * get_traversalSuccessorByIndex(size_t idx)
index-based access to traversal successors by index number
static void traverseMemoryPoolVisitorPattern(ROSE_VisitorPattern &visitor)
FOR INTERNAL USE Support for visitor pattern.
void executeVisitorMemberFunction(ROSE_VisitorPattern &visitor)
FOR INTERNAL USE Support for visitor pattern.
static SgNode * getNodeByNodeId(VariantT variantT, size_t poolIdx, size_t itemIdx)
Find a node by its variant type, pool index, and item index.
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.
virtual const char * sage_class_name() const
generates string representing the class name: (e.g. for SgNode returns "SgNode").
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
static SgNode * getNodeByNodeIdInternal(size_t poolIdx, size_t itemIdx)
FOR INTERNAL USE Find an SgNode from its memory pool and location therin.
SgNode * addRegExpAttribute(std::string s, AstRegExAttribute *a)
Support for AST matching using regular expression.
void serialize(std::ostream &output, Graph &graph)
Serialize a graph into a stream of bytes.
void copy(const Word *src, const BitRange &srcRange, Word *dst, const BitRange &dstRange)
Copy some bits.