15460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//===- Relocation.h -------------------------------------------------------===//
25460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//
35460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//                     The MCLinker Project
45460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//
55460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao// This file is distributed under the University of Illinois Open Source
65460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao// License. See LICENSE.TXT for details.
75460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//
85460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao//===----------------------------------------------------------------------===//
937b74a387bb3993387029859c2d9d051c41c724eStephen Hines#ifndef MCLD_LD_RELOCATIONFACTORY_H_
1037b74a387bb3993387029859c2d9d051c41c724eStephen Hines#define MCLD_LD_RELOCATIONFACTORY_H_
1137b74a387bb3993387029859c2d9d051c41c724eStephen Hines#include "mcld/Config/Config.h"
1237b74a387bb3993387029859c2d9d051c41c724eStephen Hines#include "mcld/Fragment/Relocation.h"
1337b74a387bb3993387029859c2d9d051c41c724eStephen Hines#include "mcld/Support/GCFactory.h"
145460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
1522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaonamespace mcld {
165460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
17cedee4b38f4786845183be7f5916dd520a170ae0Shih-wei Liaoclass FragmentRef;
1822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoclass LinkerConfig;
195460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
205460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao/** \class RelocationFactory
215460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao *  \brief RelocationFactory provides the interface for generating target
225460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao *  relocation
235460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao *
245460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao */
2537b74a387bb3993387029859c2d9d051c41c724eStephen Hinesclass RelocationFactory
2637b74a387bb3993387029859c2d9d051c41c724eStephen Hines    : public GCFactory<Relocation, MCLD_RELOCATIONS_PER_INPUT> {
2737b74a387bb3993387029859c2d9d051c41c724eStephen Hines public:
285460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  typedef Relocation::Type Type;
295460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  typedef Relocation::Address Address;
305460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  typedef Relocation::DWord DWord;
3122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  typedef Relocation::SWord SWord;
325460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
3337b74a387bb3993387029859c2d9d051c41c724eStephen Hines public:
3437b74a387bb3993387029859c2d9d051c41c724eStephen Hines  RelocationFactory();
355460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
36d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao  void setConfig(const LinkerConfig& pConfig);
375460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
385460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  // ----- production ----- //
395460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// produce - produce a relocation entry
405460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// @param pType - the type of the relocation entry
415460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// @param pFragRef - the place to apply the relocation
425460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// @param pAddend - the addend of the relocation entry
4337b74a387bb3993387029859c2d9d051c41c724eStephen Hines  Relocation* produce(Type pType, FragmentRef& pFragRef, Address pAddend = 0);
445460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
455460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// produceEmptyEntry - produce an empty relocation which
465460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  /// occupied memory space but all contents set to zero.
475460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  Relocation* produceEmptyEntry();
485460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
495460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao  void destroy(Relocation* pRelocation);
505460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
5137b74a387bb3993387029859c2d9d051c41c724eStephen Hines private:
52d0fbbb227051be16931a1aa9b4a7722ac039c698Shih-wei Liao  const LinkerConfig* m_pConfig;
535460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao};
545460a1f25d9ddecb5c70667267d66d51af177a99Shih-wei Liao
5537b74a387bb3993387029859c2d9d051c41c724eStephen Hines}  // namespace mcld
56affc150dc44fab1911775a49636d0ce85333b634Zonr Chang
5737b74a387bb3993387029859c2d9d051c41c724eStephen Hines#endif  // MCLD_LD_RELOCATIONFACTORY_H_
58