2#ifndef ROSE_SgAsmExecutableFileFormat_H
3#define ROSE_SgAsmExecutableFileFormat_H
5#include <Cxx_GrammarDeclarations.h>
27#include <Rose/Exception.h>
34#if !defined(DOCUMENTATION)
49#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
51 friend class boost::serialization::access;
56 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
SgAsmNode);
74 :
Rose::Exception(
"short read"), section(section), offset(offset), size(size) {}
75 ShortRead(
const class SgAsmGenericSection *section,
size_t offset,
size_t size,
const std::string &mesg)
76 :
Rose::Exception(mesg), section(section), offset(offset), size(size) {}
77 ShortRead(
const class SgAsmGenericSection *section,
size_t offset,
size_t size,
const char *mesg)
78 :
Rose::Exception(mesg), section(section), offset(offset), size(size) {}
79 ~ShortRead() throw () {}
92 :
Rose::Exception(
""), section(section), offset(offset), size(size) {}
93 ShortWrite(
const class SgAsmGenericSection *section,
size_t offset,
size_t size,
const std::string &mesg)
94 :
Rose::Exception(mesg), section(section), offset(offset), size(size) {}
95 ShortWrite(
const class SgAsmGenericSection *section,
size_t offset,
size_t size,
const char *mesg)
96 :
Rose::Exception(mesg), section(section), offset(offset), size(size) {}
104 FormatError(
const std::string &mesg)
105 :
Rose::Exception(mesg) {}
106 FormatError(
const char *mesg)
107 :
Rose::Exception(mesg) {}
108 ~FormatError() throw () {}
112 typedef struct stat fileDetails;
153 ISA_UNSPECIFIED = 0x0000,
155 ISA_FAMILY_MASK = 0xff00,
157 ISA_IA32_Family = 0x0100,
158 ISA_IA32_286 = 0x0101,
159 ISA_IA32_386 = 0x0102,
160 ISA_IA32_486 = 0x0103,
161 ISA_IA32_Pentium = 0x0104,
162 ISA_IA32_Cyrix6x86 = 0x0105,
163 ISA_IA32_AMDK5 = 0x0106,
164 ISA_IA32_PentiumPro = 0x0107,
165 ISA_IA32_PentiumII = 0x0108,
166 ISA_IA32_Athlon = 0x0109,
167 ISA_IA32_Pentium4 = 0x010a,
168 ISA_IA32_PentiumM = 0x010b,
170 ISA_X8664_Family = 0x0200,
171 ISA_X8664_Athlon64 = 0x0201,
172 ISA_X8664_Prescott = 0x0202,
173 ISA_X8664_IntelCore = 0x0203,
174 ISA_X8664_AMDPhenom = 0x0204,
176 ISA_SPARC_Family = 0x0300,
177 ISA_SPARC_V7 = 0x0301,
178 ISA_SPARC_V8 = 0x0302,
179 ISA_SPARC_V8E = 0x0303,
180 ISA_SPARC_V9 = 0x0304,
181 ISA_SPARC_V9JPS1 = 0x0305,
182 ISA_SPARC_V9UA = 0x0306,
183 ISA_SPARC_V9JPS2 = 0x0307,
185 ISA_M68K_Family = 0x0400,
186 ISA_M68K_68000 = 0x0401,
187 ISA_M68K_68EC000 = 0x0402,
188 ISA_M68K_68HC000 = 0x0403,
189 ISA_M68K_68008 = 0x0404,
190 ISA_M68K_68010 = 0x0405,
191 ISA_M68K_68012 = 0x0406,
192 ISA_M68K_68020 = 0x0407,
193 ISA_M68K_68EC020 = 0x0408,
194 ISA_M68K_68030 = 0x0409,
195 ISA_M68K_68EC030 = 0x040a,
196 ISA_M68K_68040 = 0x040b,
197 ISA_M68K_68EC040 = 0x040c,
198 ISA_M68K_68LC040 = 0x040d,
199 ISA_M68K_68060 = 0x040e,
200 ISA_M68K_ColdFire = 0x040f,
201 ISA_M68K_DragonBall = 0x0410,
203 ISA_M88K_Family = 0x0500,
204 ISA_M88K_88100 = 0x0501,
205 ISA_M88K_88110 = 0x0502,
206 ISA_M88K_88110MP = 0x0503,
207 ISA_M88K_88120 = 0x0504,
209 ISA_MIPS_Family = 0x0600,
210 ISA_MIPS_MarkI = 0x0601,
211 ISA_MIPS_MarkII = 0x0602,
212 ISA_MIPS_MarkIII = 0x0603,
213 ISA_MIPS_R2000 = 0x0604,
214 ISA_MIPS_R3000 = 0x0605,
215 ISA_MIPS_R4000 = 0x0606,
216 ISA_MIPS_R4200 = 0x0607,
217 ISA_MIPS_R4300 = 0x0608,
218 ISA_MIPS_R4600 = 0x0609,
219 ISA_MIPS_R4650 = 0x060a,
220 ISA_MIPS_R4700 = 0x060b,
221 ISA_MIPS_R5000 = 0x060c,
222 ISA_MIPS_RM7000 = 0x060d,
223 ISA_MIPS_R8000 = 0x060e,
224 ISA_MIPS_R10000 = 0x060f,
225 ISA_MIPS_R12000 = 0x0610,
226 ISA_MIPS_R14000 = 0x0611,
227 ISA_MIPS_R16000 = 0x0612,
228 ISA_MIPS_R16000A = 0x0613,
229 ISA_MIPS_16 = 0x0614,
230 ISA_MIPS_FPU = 0x0615,
231 ISA_MIPS_16FPU = 0x0616,
233 ISA_I860_Family = 0x0700,
234 ISA_I860_860XR = 0x0701,
235 ISA_I860_860XP = 0x0702,
237 ISA_IA64_Family = 0x0800,
238 ISA_IA64_Itanium = 0x0801,
239 ISA_IA64_Itanium2 = 0x0802,
242 ISA_ARM_Family = 0x0900,
243 ISA_ARM_ARM1 = 0x0901,
244 ISA_ARM_ARM2 = 0x0902,
245 ISA_ARM_ARM3 = 0x0903,
246 ISA_ARM_ARM6 = 0x0904,
247 ISA_ARM_ARM7 = 0x0905,
248 ISA_ARM_ARM7TDMI = 0x0906,
249 ISA_ARM_StrongARM = 0x0907,
250 ISA_ARM_ARM8 = 0x0908,
251 ISA_ARM_ARM9TDMI = 0x0909,
252 ISA_ARM_ARM9E = 0x090a,
253 ISA_ARM_ARM10E = 0x090b,
254 ISA_ARM_XScale = 0x090c,
258 ISA_ARM_ARM11 = 0x090d,
259 ISA_ARM_Cortex = 0x090e,
260 ISA_ARM_A64 = 0x090f,
265 ISA_OTHER_Family = 0xf000,
267 ISA_ATT_WE_32100 = 0xf001,
268 ISA_IBM_System_370 = 0xf002,
270 ISA_Fujitsu_VPP500 = 0xf004,
271 ISA_Sun_v8plus = 0xf005,
272 ISA_PowerPC = 0xf006,
273 ISA_PowerPC_64bit = 0xf007,
274 ISA_IBM_S390 = 0xf008,
275 ISA_NEC_V800_series = 0xf009,
276 ISA_Fujitsu_FR20 = 0xf00a,
277 ISA_TRW_RH_32 = 0xf00b,
278 ISA_Motorola_RCE = 0xf00c,
279 ISA_Digital_Alpha_fake = 0xf00e,
280 ISA_Hitachi_SH = 0xf00f,
281 ISA_Siemens_Tricore = 0xf010,
282 ISA_Argonaut_RISC_Core = 0xf011,
283 ISA_Hitachi_H8_300 = 0xf012,
284 ISA_Hitachi_H8_300H = 0xf013,
285 ISA_Hitachi_H8S = 0xf014,
286 ISA_Hitachi_H8_500 = 0xf015,
287 ISA_Stanford_MIPS_X = 0xf016,
288 ISA_Motorola_M68HC12 = 0xf017,
289 ISA_Fujitsu_MMA_Multimedia_Accelerator=0xf018,
290 ISA_Siemens_PCP = 0xf019,
291 ISA_Sony_nCPU_embeeded_RISC = 0xf01a,
292 ISA_Denso_NDR1_microprocessor=0xf01b,
293 ISA_Motorola_Start_Core_processor=0xf01c,
294 ISA_Toyota_ME16_processor = 0xf01d,
295 ISA_STMicroelectronic_ST100_processor=0xf01e,
296 ISA_Advanced_Logic_Corp_Tinyj_emb_family=0xf01f,
297 ISA_AMD_x86_64_architecture = 0xf020,
298 ISA_Sony_DSP_Processor = 0xf021,
299 ISA_Siemens_FX66_microcontroller=0xf022,
300 ISA_STMicroelectronics_ST9_plus_8_16_microcontroller=0xf023,
301 ISA_STMicroelectronics_ST7_8bit_microcontroller=0xf024,
302 ISA_Motorola_MC68HC16_microcontroller=0xf025,
303 ISA_Motorola_MC68HC11_microcontroller=0xf026,
304 ISA_Motorola_MC68HC08_microcontroller=0xf027,
305 ISA_Motorola_MC68HC05_microcontroller=0xf028,
306 ISA_Silicon_Graphics_SVx = 0xf029,
307 ISA_STMicroelectronics_ST19_8bit_microcontroller=0xf02a,
308 ISA_Digital_VAX = 0xf02b,
309 ISA_Axis_Communications_32bit_embedded_processor=0xf02c,
310 ISA_Infineon_Technologies_32bit_embedded_processor=0xf02d,
311 ISA_Element_14_64bit_DSP_Processor=0xf02e,
312 ISA_LSI_Logic_16bit_DSP_Processor=0xf02f,
313 ISA_Donald_Knuths_educational_64bit_processor=0xf030,
314 ISA_Harvard_University_machine_independent_object_files=0xf031,
315 ISA_SiTera_Prism = 0xf032,
316 ISA_Atmel_AVR_8bit_microcontroller=0xf033,
317 ISA_Fujitsu_FR30 = 0xf034,
318 ISA_Mitsubishi_D10V = 0xf035,
319 ISA_Mitsubishi_D30V = 0xf036,
320 ISA_NEC_v850 = 0xf037,
321 ISA_Mitsubishi_M32R = 0xf038,
322 ISA_Matsushita_MN10300 = 0xf039,
323 ISA_Matsushita_MN10200 = 0xf03a,
324 ISA_picoJava = 0xf03b,
325 ISA_OpenRISC_32bit_embedded_processor=0xf03c,
326 ISA_ARC_Cores_Tangent_A5 = 0xf03d,
327 ISA_Tensilica_Xtensa_Architecture=0xf03e,
328 ISA_Digital_Alpha = 0xf03f,
329 ISA_Matsushita_AM33 = 0xf040,
330 ISA_EFI_ByteCode = 0xf041
341 PURPOSE_PROC_SPECIFIC
355 static void unparseBinaryFormat(
const std::string &name,
SgAsmGenericFile*);
424 virtual std::string
class_name()
const override;
427 virtual VariantT
variantT()
const override;
432 enum { static_variant = V_SgAsmExecutableFileFormat };
447 static const unsigned pool_size;
449 static std::vector<unsigned char *> pools;
454 static unsigned long initializeStorageClassArray(SgAsmExecutableFileFormatStorageClass *);
457 static void clearMemoryPool();
458 static void deleteMemoryPool();
461 static void extendMemoryPoolForFileIO();
469 static unsigned long getNumberOfValidNodesAndSetGlobalIndexInFreepointer(
unsigned long);
471 static void resetValidFreepointers();
473 static unsigned long getNumberOfLastValidPointer();
476#if defined(INLINE_FUNCTIONS)
478 inline void *
operator new (
size_t size);
481 void *
operator new (
size_t size);
484 void operator delete (
void* pointer,
size_t size);
487 void operator delete (
void* pointer)
533#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
536 virtual RTIReturnType
roseRTI()
override;
550 virtual const char*
sage_class_name() const override ROSE_DEPRECATED_FUNCTION;
556 virtual int variant() const ROSE_DEPRECATED_FUNCTION;
738 friend class SgAsmExecutableFileFormatStorageClass;
741 friend class AstSpecificDataManagingClass;
744 friend class AstSpecificDataManagingClassStorageClass;
776#define BUILD_ATERM_SUPPORT 0
777 #if BUILD_ATERM_SUPPORT
778 #ifdef ROSE_USE_ROSE_ATERM_SUPPORT
790 virtual ATerm generate_ATerm()
override;
793 virtual void generate_ATerm_Annotation(ATerm & term)
override;
Class holding static data and functions supporting File I/O.
Attribute containing a regex expression as a string.
Base class for all ROSE exceptions.
Base class for binary files.
Contiguous region of a file.
Base class for all binary analysis IR nodes.
void initializeProperties()
Initialize all properties that have explicit initial values.
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 VariantT variantT() const
returns new style SageIII enum values
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...
virtual std::string class_name() const
returns a string representing the class name
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 initDiagnostics()
Initialize diagnostics.
ROSE_DLL_API Sawyer::Message::Facility mlog
Diagnostic facility for the ROSE library as a whole.
ROSE_UTIL_API std::string toString(const Path &)
Convert a path to a string.
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.