1 //===- GOT.h --------------------------------------------------------------===// 2 // 3 // The MCLinker Project 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 #ifndef MCLD_TARGET_GOT_H 10 #define MCLD_TARGET_GOT_H 11 12 #include <mcld/LD/LDSection.h> 13 #include <mcld/LD/SectionData.h> 14 #include <mcld/Fragment/TargetFragment.h> 15 16 namespace mcld { 17 18 class GOT; 19 class LDSection; 20 class ResolveInfo; 21 22 /** \class GOT 23 * \brief The Global Offset Table 24 */ 25 class GOT 26 { 27 protected: 28 GOT(LDSection& pSection); 29 30 public: 31 typedef SectionData::iterator iterator; 32 typedef SectionData::const_iterator const_iterator; 33 34 template<size_t SIZE> 35 class Entry : public TargetFragment 36 { 37 public: 38 enum { EntrySize = SIZE }; 39 40 public: Entry(uint64_t pValue,SectionData * pParent)41 Entry(uint64_t pValue, SectionData* pParent) 42 : TargetFragment(Fragment::Target, pParent), 43 f_Value(pValue) { 44 } 45 ~Entry()46 virtual ~Entry() {} 47 getValue()48 uint64_t getValue() const 49 { return f_Value; } 50 setValue(uint64_t pValue)51 void setValue(uint64_t pValue) 52 { f_Value = pValue; } 53 54 // Override pure virtual function size()55 size_t size() const 56 { return EntrySize; } 57 58 protected: 59 uint64_t f_Value; 60 }; 61 62 public: 63 virtual ~GOT(); 64 65 // ----- observers -----// addr()66 uint64_t addr() const { return m_Section.addr(); } size()67 uint64_t size() const { return m_Section.size(); } 68 begin()69 const_iterator begin() const { return m_SectionData->begin(); } begin()70 iterator begin() { return m_SectionData->begin(); } end()71 const_iterator end () const { return m_SectionData->end(); } end()72 iterator end () { return m_SectionData->end(); } 73 empty()74 bool empty() const 75 { return m_SectionData->empty(); } 76 77 // finalizeSectionSize - set LDSection size 78 virtual void finalizeSectionSize(); 79 80 protected: 81 LDSection& m_Section; 82 SectionData* m_SectionData; 83 }; 84 85 } // namespace of mcld 86 87 #endif 88 89