blob: f2b7f78a90822055efd1538dd7f551d189c577fe [file] [log] [blame]
Martin Storsjoe84a0b52018-12-19 07:24:38 +00001//===- Reader.h -------------------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef LLVM_TOOLS_OBJCOPY_COFF_READER_H
11#define LLVM_TOOLS_OBJCOPY_COFF_READER_H
12
13#include "Buffer.h"
14#include "llvm/BinaryFormat/COFF.h"
15#include "llvm/Object/COFF.h"
Martin Storsjo0a5d5b12018-12-30 20:35:43 +000016#include "llvm/Support/Error.h"
Martin Storsjoe84a0b52018-12-19 07:24:38 +000017
18namespace llvm {
19namespace objcopy {
20namespace coff {
21
Martin Storsjo2a632b642018-12-19 07:45:06 +000022struct Object;
Martin Storsjoe84a0b52018-12-19 07:24:38 +000023
24using object::COFFObjectFile;
25
26class Reader {
27public:
28 virtual ~Reader();
Martin Storsjo0a5d5b12018-12-30 20:35:43 +000029 virtual Expected<std::unique_ptr<Object>> create() const = 0;
Martin Storsjoe84a0b52018-12-19 07:24:38 +000030};
31
32class COFFReader : public Reader {
33 const COFFObjectFile &COFFObj;
34
Martin Storsjo0a5d5b12018-12-30 20:35:43 +000035 Error readExecutableHeaders(Object &Obj) const;
36 Error readSections(Object &Obj) const;
37 Error readSymbols(Object &Obj, bool IsBigObj) const;
Martin Storsjoe84a0b52018-12-19 07:24:38 +000038
39public:
40 explicit COFFReader(const COFFObjectFile &O) : COFFObj(O) {}
Martin Storsjo0a5d5b12018-12-30 20:35:43 +000041 Expected<std::unique_ptr<Object>> create() const override;
Martin Storsjoe84a0b52018-12-19 07:24:38 +000042};
43
44} // end namespace coff
45} // end namespace objcopy
46} // end namespace llvm
47
48#endif // LLVM_TOOLS_OBJCOPY_COFF_READER_H