Home | History | Annotate | Download | only in LD
      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 
     17 namespace mcld
     18 {
     19 
     20 class FragmentLinker;
     21 class TargetLDBackend;
     22 
     23 /** \class Relocator
     24  *  \brief Relocator provides the interface of performing relocations
     25  */
     26 class Relocator
     27 {
     28 public:
     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 
     35 public:
     36   enum Result {
     37     OK,
     38     BadReloc,
     39     Overflow,
     40     Unsupport,
     41     Unknown
     42   };
     43 
     44 public:
     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