• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <mcld/LD/ResolveInfoFactory.h>
20 
21 namespace mcld
22 {
23 
24 class Input;
25 
26 /** \class ObjectReader
27  *  \brief ObjectReader provides an common interface for different object
28  *  formats.
29  */
30 class ObjectReader : public LDReader
31 {
32 protected:
33   typedef HashTable<ResolveInfo,
34                     StringHash<ELF>,
35                     ResolveInfoFactory> GroupSignatureMap;
36 
37 protected:
ObjectReader()38   ObjectReader()
39   { }
40 
41 public:
~ObjectReader()42   virtual ~ObjectReader() { }
43 
44   virtual bool readObject(Input& pFile) = 0;
45 
46   virtual bool readSymbols(Input& pFile) = 0;
47 
48   virtual bool readSections(Input& pFile) = 0;
49 
50   /// readRelocations - read relocation sections
51   ///
52   /// This function should be called after symbol resolution.
53   virtual bool readRelocations(Input& pFile) = 0;
54 
signatures()55   GroupSignatureMap& signatures()
56   { return f_GroupSignatureMap; }
57 
signatures()58   const GroupSignatureMap& signatures() const
59   { return f_GroupSignatureMap; }
60 
61 protected:
62   GroupSignatureMap f_GroupSignatureMap;
63 
64 };
65 
66 } // namespace of mcld
67 
68 #endif
69 
70