Home | History | Annotate | Download | only in Hexagon
      1 //===- HexagonPLT.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_HEXAGON_HEXAGONPLT_H
     10 #define TARGET_HEXAGON_HEXAGONPLT_H
     11 
     12 #include "HexagonGOT.h"
     13 #include "HexagonGOTPLT.h"
     14 #include <mcld/Target/GOT.h>
     15 #include <mcld/Target/PLT.h>
     16 #include <mcld/Support/MemoryRegion.h>
     17 
     18 namespace {
     19 
     20 const uint8_t hexagon_plt0[] = {
     21  0x00, 0x40, 0x00, 0x00,  // { immext (#0)
     22  0x1c, 0xc0, 0x49, 0x6a,  //   r28 = add (pc, ##GOT0@PCREL) } # address of GOT0
     23  0x0e, 0x42, 0x9c, 0xe2,  // { r14 -= add (r28, #16)  # offset of GOTn from GOTa
     24  0x4f, 0x40, 0x9c, 0x91,  //   r15 = memw (r28 + #8)  # object ID at GOT2
     25  0x3c, 0xc0, 0x9c, 0x91,  //   r28 = memw (r28 + #4) }# dynamic link at GOT1
     26  0x0e, 0x42, 0x0e, 0x8c,  // { r14 = asr (r14, #2)    # index of PLTn
     27  0x00, 0xc0, 0x9c, 0x52,  //   jumpr r28 }            # call dynamic linker
     28  0x00, 0x00, 0x00, 0x00,
     29  0x00, 0x00, 0x00, 0x00,
     30  0x00, 0x00, 0x00, 0x00,
     31  0x00, 0x00, 0x00, 0x00,
     32  0x00, 0x00, 0x00, 0x00
     33 };
     34 
     35 const uint8_t hexagon_plt1[] = {
     36   0x00, 0x40, 0x00, 0x00, // { immext (#0)
     37   0x0e, 0xc0, 0x49, 0x6a, //   r14 = add (pc, ##GOTn@PCREL) } # address of GOTn
     38   0x1c, 0xc0, 0x8e, 0x91, // r28 = memw (r14)                 # contents of GOTn
     39   0x00, 0xc0, 0x9c, 0x52  // jumpr r28                        # call it
     40 };
     41 
     42 } // anonymous namespace
     43 
     44 namespace mcld {
     45 
     46 class GOTEntry;
     47 class LinkerConfig;
     48 class HexagonPLT1;
     49 
     50 //===----------------------------------------------------------------------===//
     51 // HexagonPLT Entry
     52 //===----------------------------------------------------------------------===//
     53 class HexagonPLT0 : public PLT::Entry<sizeof(hexagon_plt0)>
     54 {
     55 public:
     56   HexagonPLT0(SectionData& pParent);
     57 };
     58 
     59 //===----------------------------------------------------------------------===//
     60 // HexagonPLT
     61 //===----------------------------------------------------------------------===//
     62 /** \class HexagonPLT
     63  *  \brief Hexagon Procedure Linkage Table
     64  */
     65 class HexagonPLT : public PLT
     66 {
     67 public:
     68   HexagonPLT(LDSection& pSection,
     69              HexagonGOTPLT& pGOTPLT,
     70              const LinkerConfig& pConfig);
     71   ~HexagonPLT();
     72 
     73   // finalizeSectionSize - set LDSection size
     74   void finalizeSectionSize();
     75 
     76   // hasPLT1 - return if this PLT has any PLT1 entry
     77   bool hasPLT1() const;
     78 
     79   HexagonPLT1* create();
     80 
     81   void applyPLT0();
     82 
     83   void applyPLT1();
     84 
     85   uint64_t emit(MemoryRegion& pRegion);
     86 
     87   PLTEntryBase* getPLT0() const;
     88 
     89 private:
     90   HexagonGOTPLT& m_GOTPLT;
     91 
     92   const uint8_t *m_PLT0;
     93   unsigned int m_PLT0Size;
     94 
     95   const LinkerConfig& m_Config;
     96 };
     97 
     98 class HexagonPLT1 : public PLT::Entry<sizeof(hexagon_plt1)>
     99 {
    100 public:
    101   HexagonPLT1(SectionData& pParent);
    102 };
    103 
    104 } // namespace of mcld
    105 
    106 #endif
    107 
    108