RelocationFactory.h revision 533eae20118036f425f27bf0536ef0ccbb090b65
1//===- Relocation.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_LD_RELOCATION_FACTORY_H
10#define MCLD_LD_RELOCATION_FACTORY_H
11#include <mcld/Config/Config.h>
12#include <mcld/Support/GCFactory.h>
13#include <mcld/Fragment/Relocation.h>
14
15namespace mcld {
16
17class FragmentRef;
18class LinkerConfig;
19
20/** \class RelocationFactory
21 *  \brief RelocationFactory provides the interface for generating target
22 *  relocation
23 *
24 */
25class RelocationFactory : public GCFactory<Relocation, MCLD_RELOCATIONS_PER_INPUT>
26{
27public:
28  typedef Relocation::Type Type;
29  typedef Relocation::Address Address;
30  typedef Relocation::DWord DWord;
31  typedef Relocation::SWord SWord;
32
33public:
34  explicit RelocationFactory();
35
36  void setConfig(const LinkerConfig& pConfig);
37
38  // ----- production ----- //
39  /// produce - produce a relocation entry
40  /// @param pType - the type of the relocation entry
41  /// @param pFragRef - the place to apply the relocation
42  /// @param pAddend - the addend of the relocation entry
43  Relocation* produce(Type pType,
44                      FragmentRef& pFragRef,
45                      Address pAddend = 0);
46
47  /// produceEmptyEntry - produce an empty relocation which
48  /// occupied memory space but all contents set to zero.
49  Relocation* produceEmptyEntry();
50
51  void destroy(Relocation* pRelocation);
52
53private:
54  const LinkerConfig* m_pConfig;
55};
56
57} // namespace of mcld
58
59#endif
60
61