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