summaryrefslogtreecommitdiff
path: root/lib/Target/ARM/ARMGOT.h
blob: 90f0f5382ecb41b0d29ff858c9bc197340499fa8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//===- ARMGOT.h -----------------------------------------------------------===//
//
//                     The MCLinker Project
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef MCLD_ARM_GOT_H
#define MCLD_ARM_GOT_H
#ifdef ENABLE_UNITTEST
#include <gtest.h>
#endif

#include <mcld/Target/GOT.h>

namespace mcld
{
class LDSection;
class MemoryRegion;

/** \class ARMGOT
 *  \brief ARM Global Offset Table.
 */
class ARMGOT : public GOT
{
  typedef llvm::DenseMap<const ResolveInfo*, GOTEntry*> SymbolIndexMapType;

public:
  typedef llvm::MCSectionData::iterator iterator;
  typedef llvm::MCSectionData::const_iterator const_iterator;

  enum {
    ARMGOT0Num = 3
  };

public:
  ARMGOT(LDSection &pSection, llvm::MCSectionData& pSectionData);

  ~ARMGOT();

  iterator begin();

  const_iterator begin() const;

  iterator end();

  const_iterator end() const;

  uint64_t emit(MemoryRegion& pRegion);
// For GOT0
public:
  void applyGOT0(uint64_t pAddress);

// For normal GOT
public:
  // Reserve normal GOT entries.
  void reserveEntry(size_t pNum = 1);

  GOTEntry* getEntry(const ResolveInfo& pSymbol, bool& pExist);

// For GOTPLT
public:
  void reserveGOTPLTEntry();

  void applyAllGOTPLT(uint64_t pPLTBase);

  GOTEntry*& lookupGOTPLTMap(const ResolveInfo& pSymbol);

  iterator getNextGOTPLTEntry();

  iterator getGOTPLTBegin();

  const iterator getGOTPLTEnd();

private:
  // For normal GOT entries
  iterator m_NormalGOTIterator;
  SymbolIndexMapType m_NormalGOTMap;

  // For GOTPLT entries
  iterator m_GOTPLTIterator;
  SymbolIndexMapType m_GOTPLTMap;

  iterator m_GOTPLTBegin;
  iterator m_GOTPLTEnd;
};

} // namespace of mcld

#endif