2#ifndef ROSE_SgAsmLEFileHeader_H
3#define ROSE_SgAsmLEFileHeader_H
5#include <Cxx_GrammarDeclarations.h>
6#include <SgAsmGenericHeader.h>
27#include <Rose/BinaryAnalysis/ByteOrder.h>
29#ifdef ROSE_SgAsmLEFileHeader_IMPL
30#include <SgAsmDOSExtendedHeader.h>
31#include <SgAsmLEEntryTable.h>
32#include <SgAsmLENameTable.h>
33#include <SgAsmLEPageTable.h>
34#include <SgAsmLERelocTable.h>
35#include <SgAsmLESectionTable.h>
43#if !defined(DOCUMENTATION)
58#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
60 friend class boost::serialization::access;
66 s & BOOST_SERIALIZATION_NVP(p_e_byte_order);
67 s & BOOST_SERIALIZATION_NVP(p_e_word_order);
68 s & BOOST_SERIALIZATION_NVP(p_e_format_level);
69 s & BOOST_SERIALIZATION_NVP(p_e_cpu_type);
70 s & BOOST_SERIALIZATION_NVP(p_e_os_type);
71 s & BOOST_SERIALIZATION_NVP(p_e_module_version);
72 s & BOOST_SERIALIZATION_NVP(p_e_flags);
73 s & BOOST_SERIALIZATION_NVP(p_e_eip_section);
74 s & BOOST_SERIALIZATION_NVP(p_e_esp_section);
75 s & BOOST_SERIALIZATION_NVP(p_e_last_page_size);
76 s & BOOST_SERIALIZATION_NVP(p_e_page_offset_shift);
77 s & BOOST_SERIALIZATION_NVP(p_e_fixup_sect_cksum);
78 s & BOOST_SERIALIZATION_NVP(p_e_loader_sect_cksum);
79 s & BOOST_SERIALIZATION_NVP(p_e_secttab_nentries);
80 s & BOOST_SERIALIZATION_NVP(p_e_rsrctab_nentries);
81 s & BOOST_SERIALIZATION_NVP(p_e_fmtdirtab_nentries);
82 s & BOOST_SERIALIZATION_NVP(p_e_import_modtab_nentries);
83 s & BOOST_SERIALIZATION_NVP(p_e_preload_npages);
84 s & BOOST_SERIALIZATION_NVP(p_e_nonresnametab_size);
85 s & BOOST_SERIALIZATION_NVP(p_e_nonresnametab_cksum);
86 s & BOOST_SERIALIZATION_NVP(p_e_auto_ds_section);
87 s & BOOST_SERIALIZATION_NVP(p_e_debug_info_size);
88 s & BOOST_SERIALIZATION_NVP(p_e_num_instance_preload);
89 s & BOOST_SERIALIZATION_NVP(p_e_num_instance_demand);
90 s & BOOST_SERIALIZATION_NVP(p_e_heap_size);
91 s & BOOST_SERIALIZATION_NVP(p_e_npages);
92 s & BOOST_SERIALIZATION_NVP(p_e_eip);
93 s & BOOST_SERIALIZATION_NVP(p_e_esp);
94 s & BOOST_SERIALIZATION_NVP(p_e_page_size);
95 s & BOOST_SERIALIZATION_NVP(p_e_fixup_sect_size);
96 s & BOOST_SERIALIZATION_NVP(p_e_loader_sect_size);
97 s & BOOST_SERIALIZATION_NVP(p_e_secttab_rfo);
98 s & BOOST_SERIALIZATION_NVP(p_e_pagetab_rfo);
99 s & BOOST_SERIALIZATION_NVP(p_e_iterpages_offset);
100 s & BOOST_SERIALIZATION_NVP(p_e_rsrctab_rfo);
101 s & BOOST_SERIALIZATION_NVP(p_e_resnametab_rfo);
102 s & BOOST_SERIALIZATION_NVP(p_e_entrytab_rfo);
103 s & BOOST_SERIALIZATION_NVP(p_e_fmtdirtab_rfo);
104 s & BOOST_SERIALIZATION_NVP(p_e_fixup_pagetab_rfo);
105 s & BOOST_SERIALIZATION_NVP(p_e_fixup_rectab_rfo);
106 s & BOOST_SERIALIZATION_NVP(p_e_import_modtab_rfo);
107 s & BOOST_SERIALIZATION_NVP(p_e_import_proctab_rfo);
108 s & BOOST_SERIALIZATION_NVP(p_e_ppcksumtab_rfo);
109 s & BOOST_SERIALIZATION_NVP(p_e_data_pages_offset);
110 s & BOOST_SERIALIZATION_NVP(p_e_nonresnametab_offset);
111 s & BOOST_SERIALIZATION_NVP(p_e_debug_info_rfo);
112 s & BOOST_SERIALIZATION_NVP(p_dos2Header);
113 s & BOOST_SERIALIZATION_NVP(p_sectionTable);
114 s & BOOST_SERIALIZATION_NVP(p_pageTable);
115 s & BOOST_SERIALIZATION_NVP(p_residentNameTable);
116 s & BOOST_SERIALIZATION_NVP(p_nonresidentNameTable);
117 s & BOOST_SERIALIZATION_NVP(p_entryTable);
118 s & BOOST_SERIALIZATION_NVP(p_relocationTable);
130 struct LEFileHeader_disk {
131 unsigned char e_magic[2];
132 unsigned char e_byte_order;
133 unsigned char e_word_order;
134 uint32_t e_format_level;
137 uint32_t e_module_version;
140 uint32_t e_eip_section;
142 uint32_t e_esp_section;
144 uint32_t e_page_size;
145 uint32_t e_lps_or_shift;
146 uint32_t e_fixup_sect_size;
147 uint32_t e_fixup_sect_cksum;
148 uint32_t e_loader_sect_size;
149 uint32_t e_loader_sect_cksum;
150 uint32_t e_secttab_rfo;
151 uint32_t e_secttab_nentries;
152 uint32_t e_pagetab_rfo;
153 uint32_t e_iterpages_offset;
154 uint32_t e_rsrctab_rfo;
155 uint32_t e_rsrctab_nentries;
156 uint32_t e_resnametab_rfo;
157 uint32_t e_entrytab_rfo;
158 uint32_t e_fmtdirtab_rfo;
159 uint32_t e_fmtdirtab_nentries;
160 uint32_t e_fixup_pagetab_rfo;
161 uint32_t e_fixup_rectab_rfo;
162 uint32_t e_import_modtab_rfo;
163 uint32_t e_import_modtab_nentries;
164 uint32_t e_import_proctab_rfo;
165 uint32_t e_ppcksumtab_rfo;
166 uint32_t e_data_pages_offset;
167 uint32_t e_preload_npages;
168 uint32_t e_nonresnametab_offset;
169 uint32_t e_nonresnametab_size;
170 uint32_t e_nonresnametab_cksum;
171 uint32_t e_auto_ds_section;
172 uint32_t e_debug_info_rfo;
173 uint32_t e_debug_info_size;
174 uint32_t e_num_instance_preload;
175 uint32_t e_num_instance_demand;
176 uint32_t e_heap_size;
181 __attribute__((packed))
190 HF_RESERVED = 0xbffc5ccb,
191 HF_PROC_LIB_INIT = 0x00000004,
192 HF_IFIXUPS_APPLIED = 0x00000010,
193 HF_EFIXUPS_APPLIED = 0x00000020,
194 HF_PM_WINDOW_NO = 0x00000100,
195 HF_PM_WINDOW_OK = 0x00000200,
196 HF_PM_WINDOW_USE = 0x00000300,
197 HF_NOT_LOADABLE = 0x00002000,
198 HF_PROC_LIB_TERM = 0x40000000,
200 HF_MODTYPE_MASK = 0x00038000,
201 HF_MODTYPE_PROG = 0x00000000,
202 HF_MODTYPE_LIB = 0x00008000,
203 HF_MODTYPE_PLIB = 0x00018000,
204 HF_MODTYPE_PDEV = 0x00020000,
205 HF_MODTYPE_VDEV = 0x00028000
213 unsigned const& get_e_byte_order()
const;
214 void set_e_byte_order(
unsigned const&);
217 unsigned const& get_e_word_order()
const;
218 void set_e_word_order(
unsigned const&);
221 unsigned const& get_e_format_level()
const;
222 void set_e_format_level(
unsigned const&);
225 unsigned const& get_e_cpu_type()
const;
226 void set_e_cpu_type(
unsigned const&);
229 unsigned const& get_e_os_type()
const;
230 void set_e_os_type(
unsigned const&);
233 unsigned const& get_e_module_version()
const;
234 void set_e_module_version(
unsigned const&);
237 unsigned const& get_e_flags()
const;
238 void set_e_flags(
unsigned const&);
241 unsigned const& get_e_eip_section()
const;
242 void set_e_eip_section(
unsigned const&);
245 unsigned const& get_e_esp_section()
const;
246 void set_e_esp_section(
unsigned const&);
249 unsigned const& get_e_last_page_size()
const;
250 void set_e_last_page_size(
unsigned const&);
253 unsigned const& get_e_page_offset_shift()
const;
254 void set_e_page_offset_shift(
unsigned const&);
257 unsigned const& get_e_fixup_sect_cksum()
const;
258 void set_e_fixup_sect_cksum(
unsigned const&);
261 unsigned const& get_e_loader_sect_cksum()
const;
262 void set_e_loader_sect_cksum(
unsigned const&);
265 unsigned const& get_e_secttab_nentries()
const;
266 void set_e_secttab_nentries(
unsigned const&);
269 unsigned const& get_e_rsrctab_nentries()
const;
270 void set_e_rsrctab_nentries(
unsigned const&);
273 unsigned const& get_e_fmtdirtab_nentries()
const;
274 void set_e_fmtdirtab_nentries(
unsigned const&);
277 unsigned const& get_e_import_modtab_nentries()
const;
278 void set_e_import_modtab_nentries(
unsigned const&);
281 unsigned const& get_e_preload_npages()
const;
282 void set_e_preload_npages(
unsigned const&);
285 unsigned const& get_e_nonresnametab_size()
const;
286 void set_e_nonresnametab_size(
unsigned const&);
289 unsigned const& get_e_nonresnametab_cksum()
const;
290 void set_e_nonresnametab_cksum(
unsigned const&);
293 unsigned const& get_e_auto_ds_section()
const;
294 void set_e_auto_ds_section(
unsigned const&);
297 unsigned const& get_e_debug_info_size()
const;
298 void set_e_debug_info_size(
unsigned const&);
301 unsigned const& get_e_num_instance_preload()
const;
302 void set_e_num_instance_preload(
unsigned const&);
305 unsigned const& get_e_num_instance_demand()
const;
306 void set_e_num_instance_demand(
unsigned const&);
309 unsigned const& get_e_heap_size()
const;
310 void set_e_heap_size(
unsigned const&);
313 rose_addr_t
const& get_e_npages()
const;
314 void set_e_npages(rose_addr_t
const&);
317 rose_addr_t
const& get_e_eip()
const;
318 void set_e_eip(rose_addr_t
const&);
321 rose_addr_t
const& get_e_esp()
const;
322 void set_e_esp(rose_addr_t
const&);
325 rose_addr_t
const& get_e_page_size()
const;
326 void set_e_page_size(rose_addr_t
const&);
329 rose_addr_t
const& get_e_fixup_sect_size()
const;
330 void set_e_fixup_sect_size(rose_addr_t
const&);
333 rose_addr_t
const& get_e_loader_sect_size()
const;
334 void set_e_loader_sect_size(rose_addr_t
const&);
337 rose_addr_t
const& get_e_secttab_rfo()
const;
338 void set_e_secttab_rfo(rose_addr_t
const&);
341 rose_addr_t
const& get_e_pagetab_rfo()
const;
342 void set_e_pagetab_rfo(rose_addr_t
const&);
345 rose_addr_t
const& get_e_iterpages_offset()
const;
346 void set_e_iterpages_offset(rose_addr_t
const&);
349 rose_addr_t
const& get_e_rsrctab_rfo()
const;
350 void set_e_rsrctab_rfo(rose_addr_t
const&);
353 rose_addr_t
const& get_e_resnametab_rfo()
const;
354 void set_e_resnametab_rfo(rose_addr_t
const&);
357 rose_addr_t
const& get_e_entrytab_rfo()
const;
358 void set_e_entrytab_rfo(rose_addr_t
const&);
361 rose_addr_t
const& get_e_fmtdirtab_rfo()
const;
362 void set_e_fmtdirtab_rfo(rose_addr_t
const&);
365 rose_addr_t
const& get_e_fixup_pagetab_rfo()
const;
366 void set_e_fixup_pagetab_rfo(rose_addr_t
const&);
369 rose_addr_t
const& get_e_fixup_rectab_rfo()
const;
370 void set_e_fixup_rectab_rfo(rose_addr_t
const&);
373 rose_addr_t
const& get_e_import_modtab_rfo()
const;
374 void set_e_import_modtab_rfo(rose_addr_t
const&);
377 rose_addr_t
const& get_e_import_proctab_rfo()
const;
378 void set_e_import_proctab_rfo(rose_addr_t
const&);
381 rose_addr_t
const& get_e_ppcksumtab_rfo()
const;
382 void set_e_ppcksumtab_rfo(rose_addr_t
const&);
385 rose_addr_t
const& get_e_data_pages_offset()
const;
386 void set_e_data_pages_offset(rose_addr_t
const&);
389 rose_addr_t
const& get_e_nonresnametab_offset()
const;
390 void set_e_nonresnametab_offset(rose_addr_t
const&);
393 rose_addr_t
const& get_e_debug_info_rfo()
const;
394 void set_e_debug_info_rfo(rose_addr_t
const&);
428 virtual void unparse(std::ostream&)
const override;
429 virtual void dump(FILE*,
const char *prefix, ssize_t idx)
const override;
448 SgAsmLEPageTable* get_page_table() const ROSE_DEPRECATED("use get_pageTable");
449 void set_page_table(
SgAsmLEPageTable*) ROSE_DEPRECATED("use set_pageTable");
450 SgAsmLENameTable* get_resname_table() const ROSE_DEPRECATED("use get_residentNameTable");
451 void set_resname_table(
SgAsmLENameTable*) ROSE_DEPRECATED("use set_residentNameTable");
452 SgAsmLENameTable* get_nonresname_table() const ROSE_DEPRECATED("use get_nonresidentNameTable");
453 void set_nonresname_table(
SgAsmLENameTable*) ROSE_DEPRECATED("use set_nonresidentNameTable");
454 SgAsmLEEntryTable* get_entry_table() const ROSE_DEPRECATED("use get_entryTable");
456 SgAsmLERelocTable* get_reloc_table() const ROSE_DEPRECATED("use get_relocationTable");
457 void set_reloc_table(
SgAsmLERelocTable*) ROSE_DEPRECATED("use set_relocationTable");
458 const
char *format_name() const override ROSE_DEPRECATED("use formatName");
475 void initializeProperties();
494 virtual std::
string class_name() const override;
497 virtual VariantT variantT() const override;
502 enum { static_variant = V_SgAsmLEFileHeader };
517 static const unsigned pool_size;
519 static std::vector<unsigned char *> pools;
524 static unsigned long initializeStorageClassArray(SgAsmLEFileHeaderStorageClass *);
527 static void clearMemoryPool();
528 static void deleteMemoryPool();
531 static void extendMemoryPoolForFileIO();
536 static SgAsmLEFileHeader * getPointerFromGlobalIndex(AstSpecificDataManagingClass *,
unsigned long);
539 static unsigned long getNumberOfValidNodesAndSetGlobalIndexInFreepointer(
unsigned long);
541 static void resetValidFreepointers();
543 static unsigned long getNumberOfLastValidPointer();
546#if defined(INLINE_FUNCTIONS)
548 inline void *
operator new (
size_t size);
551 void *
operator new (
size_t size);
554 void operator delete (
void* pointer,
size_t size);
557 void operator delete (
void* pointer)
603#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
606 virtual RTIReturnType
roseRTI()
override;
620 virtual const char*
sage_class_name() const override ROSE_DEPRECATED_FUNCTION;
626 virtual int variant() const ROSE_DEPRECATED_FUNCTION;
808 friend class SgAsmLEFileHeaderStorageClass;
811 friend class AstSpecificDataManagingClass;
814 friend class AstSpecificDataManagingClassStorageClass;
846#define BUILD_ATERM_SUPPORT 0
847 #if BUILD_ATERM_SUPPORT
848 #ifdef ROSE_USE_ROSE_ATERM_SUPPORT
860 virtual ATerm generate_ATerm()
override;
863 virtual void generate_ATerm_Annotation(ATerm & term)
override;
941unsigned p_e_byte_order;
945unsigned p_e_word_order;
949unsigned p_e_format_level;
953unsigned p_e_cpu_type;
961unsigned p_e_module_version;
969unsigned p_e_eip_section;
973unsigned p_e_esp_section;
977unsigned p_e_last_page_size;
981unsigned p_e_page_offset_shift;
985unsigned p_e_fixup_sect_cksum;
989unsigned p_e_loader_sect_cksum;
993unsigned p_e_secttab_nentries;
997unsigned p_e_rsrctab_nentries;
1001unsigned p_e_fmtdirtab_nentries;
1005unsigned p_e_import_modtab_nentries;
1009unsigned p_e_preload_npages;
1013unsigned p_e_nonresnametab_size;
1017unsigned p_e_nonresnametab_cksum;
1021unsigned p_e_auto_ds_section;
1025unsigned p_e_debug_info_size;
1029unsigned p_e_num_instance_preload;
1033unsigned p_e_num_instance_demand;
1037unsigned p_e_heap_size;
1041rose_addr_t p_e_npages;
1053rose_addr_t p_e_page_size;
1057rose_addr_t p_e_fixup_sect_size;
1061rose_addr_t p_e_loader_sect_size;
1065rose_addr_t p_e_secttab_rfo;
1069rose_addr_t p_e_pagetab_rfo;
1073rose_addr_t p_e_iterpages_offset;
1077rose_addr_t p_e_rsrctab_rfo;
1081rose_addr_t p_e_resnametab_rfo;
1085rose_addr_t p_e_entrytab_rfo;
1089rose_addr_t p_e_fmtdirtab_rfo;
1093rose_addr_t p_e_fixup_pagetab_rfo;
1097rose_addr_t p_e_fixup_rectab_rfo;
1101rose_addr_t p_e_import_modtab_rfo;
1105rose_addr_t p_e_import_proctab_rfo;
1109rose_addr_t p_e_ppcksumtab_rfo;
1113rose_addr_t p_e_data_pages_offset;
1117rose_addr_t p_e_nonresnametab_offset;
1121rose_addr_t p_e_debug_info_rfo;
Class holding static data and functions supporting File I/O.
Attribute containing a regex expression as a string.
Base class for binary files.
virtual SgAsmGenericSection * parse()
Parse contents of the section.
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.