ObjectReader.h revision d8a752331fe7a30ce41835f139aa8a4c675ad07a
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
21namespace mcld
22{
23
24class Input;
25
26/** \class ObjectReader
27 *  \brief ObjectReader provides an common interface for different object
28 *  formats.
29 */
30class ObjectReader : public LDReader
31{
32protected:
33  typedef HashTable<ResolveInfo,
34                    StringHash<ELF>,
35                    ResolveInfoFactory> GroupSignatureMap;
36
37protected:
38  ObjectReader()
39  { }
40
41public:
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
55  GroupSignatureMap& signatures()
56  { return f_GroupSignatureMap; }
57
58  const GroupSignatureMap& signatures() const
59  { return f_GroupSignatureMap; }
60
61protected:
62  GroupSignatureMap f_GroupSignatureMap;
63
64};
65
66} // namespace of mcld
67
68#endif
69