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 TARGET_ARM_ARMGOT_H
10#define TARGET_ARM_ARMGOT_H
11
12#include <mcld/Target/GOT.h>
13#include <mcld/Support/MemoryRegion.h>
14#include <llvm/ADT/DenseMap.h>
15#include <vector>
16
17namespace mcld {
18
19class LDSection;
20
21/** \class ARMGOTEntry
22 *  \brief GOT Entry with size of 4 bytes
23 */
24class ARMGOTEntry : public GOT::Entry<4>
25{
26public:
27  ARMGOTEntry(uint64_t pContent, SectionData* pParent)
28   : GOT::Entry<4>(pContent, pParent)
29  {}
30};
31
32/** \class ARMGOT
33 *  \brief ARM Global Offset Table.
34 *
35 *  ARM GOT integrates traditional .got.plt and .got sections into one.
36 *  Traditional .got.plt is placed in the front part of GOT (PLTGOT), and
37 *  traditional .got is placed in the rear part of GOT (GOT).
38 *
39 *  ARM .got
40 *            +--------------+
41 *            |    GOT0      |
42 *            +--------------+
43 *            |    GOTPLT    |
44 *            +--------------+
45 *            |    GOT       |
46 *            +--------------+
47 *
48 */
49class ARMGOT : public GOT
50{
51public:
52  ARMGOT(LDSection &pSection);
53
54  ~ARMGOT();
55
56  ARMGOTEntry* createGOT();
57  ARMGOTEntry* createGOTPLT();
58
59  void finalizeSectionSize();
60
61  uint64_t emit(MemoryRegion& pRegion);
62
63  void applyGOT0(uint64_t pAddress);
64
65  void applyGOTPLT(uint64_t pPLTBase);
66
67  bool hasGOT1() const;
68
69private:
70  typedef std::vector<ARMGOTEntry*> EntryListType;
71  typedef EntryListType::iterator entry_iterator;
72  typedef EntryListType::const_iterator const_entry_iterator;
73
74private:
75  ARMGOTEntry* m_pGOTPLTFront;
76  ARMGOTEntry* m_pGOTFront;
77
78  /// m_GOTPLTEntries - a list of gotplt entries
79  EntryListType m_GOTPLT;
80
81  /// m_GOTEntris - a list of got entries
82  EntryListType m_GOT;
83};
84
85} // namespace of mcld
86
87#endif
88
89