summaryrefslogtreecommitdiff
path: root/lib/Target/X86/X86GOTPLT.h
blob: 04bfad04a8c9cee39af69060cc5e37f30a147c89 (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
//===- X86GOTPLT.h --------------------------------------------------------===//
//
//                     The MCLinker Project
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef MCLD_X86_GOTPLT_H
#define MCLD_X86_GOTPLT_H
#ifdef ENABLE_UNITTEST
#include <gtest.h>
#endif

#include "mcld/Target/GOT.h"

namespace mcld
{
class LDSection;

/** \class X86GOTPLT
 *  \brief X86 .got.plt section.
 */

const unsigned int X86GOT0Num = 3;

class X86GOTPLT : public GOT
{
  typedef llvm::DenseMap<const ResolveInfo*, GOTEntry*> SymbolIndexMapType;

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

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

  ~X86GOTPLT();

  iterator begin();

  const_iterator begin() const;

  iterator end();

  const_iterator end() const;

// For GOT0
public:
  void applyGOT0(const uint64_t pAddress);

// For GOTPLT
public:
  void reserveGOTPLTEntry();

  void applyAllGOTPLT(const uint64_t pPLTBase);

  GOTEntry*& lookupGOTPLTMap(const ResolveInfo& pSymbol);

  iterator getNextGOTPLTEntry();

private:
  iterator m_GOTPLTIterator;
  SymbolIndexMapType m_GOTPLTMap;
};

} // namespace of mcld

#endif