1//===- ARMGOT.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_ARM_GOT_H
10#define MCLD_ARM_GOT_H
11#ifdef ENABLE_UNITTEST
12#include <gtest.h>
13#endif
14
15#include <llvm/ADT/DenseMap.h>
16
17#include <mcld/Target/GOT.h>
18#include <mcld/LD/SectionData.h>
19
20namespace mcld
21{
22class LDSection;
23class MemoryRegion;
24
25/** \class ARMGOT
26 *  \brief ARM Global Offset Table.
27 */
28class ARMGOT : public GOT
29{
30  typedef llvm::DenseMap<const ResolveInfo*, GOTEntry*> SymbolIndexMapType;
31
32public:
33  typedef SectionData::iterator iterator;
34  typedef SectionData::const_iterator const_iterator;
35
36  enum {
37    ARMGOT0Num = 3
38  };
39
40public:
41  ARMGOT(LDSection &pSection, SectionData& pSectionData);
42
43  ~ARMGOT();
44
45  iterator begin();
46
47  const_iterator begin() const;
48
49  iterator end();
50
51  const_iterator end() const;
52
53  uint64_t emit(MemoryRegion& pRegion);
54// For GOT0
55public:
56  void applyGOT0(uint64_t pAddress);
57
58// For normal GOT
59public:
60  // Reserve normal GOT entries.
61  void reserveEntry(size_t pNum = 1);
62
63  GOTEntry* getEntry(const ResolveInfo& pSymbol, bool& pExist);
64
65// For GOTPLT
66public:
67  void reserveGOTPLTEntry();
68
69  void applyAllGOTPLT(uint64_t pPLTBase);
70
71  GOTEntry*& lookupGOTPLTMap(const ResolveInfo& pSymbol);
72
73  iterator getNextGOTPLTEntry();
74
75  iterator getGOTPLTBegin();
76
77  const iterator getGOTPLTEnd();
78
79private:
80  // For normal GOT entries
81  iterator m_NormalGOTIterator;
82  SymbolIndexMapType m_NormalGOTMap;
83
84  // For GOTPLT entries
85  iterator m_GOTPLTIterator;
86  SymbolIndexMapType m_GOTPLTMap;
87
88  iterator m_GOTPLTBegin;
89  iterator m_GOTPLTEnd;
90};
91
92} // namespace of mcld
93
94#endif
95
96