MipsGOT.h revision d8a752331fe7a30ce41835f139aa8a4c675ad07a
1//===- MipsGOT.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_MIPS_GOT_H
10#define MCLD_MIPS_GOT_H
11#ifdef ENABLE_UNITTEST
12#include <gtest.h>
13#endif
14
15#include <mcld/Target/GOT.h>
16
17namespace mcld
18{
19class LDSection;
20class MemoryRegion;
21
22/** \class MipsGOT
23 *  \brief Mips Global Offset Table.
24 */
25class MipsGOT : public GOT
26{
27private:
28  typedef llvm::DenseMap<const ResolveInfo*, GOTEntry*> SymbolIndexMapType;
29
30public:
31  typedef llvm::MCSectionData::iterator iterator;
32  typedef llvm::MCSectionData::const_iterator const_iterator;
33
34public:
35  MipsGOT(LDSection& pSection, llvm::MCSectionData& pSectionData);
36
37  iterator begin();
38  iterator end();
39
40  const_iterator begin() const;
41  const_iterator end() const;
42
43  uint64_t emit(MemoryRegion& pRegion);
44
45  void reserveLocalEntry();
46  void reserveGlobalEntry();
47
48  GOTEntry* getEntry(const ResolveInfo& pInfo, bool& pExist);
49
50  size_t getTotalNum() const;
51  size_t getLocalNum() const;
52
53private:
54  SymbolIndexMapType m_GeneralGOTMap;
55  iterator m_LocalGOTIterator;  // last local GOT entries
56  iterator m_GlobalGOTIterator; // last global GOT entries
57  size_t m_pLocalNum;
58
59private:
60  // Use reserveLocalEntry()/reserveGlobalEntry() instead of this routine.
61  void reserveEntry(size_t pNum = 1);
62};
63
64} // namespace of mcld
65
66#endif
67