Relocator.h revision 6f75755c9204b1d8817ae5a65a2f7e5af0ec3f70
1//===- Relocator.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_RELOCATOR_H
10#define MCLD_RELOCATOR_H
11#ifdef ENABLE_UNITTEST
12#include <gtest.h>
13#endif
14
15#include <mcld/Fragment/Relocation.h>
16
17namespace mcld
18{
19
20class FragmentLinker;
21class TargetLDBackend;
22
23/** \class Relocator
24 *  \brief Relocator provides the interface of performing relocations
25 */
26class Relocator
27{
28public:
29  typedef Relocation::Type    Type;
30  typedef Relocation::Address Address;
31  typedef Relocation::DWord   DWord;
32  typedef Relocation::SWord   SWord;
33  typedef Relocation::Size    Size;
34
35public:
36  enum Result {
37    OK,
38    BadReloc,
39    Overflow,
40    Unsupport,
41    Unknown
42  };
43
44public:
45  virtual ~Relocator() = 0;
46
47  /// apply - general apply function
48  virtual Result applyRelocation(Relocation& pRelocation) = 0;
49
50  // ------ observers -----//
51  virtual TargetLDBackend& getTarget() = 0;
52
53  virtual const TargetLDBackend& getTarget() const = 0;
54
55  /// getName - get the name of a relocation
56  virtual const char* getName(Type pType) const = 0;
57
58  /// getSize - get the size of a relocation in bit
59  virtual Size getSize(Type pType) const = 0;
60};
61
62} // namespace of mcld
63
64#endif
65
66