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