Home | History | Annotate | Download | only in LD
      1 //===- ObjectReader.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_OBJECT_READER_H
     10 #define MCLD_OBJECT_READER_H
     11 #ifdef ENABLE_UNITTEST
     12 #include <gtest.h>
     13 #endif
     14 #include "mcld/LD/LDReader.h"
     15 #include <llvm/Support/system_error.h>
     16 #include <mcld/ADT/HashTable.h>
     17 #include <mcld/ADT/StringHash.h>
     18 #include <mcld/LD/ResolveInfo.h>
     19 
     20 namespace mcld {
     21 
     22 class Module;
     23 class Input;
     24 
     25 /** \class ObjectReader
     26  *  \brief ObjectReader provides an common interface for different object
     27  *  formats.
     28  */
     29 class ObjectReader : public LDReader
     30 {
     31 protected:
     32   typedef HashTable<ResolveInfo, StringHash<ELF> > GroupSignatureMap;
     33 
     34 protected:
     35   ObjectReader()
     36   { }
     37 
     38 public:
     39   virtual ~ObjectReader() { f_GroupSignatureMap.clear(); }
     40 
     41   virtual bool readHeader(Input& pFile) = 0;
     42 
     43   virtual bool readSymbols(Input& pFile) = 0;
     44 
     45   virtual bool readSections(Input& pFile) = 0;
     46 
     47   /// readRelocations - read relocation sections
     48   ///
     49   /// This function should be called after symbol resolution.
     50   virtual bool readRelocations(Input& pFile) = 0;
     51 
     52   GroupSignatureMap& signatures()
     53   { return f_GroupSignatureMap; }
     54 
     55   const GroupSignatureMap& signatures() const
     56   { return f_GroupSignatureMap; }
     57 
     58 protected:
     59   GroupSignatureMap f_GroupSignatureMap;
     60 
     61 };
     62 
     63 } // namespace of mcld
     64 
     65 #endif
     66 
     67