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