MipsGOT.h revision 22add6ff3426df1a85089fe6a6e1597ee3b6f300
1//===- MipsGOT.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_MIPS_GOT_H 10#define MCLD_MIPS_GOT_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 19namespace mcld 20{ 21class LDSection; 22class MemoryRegion; 23 24/** \class MipsGOT 25 * \brief Mips Global Offset Table. 26 */ 27class MipsGOT : public GOT 28{ 29public: 30 MipsGOT(LDSection& pSection); 31 32 uint64_t emit(MemoryRegion& pRegion); 33 34 void reserveLocalEntry(); 35 void reserveGlobalEntry(); 36 37 size_t getTotalNum() const; 38 size_t getLocalNum() const; 39 40 GOT::Entry* consumeLocal(); 41 GOT::Entry* consumeGlobal(); 42 43 void setLocal(const ResolveInfo* pInfo) { 44 m_GOTTypeMap[pInfo] = false; 45 } 46 47 void setGlobal(const ResolveInfo* pInfo) { 48 m_GOTTypeMap[pInfo] = true; 49 } 50 51 bool isLocal(const ResolveInfo* pInfo) { 52 return m_GOTTypeMap[pInfo] == false; 53 } 54 55 bool isGlobal(const ResolveInfo* pInfo) { 56 return m_GOTTypeMap[pInfo] == true; 57 } 58 59 /// hasGOT1 - return if this got section has any GOT1 entry 60 bool hasGOT1() const; 61 62private: 63 typedef llvm::DenseMap<const ResolveInfo*, bool> SymbolTypeMapType; 64 65private: 66 SymbolTypeMapType m_GOTTypeMap; 67 68 iterator m_LocalGOTIterator; // last local GOT entries 69 iterator m_GlobalGOTIterator; // last global GOT entries 70 size_t m_pLocalNum; 71}; 72 73} // namespace of mcld 74 75#endif 76 77