ROSE 0.11.145.147
SgAsmElfSymbol.h
1
2#ifndef ROSE_SgAsmElfSymbol_H
3#define ROSE_SgAsmElfSymbol_H
4#include <RoseFirst.h>
5#include <Cxx_GrammarDeclarations.h>
6#include <SgAsmGenericSymbol.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 SgAsmElfSymbol
23
24/* #line 25 "../../../src/frontend/SageIII//SgAsmElfSymbol.h" */
25/* #line 19053 "/workspace/src/ROSETTA/src/binaryInstruction.C" */
26
27#include <Rose/BinaryAnalysis/ByteOrder.h>
28#include <sageContainer.h>
29
30
31/* #line 13 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro after subst for $PREDECLARATIONS" */
32
33/* #line 14 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro" */
34
35#if !defined(DOCUMENTATION)
36// Class Definition for SgAsmElfSymbol
37class ROSE_DLL_API SgAsmElfSymbol : public SgAsmGenericSymbol
38 {
39 public:
40
41
42/* #line 43 "../../../src/frontend/SageIII//SgAsmElfSymbol.h" */
43
44 virtual SgNode* copy ( SgCopyHelp& help) const override;
45// Start of memberFunctionString
46/* #line 19097 "/workspace/src/ROSETTA/src/binaryInstruction.C" */
47
48
49 //----------------------- Boost serialization for SgAsmElfSymbol -----------------------
50#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
51private:
52 friend class boost::serialization::access;
53
54 template<class S>
55 void serialize(S &s, const unsigned /*version*/) {
56 debugSerializationBegin("SgAsmElfSymbol");
57 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(SgAsmGenericSymbol);
58 s & BOOST_SERIALIZATION_NVP(p_st_info);
59 s & BOOST_SERIALIZATION_NVP(p_st_res1);
60 s & BOOST_SERIALIZATION_NVP(p_st_shndx);
61 s & BOOST_SERIALIZATION_NVP(p_st_size);
62 s & BOOST_SERIALIZATION_NVP(p_extra);
63 debugSerializationEnd("SgAsmElfSymbol");
64 }
65#endif // ROSE_HAVE_BOOST_SERIALIZATION_LIB
67 // Local types
69public:
70 enum ElfSymBinding {
71 STB_LOCAL=0,
72 STB_GLOBAL=1,
73 STB_WEAK=2
74 };
75
76 enum ElfSymType {
77 STT_NOTYPE = 0,
78 STT_OBJECT = 1,
79 STT_FUNC = 2,
80 STT_SECTION = 3,
81 STT_FILE = 4,
82 STT_COMMON = 5,
83 STT_TLS = 6,
84 STT_IFUNC = 10
85 };
86
87#ifdef _MSC_VER
88# pragma pack (1)
89#endif
90
92 struct Elf32SymbolEntry_disk {
93 uint32_t st_name;
94 uint32_t st_value;
95 uint32_t st_size;
96 unsigned char st_info;
97 unsigned char st_res1;
98 uint16_t st_shndx;
99 }
100#if !defined(SWIG) && !defined(_MSC_VER)
101 __attribute__((packed))
102#endif
103 ;
104
105 struct Elf64SymbolEntry_disk {
106 uint32_t st_name;
107 unsigned char st_info;
108 unsigned char st_res1;
109 uint16_t st_shndx;
110 uint64_t st_value;
111 uint64_t st_size;
112 }
113#if !defined(SWIG) && !defined(_MSC_VER)
114 __attribute__((packed))
115#endif
116 ;
117
118#ifdef _MSC_VER
119# pragma pack ()
120#endif
121
123 // Properties
125public:
126public:
132 unsigned char const& get_st_info() const;
133 void set_st_info(unsigned char const&);
136public:
142 unsigned char const& get_st_res1() const;
143 void set_st_res1(unsigned char const&);
146public:
152 unsigned const& get_st_shndx() const;
153 void set_st_shndx(unsigned const&);
156public:
162 rose_addr_t const& get_st_size() const;
163 void set_st_size(rose_addr_t const&);
166public:
172 SgUnsignedCharList const& get_extra() const;
173 SgUnsignedCharList& get_extra();
174 void set_extra(SgUnsignedCharList const&);
177 // Functions
179public:
182
187
192
205 virtual void dump(FILE *f, const char *prefix, ssize_t idx) const override;
206 void dump(FILE*, const char *prefix, ssize_t idx, SgAsmGenericSection*) const;
210 SgAsmElfSymbol::ElfSymBinding get_elfBinding() const;
211
213 SgAsmElfSymbol::ElfSymType get_elfType() const;
214
216 static std::string toString(SgAsmElfSymbol::ElfSymBinding);
217
219 static std::string toString(SgAsmElfSymbol::ElfSymType);
220
221private:
222 void parse_common(); // initialization common to all parse() methods
223
225 // Deprecated 2023-11
227public:
228 SgAsmElfSymbol::ElfSymBinding get_elf_binding() const ROSE_DEPRECATED("use get_elfBinding");
229 SgAsmElfSymbol::ElfSymType get_elf_type() const ROSE_DEPRECATED("use get_elfType");
230 static std::string to_string(SgAsmElfSymbol::ElfSymBinding) ROSE_DEPRECATED("use toString");
231 static std::string to_string(SgAsmElfSymbol::ElfSymType) ROSE_DEPRECATED("use toString");
232public:
234 virtual ~SgAsmElfSymbol();
235
236public:
239
240protected:
247 void initializeProperties();
248
249
250// End of memberFunctionString
251// Start of memberFunctionString
252/* #line 1 "/workspace/src/ROSETTA/Grammar/Common.code" */
253
254// *** COMMON CODE SECTION BEGINS HERE ***
255
256 public:
257
258 // DQ (3/25/3006): I put this back in because it had the logic for where the copy function required
259 // and not required which is required to match the other aspects of the copy mechanism code generation.
260 // Specifically it is a problem to declare the copy function everywhere because it is not implemented
261 // for the SgSymbol IR nodes. I'm not clear why it is not implemented for these IR nodes.
262 /* \brief Copies AST (whole subtree, depending on the SgCopyHelp class */
263 // virtual SgNode* copy ( const SgCopyHelp & help) const;
264
266 virtual std::string class_name() const override;
267
269 virtual VariantT variantT() const override; // MS: new variant used in tree traversal
270
272 // King84 (2010.08.16): Moved this to an enum to save space, since it's only used at compiler-time anyway.
273 // static const VariantT static_variant = V_SgAsmElfSymbol;
274 enum { static_variant = V_SgAsmElfSymbol };
275
276 /* the generated cast function */
278 ROSE_DLL_API friend SgAsmElfSymbol* isSgAsmElfSymbol( SgNode * s );
279
281 ROSE_DLL_API friend const SgAsmElfSymbol* isSgAsmElfSymbol( const SgNode * s );
282
283 // ******************************************
284 // * Memory Pool / New / Delete
285 // ******************************************
286
287 public:
289 static const unsigned pool_size; //
291 static std::vector<unsigned char *> pools; //
293 static SgAsmElfSymbol * next_node; //
294
296 static unsigned long initializeStorageClassArray(SgAsmElfSymbolStorageClass *); //
297
299 static void clearMemoryPool(); //
300 static void deleteMemoryPool(); //
301
303 static void extendMemoryPoolForFileIO(); //
304
306 static SgAsmElfSymbol * getPointerFromGlobalIndex(unsigned long); //
308 static SgAsmElfSymbol * getPointerFromGlobalIndex(AstSpecificDataManagingClass *, unsigned long); //
309
311 static unsigned long getNumberOfValidNodesAndSetGlobalIndexInFreepointer(unsigned long); //
313 static void resetValidFreepointers(); //
315 static unsigned long getNumberOfLastValidPointer(); //
316
317
318#if defined(INLINE_FUNCTIONS)
320 inline void *operator new (size_t size);
321#else
323 void *operator new (size_t size);
324#endif
326 void operator delete (void* pointer, size_t size);
327
328 // DQ (4/5/2007): This is not the correct operator that we want, but appears to be required to compile ROSE with ROSE.
329 void operator delete (void* pointer)
330 {
331 // This is the generated delete operator...
332 SgAsmElfSymbol::operator delete (pointer,sizeof(SgAsmElfSymbol));
333 }
334
336 static size_t numberOfNodes();
337
339 static size_t memoryUsage();
340
341 // End of scope which started in IR nodes specific code
342 /* */
343
344 /* name Internal Functions
345 \brief Internal functions ... incomplete-documentation
346
347 These functions have been made public as part of the design, but they are suggested for internal use
348 or by particularly knowledgeable users for specialized tools or applications.
349
350 \internal We could not make these private because they are required by user for special purposes. And
351 it would be unwieldy to have many of the internal classes in ROSE be explicitly defined as friends.
352
353 */
354
355 // MS: 02/12/02 container of pointers to AST successor nodes used in the traversal
356 // overridden in every class by *generated* implementation
358 virtual std::vector<SgNode*> get_traversalSuccessorContainer() override;
359 // MS: 06/28/02 container of names of variables or container indices
360 // used used in the traversal to access AST successor nodes
361 // overridden in every class by *generated* implementation
364 virtual std::vector<std::string> get_traversalSuccessorNamesContainer() override;
365
366 // GB (09/25/2007): Functions for index-based access to traversal successors; these are hopefully a lot faster
367 // than all the vector copies. The implementation for these functions is generated for each class.
369 virtual size_t get_numberOfTraversalSuccessors() override;
371 virtual SgNode *get_traversalSuccessorByIndex(size_t idx) override;
373 virtual size_t get_childIndex(SgNode *child) override;
374
375#ifndef ROSE_USE_INTERNAL_FRONTEND_DEVELOPMENT
376 // MS: 08/16/2002 method for generating RTI information
378 virtual RTIReturnType roseRTI() override;
379#endif
380 /* */
381
382
383
384 /* name Deprecated Functions
385 \brief Deprecated functions ... incomplete-documentation
386
387 These functions have been deprecated from use.
388 */
389 /* */
390
392 virtual const char* sage_class_name() const override ROSE_DEPRECATED_FUNCTION;
393
394 // JJW (10/16/2008): Changed to a single function in Node.code, and put
395 // getVariant() in #if 0 block to prevent confusing Doxygen
396#if 0
398 virtual int variant() const ROSE_DEPRECATED_FUNCTION;
400 // virtual int getVariant() const ROSE_DEPRECATED_FUNCTION;
401#endif
402 /* */
403
404
405
406
407 public:
408 /* name Traversal Support Functions
409 \brief Traversal support functions ... incomplete-documentation
410
411 These functions have been made public as part of the design, but they are suggested for internal use
412 or by particularly knowledgable users for specialized tools or applications.
413 */
414 /* */
415
416 // DQ (11/26/2005): Support for visitor pattern mechanims
417 // (inferior to ROSE traversal mechanism, experimental).
421
422 /* DXN (08/09/2010): support for the classic visitor pattern done in GoF */
424 virtual void accept (ROSE_VisitorPattern & visitor) override;
425
426 // DQ (12/26/2005): Support for traversal based on the memory pool
429 static void traverseMemoryPoolNodes(ROSE_VisitTraversal & visit);
430
434
435 // DQ (2/9/2006): Added to support traversal over single representative of each IR node
436 // This traversal helps support internal tools that call static member functions.
437 // note: this function operates on the memory pools.
440 static void visitRepresentativeNode (ROSE_VisitTraversal & visit);
441 /* */
442
443 public:
444 /* NodeId support functions */
446 static SgNode* getNodeByNodeId(VariantT variantT, size_t poolIdx, size_t itemIdx);
449 static SgAsmElfSymbol* getNodeByNodeIdInternal(size_t poolIdx, size_t itemIdx);
452 static std::string getNodeIdString(SgAsmElfSymbol* sgnode);
453 static std::string getNodeIdStringInternal(SgAsmElfSymbol* sgnode);
454
455 public:
456 /* name Memory Allocation Functions
457 \brief Memory allocations functions ... incomplete-documentation
458
459 These functions have been made public as part of the design, but they are suggested for internal use
460 or by particularly knowledgable users for specialized tools or applications.
461 */
462 /* */
463
474 virtual bool isInMemoryPool() override;
475
486 virtual void checkDataMemberPointersIfInMemoryPool() override;
487
488 // DQ (4/30/2006): Modified to be a const function.
503 virtual std::vector<std::pair<SgNode*,std::string> > returnDataMemberPointers() const override;
504
515
527 virtual long getChildIndex( SgNode* childNode ) const override;
528
529 // DQ (9/2/2015): Since this function is generated by ROSETTA, we can't define the
530 // comment here (changed to be a C style comment and not be a doxygen comment).
531 /* \brief Constructor for use by AST File I/O Mechanism
532
533 This constructor permits the IR node to be rebuilt from the contiguously arranged data in memory
534 which obtained via fast binary file I/O from disk.
535 */
536 // SgAsmElfSymbol( SgAsmElfSymbolStorageClass& source );
537
538
539
540
541
542 // JH (10/24/2005): methods added to support the ast file IO
543 private:
544
545 /* name AST Memory Allocation Support Functions
546 \brief Memory allocations support....
547
548 These functions handle the low leve support of the memory allocation scheme which permits IR nodes to be allocated
549 in large contiguous blocks to reduce memory fragmentation, improve performance, support specialized access (AST traversals),
550 and support the AST File I/O Mechanism.
551 */
552 /* */
553
554 /* JH (10/24/2005): Two typedefs. The TestType notes the type every pointer is cast to before
555 we compare them. Since I had several problems with this, I decided to make a typdef to ensure
556 that I use the same type everywhere, if any changes are made. THe second one declares the type
557 (actually unsigned long) where teh pointer address gets converted to. On 64 bit platforms this
558 might got changed, but unfortunatly, the return types are still unsigned longs. There exists
559 a correspinding one in the AST_FILE_IO class!
560 */
561 // DQ (9/2/2015): This typedef is no longer used, we can't define the
562 // comment here (changed to be a C style comment and not be a doxygen comment).
563 /* \brief Typedef used for low level memory access.
564 */
565 // typedef unsigned char* TestType;
566
567 // DQ (9/2/2015): This typedef is no longer used, we can't define the
568 // comment here (changed to be a C style comment and not be a doxygen comment).
569 /* \brief Typedef used to hold memory addresses as values.
570 */
571 // typedef unsigned long AddressType;
572
573
574
575 // necessary, to have direct access to the p_freepointer and the private methods !
577 friend class AST_FILE_IO;
578
580 friend class SgAsmElfSymbolStorageClass;
581
583 friend class AstSpecificDataManagingClass;
584
586 friend class AstSpecificDataManagingClassStorageClass;
587 public:
589 SgAsmElfSymbol( const SgAsmElfSymbolStorageClass& source );
590
591 // private: // JJW hack
592 /*
593 name AST Memory Allocation Support Variables
594 Memory allocations support variables
595
596 These variables handle the low level support of the memory allocation scheme which permits IR nodes to be allocated
597 in large contiguous blocks to reduce memory fragmentation, improve performance, support specialized access (AST traversals),
598 and support the AST File I/O Mechanism.
599 */
600 /* */
601
602 public:
603
604 // DQ (11/21/2009): Added function to add new Regular Expression attributes and return pointer
605 // to current node (so that it will work cleanly with build functions to specify patterns).
606 // virtual SgNode* addRegExpAttribute();
613
614#ifndef _MSC_VER
615// Rasmussen (04/17/2019): Support for ATerms has been deprecated as it is no longer needed
616// and likely never fully implemented nor tested. Files remain in the src tree but are no
617// longer built.
618#define BUILD_ATERM_SUPPORT 0
619 #if BUILD_ATERM_SUPPORT
620 #ifdef ROSE_USE_ROSE_ATERM_SUPPORT
621 // DQ (10/4/2014): Adding ATerm support to ROSE.
631 // Rasmussen (1/7/2019): Added override to kill warning messages of overridden virtual function
632 virtual ATerm generate_ATerm() override;
633
635 virtual void generate_ATerm_Annotation(ATerm & term) override;
636 #endif
637 #endif // BUILD_ATERM_SUPPORT
638#endif
639 // These can't be virtual functions since we don't yet know what IR node to build (until we have read the aterm).
640 // virtual generate_AST(ATerm & term);
641 // virtual void read_ATerm_Annotation(ATerm & term);
642
643// *** COMMON CODE SECTION ENDS HERE ***
644
645
646// End of memberFunctionString
647// Start of memberFunctionString
648/* #line 706 "/workspace/src/ROSETTA/Grammar/Node.code" */
649
650 // the generated cast function
651 // friend ROSE_DLL_API SgAsmElfSymbol* isSgAsmElfSymbol ( SgNode* s );
652
653 typedef SgAsmGenericSymbol base_node_type;
654
655
656// End of memberFunctionString
657
658
659
660
661
662
663 protected:
664// Start of memberFunctionString
665unsigned char p_st_info;
666
667// End of memberFunctionString
668// Start of memberFunctionString
669unsigned char p_st_res1;
670
671// End of memberFunctionString
672// Start of memberFunctionString
673unsigned p_st_shndx;
674
675// End of memberFunctionString
676// Start of memberFunctionString
677rose_addr_t p_st_size;
678
679// End of memberFunctionString
680// Start of memberFunctionString
681SgUnsignedCharList p_extra;
682
683// End of memberFunctionString
684
686 friend struct Rose::Traits::generated::describe_field_t<SgAsmElfSymbol, unsigned char,&SgAsmElfSymbol::p_st_info>;
687 friend struct Rose::Traits::generated::describe_field_t<SgAsmElfSymbol, unsigned char,&SgAsmElfSymbol::p_st_res1>;
688 friend struct Rose::Traits::generated::describe_field_t<SgAsmElfSymbol, unsigned,&SgAsmElfSymbol::p_st_shndx>;
689 friend struct Rose::Traits::generated::describe_field_t<SgAsmElfSymbol, rose_addr_t,&SgAsmElfSymbol::p_st_size>;
690 friend struct Rose::Traits::generated::describe_field_t<SgAsmElfSymbol, SgUnsignedCharList,&SgAsmElfSymbol::p_extra>;
691
692/* #line 21 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro" */
693
694
695 };
696#endif
697
698// postdeclarations for SgAsmElfSymbol
699
700/* #line 701 "../../../src/frontend/SageIII//SgAsmElfSymbol.h" */
701
702/* #line 27 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro after subst for $POSTDECLARATIONS" */
703
704/* #line 28 "/workspace/src/ROSETTA/Grammar/grammarClassDeclarationMacros.macro" */
705
706
707/* #line 708 "../../../src/frontend/SageIII//SgAsmElfSymbol.h" */
708
709#endif // ROSE_SgAsmElfSymbol_H
710
Class holding static data and functions supporting File I/O.
Definition AST_FILE_IO.h:19
Attribute containing a regex expression as a string.
ELF file section containing symbols.
Represents a single ELF symbol.
Contiguous region of a file.
virtual void dump(FILE *, const char *prefix, ssize_t idx) const
Print some debugging info.
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 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 parse(SgAsmGenericFile *)
Main function to parse DWARF information.
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.
const char * ElfSymType(int64_t)
Convert SgAsmElfSymbol::ElfSymType enum constant to a string.
const char * ElfSymBinding(int64_t)
Convert SgAsmElfSymbol::ElfSymBinding enum constant to a string.
32-bit format of an ELF symbol.