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