X86PLT.h revision affc150dc44fab1911775a49636d0ce85333b634
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 14namespace mcld { 15 16class X86GOTPLT; 17class GOTEntry; 18class Output; 19 20class X86PLT0 : public PLTEntry { 21public: 22 X86PLT0(llvm::MCSectionData* pParent, unsigned int pSize); 23}; 24 25class X86PLT1 : public PLTEntry { 26public: 27 X86PLT1(llvm::MCSectionData* pParent, unsigned int pSize); 28}; 29 30/** \class X86PLT 31 * \brief X86 Procedure Linkage Table 32 */ 33class X86PLT : public PLT 34{ 35 typedef llvm::DenseMap<const ResolveInfo*, X86PLT1*> SymbolIndexType; 36 37public: 38 typedef llvm::MCSectionData::iterator iterator; 39 typedef llvm::MCSectionData::const_iterator const_iterator; 40 41public: 42 X86PLT(LDSection& pSection, 43 llvm::MCSectionData& pSectionData, 44 X86GOTPLT& pGOTPLT, 45 const Output& pOutput); 46 ~X86PLT(); 47 48// Override virtual function. 49public: 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 58public: 59 60 iterator begin() { return m_SectionData.begin(); } 61 62 const_iterator begin() const { return m_SectionData.begin(); } 63 64 iterator end() { return m_SectionData.end(); } 65 66 const_iterator end() const { return m_SectionData.end(); } 67 68 X86PLT0* getPLT0() const; 69 70 void applyPLT0(); 71 72 void applyPLT1(); 73 74private: 75 X86GOTPLT& m_GOTPLT; 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 const Output& m_Output; 89}; 90 91} // namespace of mcld 92 93#endif 94