ARMGOT.h revision 22add6ff3426df1a85089fe6a6e1597ee3b6f300
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
19namespace mcld {
20
21class LDSection;
22class MemoryRegion;
23
24/** \class ARMGOT
25 *  \brief ARM Global Offset Table.
26 *
27 *  ARM GOT integrates traditional .got.plt and .got sections into one.
28 *  Traditional .got.plt is placed in the front part of GOT (PLTGOT), and
29 *  traditional .got is placed in the rear part of GOT (GOT).
30 *
31 *  ARM .got
32 *            +--------------+
33 *            |    GOT0      |
34 *            +--------------+
35 *            |    GOTPLT    |
36 *            +--------------+
37 *            |    GOT       |
38 *            +--------------+
39 *
40 */
41class ARMGOT : public GOT
42{
43public:
44  ARMGOT(LDSection &pSection);
45
46  ~ARMGOT();
47
48  void reserveGOTPLT();
49
50  void reserveGOT();
51
52  GOT::Entry* consumeGOT();
53
54  GOT::Entry* consumeGOTPLT();
55
56  uint64_t emit(MemoryRegion& pRegion);
57
58  void applyGOT0(uint64_t pAddress);
59
60  void applyGOTPLT(uint64_t pPLTBase);
61
62  bool hasGOT1() const;
63
64private:
65  struct Part {
66  public:
67    Part() : front(NULL), last_used(NULL) { }
68
69  public:
70    GOT::Entry* front;
71    GOT::Entry* last_used;
72  };
73
74private:
75  Part m_GOTPLT;
76  Part m_GOT;
77
78};
79
80} // namespace of mcld
81
82#endif
83
84