ARMGOT.h revision 87f34658dec9097d987d254a990ea7f311bfc95f
1//===- ARMGOT.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_ARM_GOT_H 10#define MCLD_ARM_GOT_H 11#ifdef ENABLE_UNITTEST 12#include <gtest.h> 13#endif 14 15#include <mcld/Target/GOT.h> 16#include <mcld/Support/MemoryRegion.h> 17#include <llvm/ADT/DenseMap.h> 18#include <vector> 19 20namespace mcld { 21 22class LDSection; 23 24/** \class ARMGOTEntry 25 * \brief GOT Entry with size of 4 bytes 26 */ 27class ARMGOTEntry : public GOT::Entry<4> 28{ 29public: 30 ARMGOTEntry(uint64_t pContent, SectionData* pParent) 31 : GOT::Entry<4>(pContent, pParent) 32 {} 33}; 34 35/** \class ARMGOT 36 * \brief ARM Global Offset Table. 37 * 38 * ARM GOT integrates traditional .got.plt and .got sections into one. 39 * Traditional .got.plt is placed in the front part of GOT (PLTGOT), and 40 * traditional .got is placed in the rear part of GOT (GOT). 41 * 42 * ARM .got 43 * +--------------+ 44 * | GOT0 | 45 * +--------------+ 46 * | GOTPLT | 47 * +--------------+ 48 * | GOT | 49 * +--------------+ 50 * 51 */ 52class ARMGOT : public GOT 53{ 54public: 55 ARMGOT(LDSection &pSection); 56 57 ~ARMGOT(); 58 59 ARMGOTEntry* createGOT(); 60 ARMGOTEntry* createGOTPLT(); 61 62 void finalizeSectionSize(); 63 64 uint64_t emit(MemoryRegion& pRegion); 65 66 void applyGOT0(uint64_t pAddress); 67 68 void applyGOTPLT(uint64_t pPLTBase); 69 70 bool hasGOT1() const; 71 72private: 73 typedef std::vector<ARMGOTEntry*> EntryListType; 74 typedef EntryListType::iterator entry_iterator; 75 typedef EntryListType::const_iterator const_entry_iterator; 76 77private: 78 ARMGOTEntry* m_pGOTPLTFront; 79 ARMGOTEntry* m_pGOTFront; 80 81 /// m_GOTPLTEntries - a list of gotplt entries 82 EntryListType m_GOTPLT; 83 84 /// m_GOTEntris - a list of got entries 85 EntryListType m_GOT; 86}; 87 88} // namespace of mcld 89 90#endif 91 92