Home | History | Annotate | Download | only in ARM
      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 MCLD_ARM_GOT_H
     10 #define MCLD_ARM_GOT_H
     11 #ifdef ENABLE_UNITTEST
     12 #include <gtest.h>
     13 #endif
     14 
     15 #include <mcld/Target/GOT.h>
     16 
     17 namespace mcld
     18 {
     19 class LDSection;
     20 class MemoryRegion;
     21 
     22 /** \class ARMGOT
     23  *  \brief ARM Global Offset Table.
     24  */
     25 class ARMGOT : public GOT
     26 {
     27   typedef llvm::DenseMap<const ResolveInfo*, GOTEntry*> SymbolIndexMapType;
     28 
     29 public:
     30   typedef llvm::MCSectionData::iterator iterator;
     31   typedef llvm::MCSectionData::const_iterator const_iterator;
     32 
     33   enum {
     34     ARMGOT0Num = 3
     35   };
     36 
     37 public:
     38   ARMGOT(LDSection &pSection, llvm::MCSectionData& pSectionData);
     39 
     40   ~ARMGOT();
     41 
     42   iterator begin();
     43 
     44   const_iterator begin() const;
     45 
     46   iterator end();
     47 
     48   const_iterator end() const;
     49 
     50   uint64_t emit(MemoryRegion& pRegion);
     51 // For GOT0
     52 public:
     53   void applyGOT0(uint64_t pAddress);
     54 
     55 // For normal GOT
     56 public:
     57   // Reserve normal GOT entries.
     58   void reserveEntry(size_t pNum = 1);
     59 
     60   GOTEntry* getEntry(const ResolveInfo& pSymbol, bool& pExist);
     61 
     62 // For GOTPLT
     63 public:
     64   void reserveGOTPLTEntry();
     65 
     66   void applyAllGOTPLT(uint64_t pPLTBase);
     67 
     68   GOTEntry*& lookupGOTPLTMap(const ResolveInfo& pSymbol);
     69 
     70   iterator getNextGOTPLTEntry();
     71 
     72   iterator getGOTPLTBegin();
     73 
     74   const iterator getGOTPLTEnd();
     75 
     76 private:
     77   // For normal GOT entries
     78   iterator m_NormalGOTIterator;
     79   SymbolIndexMapType m_NormalGOTMap;
     80 
     81   // For GOTPLT entries
     82   iterator m_GOTPLTIterator;
     83   SymbolIndexMapType m_GOTPLTMap;
     84 
     85   iterator m_GOTPLTBegin;
     86   iterator m_GOTPLTEnd;
     87 };
     88 
     89 } // namespace of mcld
     90 
     91 #endif
     92