ROSE 0.11.145.247
SgAsmElfSection.h
1
2#ifndef ROSE_SgAsmElfSection_H
3#define ROSE_SgAsmElfSection_H
4#include <RoseFirst.h>
5#include <Cxx_GrammarDeclarations.h>
6#include <SgAsmGenericSection.h>
7
8
9
10/* #line 1 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro" */
11
12// WARNING -- GENERATED CODE -- DO NOT MODIFY THIS CODE -- WARNING!
13// This code is automatically generated for each
14// terminal and non-terminal within the defined
15// grammar. There is a simple way to change the
16// code to fix bugs etc. See the ROSE README file
17// for directions.
18
19// tps: (02/22/2010): Adding DLL export requirements
20#include "rosedll.h"
21
22// predeclarations for SgAsmElfSection
23
24/* #line 25 "../../../src/frontend/SageIII//SgAsmElfSection.h" */
25/* #line 23004 "/workspace/src/ROSETTA/src/binaryInstruction.C" */
26
27#include <Rose/BinaryAnalysis/Address.h>
28
29#ifdef ROSE_SgAsmElfSection_IMPL
30#include <SgAsmElfSectionTableEntry.h>
31#include <SgAsmElfSegmentTableEntry.h>
32#endif
33
34
35/* #line 13 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro after subst for $PREDECLARATIONS" */
36
37/* #line 14 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro" */
38
39#if !defined(DOCUMENTATION)
40// Class Definition for SgAsmElfSection
41class ROSE_DLL_API SgAsmElfSection : public SgAsmGenericSection
42 {
43 public:
44
45
46/* #line 47 "../../../src/frontend/SageIII//SgAsmElfSection.h" */
47
48 virtual SgNode* copy ( SgCopyHelp& help) const override;
49// Start of memberFunctionString
50/* #line 23037 "/workspace/src/ROSETTA/src/binaryInstruction.C" */
51
52
53 //----------------------- Boost serialization for SgAsmElfSection -----------------------
54#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
55private:
56 friend class boost::serialization::access;
57
58 template<class S>
59 void serialize(S &s, const unsigned /*version*/) {
60 debugSerializationBegin("SgAsmElfSection");
61 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(SgAsmGenericSection);
62 s & BOOST_SERIALIZATION_NVP(p_linkedSection);
63 s & BOOST_SERIALIZATION_NVP(p_sectionEntry);
64 s & BOOST_SERIALIZATION_NVP(p_segmentEntry);
65 debugSerializationEnd("SgAsmElfSection");
66 }
67#endif // ROSE_ENABLE_BOOST_SERIALIZATION
68public:
69public:
75 SgAsmElfSection* const& get_linkedSection() const;
76 virtual void set_linkedSection(SgAsmElfSection*);
78public:
82 SgAsmElfSectionTableEntry* const& get_sectionEntry() const;
83 void set_sectionEntry(SgAsmElfSectionTableEntry* const&);
86public:
90 SgAsmElfSegmentTableEntry* const& get_segmentEntry() const;
91 void set_segmentEntry(SgAsmElfSegmentTableEntry* const&);
93public:
99
105 SgAsmElfSection *initFromSectionTable(SgAsmElfSectionTableEntry*, SgAsmElfStringSection*, int id);
106
110 SgAsmElfSection *initFromSegmentTable(SgAsmElfSegmentTableEntry*, bool mmapOnly=false);
111
132 Rose::BinaryAnalysis::Address calculateSizes(size_t r32size, size_t r64size, const std::vector<size_t> &optsizes,
133 size_t *entsize, size_t *required, size_t *optional, size_t *entcount) const;
134
135 virtual void finishParsing();
136
154 calculateSizes(size_t *entsize, size_t *required, size_t *optional, size_t *entcount) const;
155
156 virtual bool reallocate() override;
157
159 virtual void dump(FILE*, const char *prefix, ssize_t idx) const override;
160
162 void allocateNameToStorage(SgAsmElfStringSection*);
163
167 SgAsmElfFileHeader *get_elfHeader() const;
168
170 // Deprecated 2023-11
172public:
173 SgAsmElfSection* get_linked_section() const ROSE_DEPRECATED("use get_linkedSection");
174 virtual void set_linked_section(SgAsmElfSection*) ROSE_DEPRECATED("use set_linkSection");
175 SgAsmElfSectionTableEntry* get_section_entry() const ROSE_DEPRECATED("use get_sectionEntry");
176 void set_section_entry(SgAsmElfSectionTableEntry*) ROSE_DEPRECATED("use set_sectionEntry");
177 SgAsmElfSegmentTableEntry* get_segment_entry() const ROSE_DEPRECATED("use get_segmentEntry");
178 void set_segment_entry(SgAsmElfSegmentTableEntry*) ROSE_DEPRECATED("use set_segmentEntry");
179 SgAsmElfSection *init_from_section_table(SgAsmElfSectionTableEntry*, SgAsmElfStringSection*, int)
180 ROSE_DEPRECATED("use initFromSectionTable");
181 SgAsmElfSection *init_from_segment_table(SgAsmElfSegmentTableEntry*, bool mmap_only=false)
182 ROSE_DEPRECATED("use initFromSegmentTable");
183 Rose::BinaryAnalysis::Address
184 calculate_sizes(size_t, size_t, const std::vector<size_t>&, size_t*, size_t*, size_t*, size_t*) const
185 ROSE_DEPRECATED("use calculateSizes");
186 virtual void finish_parsing() ROSE_DEPRECATED("use finishParsing");
187 virtual Rose::BinaryAnalysis::Address
188 calculate_sizes(size_t*, size_t*, size_t*, size_t*) const ROSE_DEPRECATED("use calculateSizes");
189 void allocate_name_to_storage(SgAsmElfStringSection*) ROSE_DEPRECATED("use allocateNameToStorage");
190 SgAsmElfFileHeader *get_elf_header() const ROSE_DEPRECATED("use get_elfHeader");
191public:
193 virtual ~SgAsmElfSection();
194
195public:
198
199protected:
206 void initializeProperties();
207
208
209// End of memberFunctionString
210// Start of memberFunctionString
211/* #line 1 "/workspace/src/ROSETTA/Grammar/Common.code" */
212
213// *** COMMON CODE SECTION BEGINS HERE ***
214
215 public:
216
217 // DQ (3/25/3006): I put this back in because it had the logic for where the copy function required
218 // and not required which is required to match the other aspects of the copy mechanism code generation.
219 // Specifically it is a problem to declare the copy function everywhere because it is not implemented
220 // for the SgSymbol IR nodes. I'm not clear why it is not implemented for these IR nodes.
221 /* \brief Copies AST (whole subtree, depending on the SgCopyHelp class */
222 // virtual SgNode* copy ( const SgCopyHelp & help) const;
223
225 virtual std::string class_name() const override;
226
228 virtual VariantT variantT() const override; // MS: new variant used in tree traversal
229
231 // King84 (2010.08.16): Moved this to an enum to save space, since it's only used at compiler-time anyway.
232 // static const VariantT static_variant = V_SgAsmElfSection;
233 enum { static_variant = V_SgAsmElfSection };
234
235 /* the generated cast function */
237 ROSE_DLL_API friend SgAsmElfSection* isSgAsmElfSection( SgNode * s );
238
240 ROSE_DLL_API friend const SgAsmElfSection* isSgAsmElfSection( const SgNode * s );
241
242 // ******************************************
243 // * Memory Pool / New / Delete
244 // ******************************************
245
246 public:
248 static const unsigned pool_size; //
250 static std::vector<unsigned char *> pools; //
252 static SgAsmElfSection * next_node; //
253
255 static unsigned long initializeStorageClassArray(SgAsmElfSectionStorageClass *); //
256
258 static void clearMemoryPool(); //
259 static void deleteMemoryPool(); //
260
262 static void extendMemoryPoolForFileIO(); //
263
265 static SgAsmElfSection * getPointerFromGlobalIndex(unsigned long); //
267 static SgAsmElfSection * getPointerFromGlobalIndex(AstSpecificDataManagingClass *, unsigned long); //
268
270 static unsigned long getNumberOfValidNodesAndSetGlobalIndexInFreepointer(unsigned long); //
272 static void resetValidFreepointers(); //
274 static unsigned long getNumberOfLastValidPointer(); //
275
276
277#if defined(INLINE_FUNCTIONS)
279 inline void *operator new (size_t size);
280#else
282 void *operator new (size_t size);
283#endif
285 void operator delete (void* pointer, size_t size);
286
287 // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
288 void operator delete (void* pointer)
289 {
290 // This is the generated delete operator...
291 SgAsmElfSection::operator delete (pointer,sizeof(SgAsmElfSection));
292 }
293
295 static size_t numberOfNodes();
296
298 static size_t memoryUsage();
299
300 // End of scope which started in IR nodes specific code
301 /* */
302
303 /* name Internal Functions
304 \brief Internal functions ... incomplete-documentation
305
306 These functions have been made public as part of the design, but they are suggested for internal use
307 or by particularly knowledgeable users for specialized tools or applications.
308
309 \internal We could not make these private because they are required by user for special purposes. And
310 it would be unwieldy to have many of the internal classes in ROSE be explicitly defined as friends.
311
312 */
313
314 // MS: 02/12/02 container of pointers to AST successor nodes used in the traversal
315 // overridden in every class by *generated* implementation
317 virtual std::vector<SgNode*> get_traversalSuccessorContainer() const override;
318 // MS: 06/28/02 container of names of variables or container indices
319 // used used in the traversal to access AST successor nodes
320 // overridden in every class by *generated* implementation
323 virtual std::vector<std::string> get_traversalSuccessorNamesContainer() const override;
324
325 // GB (09/25/2007): Functions for index-based access to traversal successors; these are hopefully a lot faster
326 // than all the vector copies. The implementation for these functions is generated for each class.
328 virtual size_t get_numberOfTraversalSuccessors() const override;
330 virtual SgNode *get_traversalSuccessorByIndex(size_t idx) const override;
332 virtual size_t get_childIndex(SgNode *child) const override;
333
334#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
335 // MS: 08/16/2002 method for generating RTI information
337 virtual RTIReturnType roseRTI() override;
338#endif
339 /* */
340
341
342
343 /* name Deprecated Functions
344 \brief Deprecated functions ... incomplete-documentation
345
346 These functions have been deprecated from use.
347 */
348 /* */
349
351 virtual const char* sage_class_name() const override ROSE_DEPRECATED_FUNCTION;
352
353 // JJW (10/16/2008): Changed to a single function in Node.code, and put
354 // getVariant() in #if 0 block to prevent confusing Doxygen
355#if 0
357 virtual int variant() const ROSE_DEPRECATED_FUNCTION;
359 // virtual int getVariant() const ROSE_DEPRECATED_FUNCTION;
360#endif
361 /* */
362
363
364
365
366 public:
367 /* name Traversal Support Functions
368 \brief Traversal support functions ... incomplete-documentation
369
370 These functions have been made public as part of the design, but they are suggested for internal use
371 or by particularly knowledgable users for specialized tools or applications.
372 */
373 /* */
374
375 // DQ (11/26/2005): Support for visitor pattern mechanims
376 // (inferior to ROSE traversal mechanism, experimental).
380
381 /* DXN (08/09/2010): support for the classic visitor pattern done in GoF */
383 virtual void accept (ROSE_VisitorPattern & visitor) override;
384
385 // DQ (12/26/2005): Support for traversal based on the memory pool
388 static void traverseMemoryPoolNodes(ROSE_VisitTraversal & visit);
389
393
394 // DQ (2/9/2006): Added to support traversal over single representative of each IR node
395 // This traversal helps support internal tools that call static member functions.
396 // note: this function operates on the memory pools.
399 static void visitRepresentativeNode (ROSE_VisitTraversal & visit);
400 /* */
401
402 public:
403 /* NodeId support functions */
405 static SgNode* getNodeByNodeId(VariantT variantT, size_t poolIdx, size_t itemIdx);
408 static SgAsmElfSection* getNodeByNodeIdInternal(size_t poolIdx, size_t itemIdx);
411 static std::string getNodeIdString(SgAsmElfSection* sgnode);
412 static std::string getNodeIdStringInternal(SgAsmElfSection* sgnode);
413
414 public:
415 /* name Memory Allocation Functions
416 \brief Memory allocations functions ... incomplete-documentation
417
418 These functions have been made public as part of the design, but they are suggested for internal use
419 or by particularly knowledgable users for specialized tools or applications.
420 */
421 /* */
422
433 virtual bool isInMemoryPool() override;
434
445 virtual void checkDataMemberPointersIfInMemoryPool() override;
446
447 // DQ (4/30/2006): Modified to be a const function.
462 virtual std::vector<std::pair<SgNode*,std::string> > returnDataMemberPointers() const override;
463
474
486 virtual long getChildIndex( SgNode* childNode ) const override;
487
488 // DQ (9/2/2015): Since this function is generated by ROSETTA, we can't define the
489 // comment here (changed to be a C style comment and not be a doxygen comment).
490 /* \brief Constructor for use by AST File I/O Mechanism
491
492 This constructor permits the IR node to be rebuilt from the contiguously arranged data in memory
493 which obtained via fast binary file I/O from disk.
494 */
495 // SgAsmElfSection( SgAsmElfSectionStorageClass& source );
496
497
498
499
500
501 // JH (10/24/2005): methods added to support the ast file IO
502 private:
503
504 /* name AST Memory Allocation Support Functions
505 \brief Memory allocations support....
506
507 These functions handle the low leve support of the memory allocation scheme which permits IR nodes to be allocated
508 in large contiguous blocks to reduce memory fragmentation, improve performance, support specialized access (AST traversals),
509 and support the AST File I/O Mechanism.
510 */
511 /* */
512
513 /* JH (10/24/2005): Two typedefs. The TestType notes the type every pointer is cast to before
514 we compare them. Since I had several problems with this, I decided to make a typdef to ensure
515 that I use the same type everywhere, if any changes are made. THe second one declares the type
516 (actually unsigned long) where teh pointer address gets converted to. On 64 bit platforms this
517 might got changed, but unfortunatly, the return types are still unsigned longs. There exists
518 a correspinding one in the AST_FILE_IO class!
519 */
520 // DQ (9/2/2015): This typedef is no longer used, we can't define the
521 // comment here (changed to be a C style comment and not be a doxygen comment).
522 /* \brief Typedef used for low level memory access.
523 */
524 // typedef unsigned char* TestType;
525
526 // DQ (9/2/2015): This typedef is no longer used, we can't define the
527 // comment here (changed to be a C style comment and not be a doxygen comment).
528 /* \brief Typedef used to hold memory addresses as values.
529 */
530 // typedef unsigned long AddressType;
531
532
533
534 // necessary, to have direct access to the p_freepointer and the private methods !
536 friend class AST_FILE_IO;
537
539 friend class SgAsmElfSectionStorageClass;
540
542 friend class AstSpecificDataManagingClass;
543
545 friend class AstSpecificDataManagingClassStorageClass;
546 public:
548 SgAsmElfSection( const SgAsmElfSectionStorageClass& source );
549
550 // private: // JJW hack
551 /*
552 name AST Memory Allocation Support Variables
553 Memory allocations support variables
554
555 These variables handle the low level support of the memory allocation scheme which permits IR nodes to be allocated
556 in large contiguous blocks to reduce memory fragmentation, improve performance, support specialized access (AST traversals),
557 and support the AST File I/O Mechanism.
558 */
559 /* */
560
561 public:
562
563 // DQ (11/21/2009): Added function to add new Regular Expression attributes and return pointer
564 // to current node (so that it will work cleanly with build functions to specify patterns).
565 // virtual SgNode* addRegExpAttribute();
572
573#ifndef _MSC_VER
574// Rasmussen (04/17/2019): Support for ATerms has been deprecated as it is no longer needed
575// and likely never fully implemented nor tested. Files remain in the src tree but are no
576// longer built.
577#define BUILD_ATERM_SUPPORT 0
578 #if BUILD_ATERM_SUPPORT
579 #ifdef ROSE_USE_ROSE_ATERM_SUPPORT
580 // DQ (10/4/2014): Adding ATerm support to ROSE.
590 // Rasmussen (1/7/2019): Added override to kill warning messages of overridden virtual function
591 virtual ATerm generate_ATerm() override;
592
594 virtual void generate_ATerm_Annotation(ATerm & term) override;
595 #endif
596 #endif // BUILD_ATERM_SUPPORT
597#endif
598 // These can't be virtual functions since we don't yet know what IR node to build (until we have read the aterm).
599 // virtual generate_AST(ATerm & term);
600 // virtual void read_ATerm_Annotation(ATerm & term);
601
602// *** COMMON CODE SECTION ENDS HERE ***
603
604
605// End of memberFunctionString
606// Start of memberFunctionString
607/* #line 710 "/workspace/src/ROSETTA/Grammar/Node.code" */
608
609 // the generated cast function
610 // friend ROSE_DLL_API SgAsmElfSection* isSgAsmElfSection ( SgNode* s );
611
612 typedef SgAsmGenericSection base_node_type;
613
614
615// End of memberFunctionString
616
617
618
619
620 protected:
621// Start of memberFunctionString
622SgAsmElfSection* p_linkedSection;
623
624// End of memberFunctionString
625// Start of memberFunctionString
626SgAsmElfSectionTableEntry* p_sectionEntry;
627
628// End of memberFunctionString
629// Start of memberFunctionString
630SgAsmElfSegmentTableEntry* p_segmentEntry;
631
632// End of memberFunctionString
633
635 friend struct Rose::Traits::generated::describe_field_t<SgAsmElfSection, SgAsmElfSection*,&SgAsmElfSection::p_linkedSection>;
636 friend struct Rose::Traits::generated::describe_field_t<SgAsmElfSection, SgAsmElfSectionTableEntry*,&SgAsmElfSection::p_sectionEntry>;
637 friend struct Rose::Traits::generated::describe_field_t<SgAsmElfSection, SgAsmElfSegmentTableEntry*,&SgAsmElfSection::p_segmentEntry>;
638
639/* #line 21 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro" */
640
641
642 };
643#endif
644
645// postdeclarations for SgAsmElfSection
646
647/* #line 648 "../../../src/frontend/SageIII//SgAsmElfSection.h" */
648
649/* #line 27 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro after subst for $POSTDECLARATIONS" */
650
651/* #line 28 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro" */
652
653
654/* #line 655 "../../../src/frontend/SageIII//SgAsmElfSection.h" */
655
656#endif // ROSE_SgAsmElfSection_H
657
Class holding static data and functions supporting File I/O.
Definition AST_FILE_IO.h:19
Attribute containing a regex expression as a string.
Represents the file header of an ELF binary container.
Represents one entry in an ELF section table.
Base class for ELF file sections.
Represents one entry of a segment table.
ELF string table section.
Base class for container file headers.
Contiguous region of a file.
virtual void dump(FILE *, const char *prefix, ssize_t idx) const
Print some debugging info.
virtual bool reallocate()
Called prior to unparse to make things consistent.
Supporting class from copy mechanism within ROSE.
Definition sageCopy.h:26
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 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
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.
std::uint64_t Address
Address.
Definition Address.h:11
void serialize(std::ostream &output, Graph &graph)
Serialize a graph into a stream of bytes.
The ROSE library.
void copy(const Word *src, const BitRange &srcRange, Word *dst, const BitRange &dstRange)
Copy some bits.