GOT.h revision 533eae20118036f425f27bf0536ef0ccbb090b65
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
16namespace mcld {
17
18class GOT;
19class LDSection;
20class ResolveInfo;
21
22/** \class GOT
23 *  \brief The Global Offset Table
24 */
25class GOT
26{
27protected:
28  GOT(LDSection& pSection);
29
30public:
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:
41    Entry(uint64_t pValue, SectionData* pParent)
42      : TargetFragment(Fragment::Target, pParent),
43        f_Value(pValue) {
44    }
45
46    virtual ~Entry() {}
47
48    uint64_t getValue() const
49    { return f_Value; }
50
51    void setValue(uint64_t pValue)
52    { f_Value = pValue; }
53
54    // Override pure virtual function
55    size_t size() const
56    { return EntrySize; }
57
58  protected:
59    uint64_t f_Value;
60  };
61
62public:
63  virtual ~GOT();
64
65  // ----- observers -----//
66  uint64_t addr() const { return m_Section.addr(); }
67  uint64_t size() const { return m_Section.size(); }
68
69  const_iterator begin() const { return m_SectionData->begin(); }
70  iterator       begin()       { return m_SectionData->begin(); }
71  const_iterator end  () const { return m_SectionData->end();   }
72  iterator       end  ()       { return m_SectionData->end();   }
73
74  bool empty() const
75  { return m_SectionData->empty(); }
76
77  // finalizeSectionSize - set LDSection size
78  virtual void finalizeSectionSize();
79
80protected:
81  LDSection& m_Section;
82  SectionData* m_SectionData;
83};
84
85} // namespace of mcld
86
87#endif
88
89