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