1 //===- ARMPLT.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_ARMPLT_H_ 10 #define TARGET_ARM_ARMPLT_H_ 11 12 #include "mcld/Target/GOT.h" 13 #include "mcld/Target/PLT.h" 14 #include "mcld/Support/MemoryRegion.h" 15 16 const uint32_t arm_plt0[] = { 17 0xe52de004, // str lr, [sp, #-4]! 18 0xe59fe004, // ldr lr, [pc, #4] 19 0xe08fe00e, // add lr, pc, lr 20 0xe5bef008, // ldr pc, [lr, #8]! 21 0x00000000 // &GOT[0] - . 22 }; 23 24 const uint32_t arm_plt1[] = { 25 0xe28fc600, // add ip, pc, #0xNN00000 26 0xe28cca00, // add ip, ip, #0xNN000 27 0xe5bcf000 // ldr pc, [ip, #0xNNN]! 28 }; 29 30 namespace mcld { 31 32 class ARMGOT; 33 34 class ARMPLT0 : public PLT::Entry<sizeof(arm_plt0)> { 35 public: 36 ARMPLT0(SectionData& pParent); 37 }; 38 39 class ARMPLT1 : public PLT::Entry<sizeof(arm_plt1)> { 40 public: 41 ARMPLT1(SectionData& pParent); 42 }; 43 44 /** \class ARMPLT 45 * \brief ARM Procedure Linkage Table 46 */ 47 class ARMPLT : public PLT { 48 public: 49 ARMPLT(LDSection& pSection, ARMGOT& pGOTPLT); 50 ~ARMPLT(); 51 52 // finalizeSectionSize - set LDSection size 53 void finalizeSectionSize(); 54 55 // hasPLT1 - return if this plt section has any plt1 entry 56 bool hasPLT1() const; 57 58 ARMPLT1* create(); 59 60 ARMPLT0* getPLT0() const; 61 62 void applyPLT0(); 63 64 void applyPLT1(); 65 66 uint64_t emit(MemoryRegion& pRegion); 67 68 private: 69 ARMGOT& m_GOT; 70 }; 71 72 } // namespace mcld 73 74 #endif // TARGET_ARM_ARMPLT_H_ 75