summaryrefslogtreecommitdiff
path: root/include/mcld/LD/ELFObjectReader.h
blob: 635da851090d1221aecda1b52f2616238f217e26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//===- ELFObjectReader.h --------------------------------------------------===//
//
//                     The MCLinker Project
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef MCLD_ELF_OBJECT_READER_H
#define MCLD_ELF_OBJECT_READER_H
#ifdef ENABLE_UNITTEST
#include <gtest.h>
#endif

#include <mcld/LD/ObjectReader.h>
#include <llvm/Support/system_error.h>

namespace mcld
{

class Input;
class MCLinker;
class GNULDBackend;
class ELFReaderIF;

/** \lclass ELFObjectReader
 *  \brief ELFObjectReader reads target-independent parts of ELF object file
 */
class ELFObjectReader : public ObjectReader
{
public:
  ELFObjectReader(GNULDBackend& pBackend, MCLinker& pLinker);

  ~ELFObjectReader();

  // -----  observers  ----- //
  bool isMyFormat(Input &pFile) const;

  // -----  readers  ----- //
  bool readObject(Input& pFile);

  virtual bool readSections(Input& pFile);

  virtual bool readSymbols(Input& pFile);

  /// readRelocations - read relocation sections
  ///
  /// This function should be called after symbol resolution.
  virtual bool readRelocations(Input& pFile);

private:
  ELFReaderIF* m_pELFReader;
  MCLinker& m_Linker;
};

} // namespace of mcld

#endif