• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <llvm/ADT/DenseMap.h>
16 
17 #include <mcld/Target/GOT.h>
18 
19 namespace mcld {
20 
21 class LDSection;
22 class MemoryRegion;
23 
24 /** \class ARMGOTEntry
25  *  \brief GOT Entry with size of 4 bytes
26  */
27 class ARMGOTEntry : public GOT::Entry<4>
28 {
29 public:
ARMGOTEntry(uint64_t pContent,SectionData * pParent)30   ARMGOTEntry(uint64_t pContent, SectionData* pParent)
31    : GOT::Entry<4>(pContent, pParent)
32   {}
33 };
34 
35 /** \class ARMGOT
36  *  \brief ARM Global Offset Table.
37  *
38  *  ARM GOT integrates traditional .got.plt and .got sections into one.
39  *  Traditional .got.plt is placed in the front part of GOT (PLTGOT), and
40  *  traditional .got is placed in the rear part of GOT (GOT).
41  *
42  *  ARM .got
43  *            +--------------+
44  *            |    GOT0      |
45  *            +--------------+
46  *            |    GOTPLT    |
47  *            +--------------+
48  *            |    GOT       |
49  *            +--------------+
50  *
51  */
52 class ARMGOT : public GOT
53 {
54 public:
55   ARMGOT(LDSection &pSection);
56 
57   ~ARMGOT();
58 
59   void reserve(size_t pNum = 1);
60 
61   void reserveGOTPLT();
62 
63   void reserveGOT();
64 
65   ARMGOTEntry* consume();
66 
67   ARMGOTEntry* consumeGOT();
68 
69   ARMGOTEntry* consumeGOTPLT();
70 
71   uint64_t emit(MemoryRegion& pRegion);
72 
73   void applyGOT0(uint64_t pAddress);
74 
75   void applyGOTPLT(uint64_t pPLTBase);
76 
77   bool hasGOT1() const;
78 
79 private:
80   struct Part {
81   public:
PartPart82     Part() : front(NULL), last_used(NULL) { }
83 
84   public:
85     ARMGOTEntry* front;
86     ARMGOTEntry* last_used;
87   };
88 
89 private:
90   Part m_GOTPLT;
91   Part m_GOT;
92 
93   ARMGOTEntry* m_pLast; ///< the last consumed entry
94 };
95 
96 } // namespace of mcld
97 
98 #endif
99 
100