X86PLT.h revision 22add6ff3426df1a85089fe6a6e1597ee3b6f300
1//===- X86PLT.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_TARGET_X86_PLT_H
10#define MCLD_TARGET_X86_PLT_H
11
12#include <mcld/Target/PLT.h>
13
14namespace mcld {
15
16class X86GOTPLT;
17class GOTEntry;
18class LinkerConfig;
19
20class X86PLT0 : public PLT::Entry
21{
22public:
23  X86PLT0(SectionData& pParent, unsigned int pSize);
24};
25
26class X86PLT1 : public PLT::Entry
27{
28public:
29  X86PLT1(SectionData& pParent, unsigned int pSize);
30};
31
32/** \class X86PLT
33 *  \brief X86 Procedure Linkage Table
34 */
35class X86PLT : public PLT
36{
37public:
38  X86PLT(LDSection& pSection,
39         X86GOTPLT& pGOTPLT,
40         const LinkerConfig& pConfig);
41  ~X86PLT();
42
43  // finalizeSectionSize - set LDSection size
44  void finalizeSectionSize();
45
46  // hasPLT1 - return if this PLT has any PLT1 entry
47  bool hasPLT1() const;
48
49  void reserveEntry(size_t pNum = 1) ;
50
51  PLT::Entry* consume();
52
53  void applyPLT0();
54
55  void applyPLT1();
56
57  unsigned int getPLT0Size() const { return m_PLT0Size; }
58  unsigned int getPLT1Size() const { return m_PLT1Size; }
59
60private:
61  X86PLT0* getPLT0() const;
62
63private:
64  X86GOTPLT& m_GOTPLT;
65
66  // the last consumed entry.
67  SectionData::iterator m_Last;
68
69  const uint8_t *m_PLT0;
70  const uint8_t *m_PLT1;
71  unsigned int m_PLT0Size;
72  unsigned int m_PLT1Size;
73
74  const LinkerConfig& m_Config;
75};
76
77} // namespace of mcld
78
79#endif
80