2#ifndef ROSE_SgAsmExecutableFileFormat_H
3#define ROSE_SgAsmExecutableFileFormat_H
5#include <Cxx_GrammarDeclarations.h>
27#include <Rose/BinaryAnalysis/Address.h>
28#include <Rose/Exception.h>
35#if !defined(DOCUMENTATION)
50#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
52 friend class boost::serialization::access;
57 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
SgAsmNode);
75 :
Rose::Exception(
"short read"), section(section), offset(offset), size(size) {}
76 ShortRead(
const class SgAsmGenericSection *section,
size_t offset,
size_t size,
const std::string &mesg)
77 :
Rose::Exception(mesg), section(section), offset(offset), size(size) {}
78 ShortRead(
const class SgAsmGenericSection *section,
size_t offset,
size_t size,
const char *mesg)
79 :
Rose::Exception(mesg), section(section), offset(offset), size(size) {}
80 ~ShortRead() throw () {}
93 :
Rose::Exception(
""), section(section), offset(offset), size(size) {}
94 ShortWrite(
const class SgAsmGenericSection *section,
size_t offset,
size_t size,
const std::string &mesg)
95 :
Rose::Exception(mesg), section(section), offset(offset), size(size) {}
96 ShortWrite(
const class SgAsmGenericSection *section,
size_t offset,
size_t size,
const char *mesg)
97 :
Rose::Exception(mesg), section(section), offset(offset), size(size) {}
105 FormatError(
const std::string &mesg)
106 :
Rose::Exception(mesg) {}
107 FormatError(
const char *mesg)
108 :
Rose::Exception(mesg) {}
109 ~FormatError() throw () {}
113 typedef struct stat fileDetails;
154 ISA_UNSPECIFIED = 0x0000,
156 ISA_FAMILY_MASK = 0xff00,
158 ISA_IA32_Family = 0x0100,
159 ISA_IA32_286 = 0x0101,
160 ISA_IA32_386 = 0x0102,
161 ISA_IA32_486 = 0x0103,
162 ISA_IA32_Pentium = 0x0104,
163 ISA_IA32_Cyrix6x86 = 0x0105,
164 ISA_IA32_AMDK5 = 0x0106,
165 ISA_IA32_PentiumPro = 0x0107,
166 ISA_IA32_PentiumII = 0x0108,
167 ISA_IA32_Athlon = 0x0109,
168 ISA_IA32_Pentium4 = 0x010a,
169 ISA_IA32_PentiumM = 0x010b,
171 ISA_X8664_Family = 0x0200,
172 ISA_X8664_Athlon64 = 0x0201,
173 ISA_X8664_Prescott = 0x0202,
174 ISA_X8664_IntelCore = 0x0203,
175 ISA_X8664_AMDPhenom = 0x0204,
177 ISA_SPARC_Family = 0x0300,
178 ISA_SPARC_V7 = 0x0301,
179 ISA_SPARC_V8 = 0x0302,
180 ISA_SPARC_V8E = 0x0303,
181 ISA_SPARC_V9 = 0x0304,
182 ISA_SPARC_V9JPS1 = 0x0305,
183 ISA_SPARC_V9UA = 0x0306,
184 ISA_SPARC_V9JPS2 = 0x0307,
186 ISA_M68K_Family = 0x0400,
187 ISA_M68K_68000 = 0x0401,
188 ISA_M68K_68EC000 = 0x0402,
189 ISA_M68K_68HC000 = 0x0403,
190 ISA_M68K_68008 = 0x0404,
191 ISA_M68K_68010 = 0x0405,
192 ISA_M68K_68012 = 0x0406,
193 ISA_M68K_68020 = 0x0407,
194 ISA_M68K_68EC020 = 0x0408,
195 ISA_M68K_68030 = 0x0409,
196 ISA_M68K_68EC030 = 0x040a,
197 ISA_M68K_68040 = 0x040b,
198 ISA_M68K_68EC040 = 0x040c,
199 ISA_M68K_68LC040 = 0x040d,
200 ISA_M68K_68060 = 0x040e,
201 ISA_M68K_ColdFire = 0x040f,
202 ISA_M68K_DragonBall = 0x0410,
204 ISA_M88K_Family = 0x0500,
205 ISA_M88K_88100 = 0x0501,
206 ISA_M88K_88110 = 0x0502,
207 ISA_M88K_88110MP = 0x0503,
208 ISA_M88K_88120 = 0x0504,
210 ISA_MIPS_Family = 0x0600,
211 ISA_MIPS_MarkI = 0x0601,
212 ISA_MIPS_MarkII = 0x0602,
213 ISA_MIPS_MarkIII = 0x0603,
214 ISA_MIPS_R2000 = 0x0604,
215 ISA_MIPS_R3000 = 0x0605,
216 ISA_MIPS_R4000 = 0x0606,
217 ISA_MIPS_R4200 = 0x0607,
218 ISA_MIPS_R4300 = 0x0608,
219 ISA_MIPS_R4600 = 0x0609,
220 ISA_MIPS_R4650 = 0x060a,
221 ISA_MIPS_R4700 = 0x060b,
222 ISA_MIPS_R5000 = 0x060c,
223 ISA_MIPS_RM7000 = 0x060d,
224 ISA_MIPS_R8000 = 0x060e,
225 ISA_MIPS_R10000 = 0x060f,
226 ISA_MIPS_R12000 = 0x0610,
227 ISA_MIPS_R14000 = 0x0611,
228 ISA_MIPS_R16000 = 0x0612,
229 ISA_MIPS_R16000A = 0x0613,
230 ISA_MIPS_16 = 0x0614,
231 ISA_MIPS_FPU = 0x0615,
232 ISA_MIPS_16FPU = 0x0616,
234 ISA_I860_Family = 0x0700,
235 ISA_I860_860XR = 0x0701,
236 ISA_I860_860XP = 0x0702,
238 ISA_IA64_Family = 0x0800,
239 ISA_IA64_Itanium = 0x0801,
240 ISA_IA64_Itanium2 = 0x0802,
243 ISA_ARM_Family = 0x0900,
244 ISA_ARM_ARM1 = 0x0901,
245 ISA_ARM_ARM2 = 0x0902,
246 ISA_ARM_ARM3 = 0x0903,
247 ISA_ARM_ARM6 = 0x0904,
248 ISA_ARM_ARM7 = 0x0905,
249 ISA_ARM_ARM7TDMI = 0x0906,
250 ISA_ARM_StrongARM = 0x0907,
251 ISA_ARM_ARM8 = 0x0908,
252 ISA_ARM_ARM9TDMI = 0x0909,
253 ISA_ARM_ARM9E = 0x090a,
254 ISA_ARM_ARM10E = 0x090b,
255 ISA_ARM_XScale = 0x090c,
259 ISA_ARM_ARM11 = 0x090d,
260 ISA_ARM_Cortex = 0x090e,
261 ISA_ARM_A64 = 0x090f,
266 ISA_OTHER_Family = 0xf000,
268 ISA_ATT_WE_32100 = 0xf001,
269 ISA_IBM_System_370 = 0xf002,
271 ISA_Fujitsu_VPP500 = 0xf004,
272 ISA_Sun_v8plus = 0xf005,
273 ISA_PowerPC = 0xf006,
274 ISA_PowerPC_64bit = 0xf007,
275 ISA_IBM_S390 = 0xf008,
276 ISA_NEC_V800_series = 0xf009,
277 ISA_Fujitsu_FR20 = 0xf00a,
278 ISA_TRW_RH_32 = 0xf00b,
279 ISA_Motorola_RCE = 0xf00c,
280 ISA_Digital_Alpha_fake = 0xf00e,
281 ISA_Hitachi_SH = 0xf00f,
282 ISA_Siemens_Tricore = 0xf010,
283 ISA_Argonaut_RISC_Core = 0xf011,
284 ISA_Hitachi_H8_300 = 0xf012,
285 ISA_Hitachi_H8_300H = 0xf013,
286 ISA_Hitachi_H8S = 0xf014,
287 ISA_Hitachi_H8_500 = 0xf015,
288 ISA_Stanford_MIPS_X = 0xf016,
289 ISA_Motorola_M68HC12 = 0xf017,
290 ISA_Fujitsu_MMA_Multimedia_Accelerator=0xf018,
291 ISA_Siemens_PCP = 0xf019,
292 ISA_Sony_nCPU_embeeded_RISC = 0xf01a,
293 ISA_Denso_NDR1_microprocessor=0xf01b,
294 ISA_Motorola_Start_Core_processor=0xf01c,
295 ISA_Toyota_ME16_processor = 0xf01d,
296 ISA_STMicroelectronic_ST100_processor=0xf01e,
297 ISA_Advanced_Logic_Corp_Tinyj_emb_family=0xf01f,
298 ISA_AMD_x86_64_architecture = 0xf020,
299 ISA_Sony_DSP_Processor = 0xf021,
300 ISA_Siemens_FX66_microcontroller=0xf022,
301 ISA_STMicroelectronics_ST9_plus_8_16_microcontroller=0xf023,
302 ISA_STMicroelectronics_ST7_8bit_microcontroller=0xf024,
303 ISA_Motorola_MC68HC16_microcontroller=0xf025,
304 ISA_Motorola_MC68HC11_microcontroller=0xf026,
305 ISA_Motorola_MC68HC08_microcontroller=0xf027,
306 ISA_Motorola_MC68HC05_microcontroller=0xf028,
307 ISA_Silicon_Graphics_SVx = 0xf029,
308 ISA_STMicroelectronics_ST19_8bit_microcontroller=0xf02a,
309 ISA_Digital_VAX = 0xf02b,
310 ISA_Axis_Communications_32bit_embedded_processor=0xf02c,
311 ISA_Infineon_Technologies_32bit_embedded_processor=0xf02d,
312 ISA_Element_14_64bit_DSP_Processor=0xf02e,
313 ISA_LSI_Logic_16bit_DSP_Processor=0xf02f,
314 ISA_Donald_Knuths_educational_64bit_processor=0xf030,
315 ISA_Harvard_University_machine_independent_object_files=0xf031,
316 ISA_SiTera_Prism = 0xf032,
317 ISA_Atmel_AVR_8bit_microcontroller=0xf033,
318 ISA_Fujitsu_FR30 = 0xf034,
319 ISA_Mitsubishi_D10V = 0xf035,
320 ISA_Mitsubishi_D30V = 0xf036,
321 ISA_NEC_v850 = 0xf037,
322 ISA_Mitsubishi_M32R = 0xf038,
323 ISA_Matsushita_MN10300 = 0xf039,
324 ISA_Matsushita_MN10200 = 0xf03a,
325 ISA_picoJava = 0xf03b,
326 ISA_OpenRISC_32bit_embedded_processor=0xf03c,
327 ISA_ARC_Cores_Tangent_A5 = 0xf03d,
328 ISA_Tensilica_Xtensa_Architecture=0xf03e,
329 ISA_Digital_Alpha = 0xf03f,
330 ISA_Matsushita_AM33 = 0xf040,
331 ISA_EFI_ByteCode = 0xf041
342 PURPOSE_PROC_SPECIFIC
356 static void unparseBinaryFormat(
const std::string &name,
SgAsmGenericFile*);
425 virtual std::string
class_name()
const override;
428 virtual VariantT
variantT()
const override;
433 enum { static_variant = V_SgAsmExecutableFileFormat };
448 static const unsigned pool_size;
450 static std::vector<unsigned char *> pools;
455 static unsigned long initializeStorageClassArray(SgAsmExecutableFileFormatStorageClass *);
458 static void clearMemoryPool();
459 static void deleteMemoryPool();
462 static void extendMemoryPoolForFileIO();
470 static unsigned long getNumberOfValidNodesAndSetGlobalIndexInFreepointer(
unsigned long);
472 static void resetValidFreepointers();
474 static unsigned long getNumberOfLastValidPointer();
477#if defined(INLINE_FUNCTIONS)
479 inline void *
operator new (
size_t size);
482 void *
operator new (
size_t size);
485 void operator delete (
void* pointer,
size_t size);
488 void operator delete (
void* pointer)
534#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
537 virtual RTIReturnType
roseRTI()
override;
551 virtual const char*
sage_class_name() const override ROSE_DEPRECATED_FUNCTION;
557 virtual int variant() const ROSE_DEPRECATED_FUNCTION;
739 friend class SgAsmExecutableFileFormatStorageClass;
742 friend class AstSpecificDataManagingClass;
745 friend class AstSpecificDataManagingClassStorageClass;
777#define BUILD_ATERM_SUPPORT 0
778 #if BUILD_ATERM_SUPPORT
779 #ifdef ROSE_USE_ROSE_ATERM_SUPPORT
791 virtual ATerm generate_ATerm()
override;
794 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 RTIReturnType roseRTI()
return C++ Runtime-Time-Information
virtual size_t get_numberOfTraversalSuccessors() const
return number of children in the traversal successor list
virtual std::vector< std::string > get_traversalSuccessorNamesContainer() const
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 size_t get_childIndex(SgNode *child) const
index-based access to traversal successors by child node
virtual std::vector< SgNode * > get_traversalSuccessorContainer() const
container of pointers to AST successor nodes used in the traversal overridden in every class by gener...
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 void debugSerializationBegin(const char *className)
Called by generated serializers.
virtual SgNode * get_traversalSuccessorByIndex(size_t idx) const
index-based access to traversal successors by index number
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
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.
std::uint64_t Address
Address.
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.