X86GOTPLT.h revision affc150dc44fab1911775a49636d0ce85333b634
1//===- X86GOTPLT.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_X86_GOTPLT_H
10#define MCLD_X86_GOTPLT_H
11#ifdef ENABLE_UNITTEST
12#include <gtest.h>
13#endif
14
15#include <mcld/Target/GOT.h>
16
17namespace mcld
18{
19class LDSection;
20
21/** \class X86GOTPLT
22 *  \brief X86 .got.plt section.
23 */
24
25const unsigned int X86GOTPLT0Num = 3;
26
27class X86GOTPLT : public GOT
28{
29  typedef llvm::DenseMap<const ResolveInfo*, GOTEntry*> SymbolIndexMapType;
30
31public:
32  typedef llvm::MCSectionData::iterator iterator;
33  typedef llvm::MCSectionData::const_iterator const_iterator;
34
35public:
36  X86GOTPLT(LDSection &pSection, llvm::MCSectionData& pSectionData);
37
38  ~X86GOTPLT();
39
40  iterator begin();
41
42  const_iterator begin() const;
43
44  iterator end();
45
46  const_iterator end() const;
47
48// For GOT0
49public:
50  void applyGOT0(uint64_t pAddress);
51
52// For GOTPLT
53public:
54  void reserveEntry(size_t pNum = 1);
55
56  GOTEntry* getEntry(const ResolveInfo& pSymbol, bool& pExist);
57
58  void applyAllGOTPLT(uint64_t pPLTBase,
59                      unsigned int pPLT0Size,
60                      unsigned int pPLT1Size);
61
62  GOTEntry*& lookupGOTPLTMap(const ResolveInfo& pSymbol);
63
64private:
65  iterator m_GOTPLTIterator;
66  SymbolIndexMapType m_GOTPLTMap;
67};
68
69} // namespace of mcld
70
71#endif
72
73