ObjectReader.h revision a790f0a8f3175183bea088389b3e4ae41813e192
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
16namespace mcld {
17
18class Module;
19class Input;
20
21/** \class ObjectReader
22 *  \brief ObjectReader provides an common interface for different object
23 *  formats.
24 */
25class ObjectReader : public LDReader
26{
27protected:
28  typedef HashTable<ResolveInfo, hash::StringHash<hash::DJB> > GroupSignatureMap;
29
30protected:
31  ObjectReader()
32  { }
33
34public:
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
48  GroupSignatureMap& signatures()
49  { return f_GroupSignatureMap; }
50
51  const GroupSignatureMap& signatures() const
52  { return f_GroupSignatureMap; }
53
54protected:
55  GroupSignatureMap f_GroupSignatureMap;
56
57};
58
59} // namespace of mcld
60
61#endif
62
63