PLT.h revision cedee4b38f4786845183be7f5916dd520a170ae0
1//===- PLT.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_PROCEDURE_LINKAGE_TABLE_H 10#define MCLD_PROCEDURE_LINKAGE_TABLE_H 11#ifdef ENABLE_UNITTEST 12#include <gtest.h> 13#endif 14 15#include <llvm/ADT/ilist.h> 16 17#include <mcld/LD/LDSection.h> 18#include <mcld/LD/TargetFragment.h> 19 20namespace mcld 21{ 22 23class SectionData; 24class ResolveInfo; 25 26/** \class PLTEntry 27 */ 28class PLTEntry : public TargetFragment 29{ 30public: 31 PLTEntry(size_t pSize, SectionData* pParent); 32 virtual ~PLTEntry(); 33 34 size_t getEntrySize() const 35 { return m_EntrySize; } 36 37 void setContent(unsigned char* pContent) 38 { m_pContent = pContent; } 39 40 const unsigned char* getContent() const 41 { return m_pContent; } 42 43 //Used by llvm::cast<>. 44 static bool classof(const Fragment *O) 45 { return true; } 46 47 size_t getSize() const 48 { return m_EntrySize; } 49 50protected: 51 size_t m_EntrySize; 52 unsigned char* m_pContent; 53}; 54 55/** \class PLT 56 * \brief Procedure linkage table 57 */ 58class PLT 59{ 60public: 61 PLT(LDSection& pSection, SectionData& pSectionData); 62 virtual ~PLT(); 63 64 const LDSection& getSection() const 65 { return m_Section; } 66 67 const SectionData& getSectionData() const 68 { return m_SectionData; } 69 70public: 71 /// reserveEntry - reseve the number of pNum of empty entries 72 /// The empty entris are reserved for layout to adjust the fragment offset. 73 virtual void reserveEntry(size_t pNum = 1) = 0; 74 75 /// getPLTEntry - get an empty entry or an exitsted filled entry with pSymbol. 76 /// @param pSymbol - the target symbol 77 /// @param pExist - ture if the a filled entry with pSymbol existed, otherwise false. 78 virtual PLTEntry* getPLTEntry(const ResolveInfo& pSymbol, bool& pExist) = 0; 79 80protected: 81 LDSection& m_Section; 82 SectionData& m_SectionData; 83}; 84 85} // namespace of mcld 86 87#endif 88 89