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