Home | History | Annotate | Download | only in ARM
      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 MCLD_ARM_PLT_H
     10 #define MCLD_ARM_PLT_H
     11 
     12 #include <mcld/Target/GOT.h>
     13 #include <mcld/Target/PLT.h>
     14 
     15 namespace {
     16 
     17 const uint32_t arm_plt0[] = {
     18   0xe52de004, // str   lr, [sp, #-4]!
     19   0xe59fe004, // ldr   lr, [pc, #4]
     20   0xe08fe00e, // add   lr, pc, lr
     21   0xe5bef008, // ldr   pc, [lr, #8]!
     22   0x00000000, // &GOT[0] - .
     23 };
     24 
     25 const uint32_t arm_plt1[] = {
     26   0xe28fc600, // add   ip, pc, #0xNN00000
     27   0xe28cca00, // add   ip, ip, #0xNN000
     28   0xe5bcf000, // ldr   pc, [ip, #0xNNN]!
     29 };
     30 
     31 } // anonymous namespace
     32 
     33 namespace mcld {
     34 
     35 class ARMGOT;
     36 class MemoryRegion;
     37 
     38 class ARMPLT0 : public PLT::Entry<sizeof(arm_plt0)>
     39 {
     40 public:
     41   ARMPLT0(SectionData& pParent);
     42 };
     43 
     44 class ARMPLT1 : public PLT::Entry<sizeof(arm_plt1)>
     45 {
     46 public:
     47   ARMPLT1(SectionData& pParent);
     48 };
     49 
     50 /** \class ARMPLT
     51  *  \brief ARM Procedure Linkage Table
     52  */
     53 class ARMPLT : public PLT
     54 {
     55 public:
     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   void reserveEntry(size_t pNum = 1) ;
     66 
     67   ARMPLT1* consume();
     68 
     69   ARMPLT0* getPLT0() const;
     70 
     71   void applyPLT0();
     72 
     73   void applyPLT1();
     74 
     75   uint64_t emit(MemoryRegion& pRegion);
     76 
     77 private:
     78   ARMGOT& m_GOT;
     79 
     80   // Used by getEntry() for mapping a ResolveInfo instance to a PLT1 Entry.
     81   iterator m_PLTEntryIterator;
     82 };
     83 
     84 } // namespace of mcld
     85 
     86 #endif
     87 
     88