1//===- X86PLT.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_X86_PLT_H
10#define MCLD_TARGET_X86_PLT_H
11
12#include <llvm/ADT/DenseMap.h>
13
14#include <mcld/Target/PLT.h>
15#include <mcld/LD/SectionData.h>
16
17namespace mcld {
18
19class X86GOTPLT;
20class GOTEntry;
21class Output;
22
23class X86PLT0 : public PLTEntry
24{
25public:
26  X86PLT0(SectionData* pParent, unsigned int pSize);
27};
28
29class X86PLT1 : public PLTEntry
30{
31public:
32  X86PLT1(SectionData* pParent, unsigned int pSize);
33};
34
35/** \class X86PLT
36 *  \brief X86 Procedure Linkage Table
37 */
38class X86PLT : public PLT
39{
40  typedef llvm::DenseMap<const ResolveInfo*, X86PLT1*> SymbolIndexType;
41
42public:
43  typedef SectionData::iterator iterator;
44  typedef SectionData::const_iterator const_iterator;
45
46public:
47  X86PLT(LDSection& pSection,
48         SectionData& pSectionData,
49         X86GOTPLT& pGOTPLT,
50         const Output& pOutput);
51  ~X86PLT();
52
53// Override virtual function.
54public:
55
56  // reserveEntry is X86GOT friend function.
57  void reserveEntry(size_t pNum = 1) ;
58
59  PLTEntry* getPLTEntry(const ResolveInfo& pSymbol, bool& pExist) ;
60
61  GOTEntry* getGOTPLTEntry(const ResolveInfo& pSymbol, bool& pExist);
62
63public:
64
65  iterator begin() { return m_SectionData.begin(); }
66
67  const_iterator begin() const { return m_SectionData.begin(); }
68
69  iterator end() { return m_SectionData.end(); }
70
71  const_iterator end() const { return m_SectionData.end(); }
72
73  X86PLT0* getPLT0() const;
74
75  void applyPLT0();
76
77  void applyPLT1();
78
79private:
80  X86GOTPLT& m_GOTPLT;
81
82  // Used by getEntry() for mapping a ResolveInfo
83  // instance to a PLT1 Entry.
84  iterator m_PLTEntryIterator;
85
86  SymbolIndexType m_PLTEntryMap;
87
88  const uint8_t *m_PLT0;
89  const uint8_t *m_PLT1;
90  unsigned int m_PLT0Size;
91  unsigned int m_PLT1Size;
92
93  const Output& m_Output;
94};
95
96} // namespace of mcld
97
98#endif
99