ObjectReader.h revision 87f34658dec9097d987d254a990ea7f311bfc95f
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#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
20namespace mcld {
21
22class Module;
23class Input;
24
25/** \class ObjectReader
26 *  \brief ObjectReader provides an common interface for different object
27 *  formats.
28 */
29class ObjectReader : public LDReader
30{
31protected:
32  typedef HashTable<ResolveInfo, hash::StringHash<hash::DJB> > GroupSignatureMap;
33
34protected:
35  ObjectReader()
36  { }
37
38public:
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
58protected:
59  GroupSignatureMap f_GroupSignatureMap;
60
61};
62
63} // namespace of mcld
64
65#endif
66
67