Home | History | Annotate | Download | only in LD
      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 
     15 namespace mcld {
     16 
     17 class FragmentRef;
     18 class LinkerConfig;
     19 
     20 /** \class RelocationFactory
     21  *  \brief RelocationFactory provides the interface for generating target
     22  *  relocation
     23  *
     24  */
     25 class RelocationFactory : public GCFactory<Relocation, MCLD_RELOCATIONS_PER_INPUT>
     26 {
     27 public:
     28   typedef Relocation::Type Type;
     29   typedef Relocation::Address Address;
     30   typedef Relocation::DWord DWord;
     31   typedef Relocation::SWord SWord;
     32 
     33 public:
     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 
     53 private:
     54   const LinkerConfig* m_pConfig;
     55 };
     56 
     57 } // namespace of mcld
     58 
     59 #endif
     60 
     61