X86Relocator.h revision d0fbbb227051be16931a1aa9b4a7722ac039c698
1//===-  X86Relocator.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 X86_RELOCATION_FACTORY_H
10#define X86_RELOCATION_FACTORY_H
11#ifdef ENABLE_UNITTEST
12#include <gtest.h>
13#endif
14
15#include <mcld/LD/Relocator.h>
16#include <mcld/Target/GOT.h>
17#include <mcld/Target/PLT.h>
18#include <mcld/Target/SymbolEntryMap.h>
19#include "X86LDBackend.h"
20
21namespace mcld {
22
23class ResolveInfo;
24
25/** \class X86Relocator
26 *  \brief X86Relocator creates and destroys the X86 relocations.
27 *
28 */
29class X86Relocator : public Relocator
30{
31public:
32  typedef SymbolEntryMap<PLTEntryBase> SymPLTMap;
33  typedef SymbolEntryMap<X86GOTEntry> SymGOTMap;
34  typedef SymbolEntryMap<X86GOTPLTEntry> SymGOTPLTMap;
35
36public:
37  X86Relocator(X86GNULDBackend& pParent);
38  ~X86Relocator();
39
40  Result applyRelocation(Relocation& pRelocation);
41
42  X86GNULDBackend& getTarget()
43  { return m_Target; }
44
45  const X86GNULDBackend& getTarget() const
46  { return m_Target; }
47
48  const char* getName(Relocation::Type pType) const;
49
50  const SymPLTMap& getSymPLTMap() const { return m_SymPLTMap; }
51  SymPLTMap&       getSymPLTMap()       { return m_SymPLTMap; }
52
53  const SymGOTMap& getSymGOTMap() const { return m_SymGOTMap; }
54  SymGOTMap&       getSymGOTMap()       { return m_SymGOTMap; }
55
56  const SymGOTPLTMap& getSymGOTPLTMap() const { return m_SymGOTPLTMap; }
57  SymGOTPLTMap&       getSymGOTPLTMap()       { return m_SymGOTPLTMap; }
58
59private:
60  X86GNULDBackend& m_Target;
61  SymPLTMap m_SymPLTMap;
62  SymGOTMap m_SymGOTMap;
63  SymGOTPLTMap m_SymGOTPLTMap;
64};
65
66} // namespace of mcld
67
68#endif
69
70