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