Martin Storsjo | e84a0b5 | 2018-12-19 07:24:38 +0000 | [diff] [blame] | 1 | //===- 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 Storsjo | 0a5d5b1 | 2018-12-30 20:35:43 +0000 | [diff] [blame] | 16 | #include "llvm/Support/Error.h" |
Martin Storsjo | e84a0b5 | 2018-12-19 07:24:38 +0000 | [diff] [blame] | 17 | |
| 18 | namespace llvm { |
| 19 | namespace objcopy { |
| 20 | namespace coff { |
| 21 | |
Martin Storsjo | 2a632b64 | 2018-12-19 07:45:06 +0000 | [diff] [blame] | 22 | struct Object; |
Martin Storsjo | e84a0b5 | 2018-12-19 07:24:38 +0000 | [diff] [blame] | 23 | |
| 24 | using object::COFFObjectFile; |
| 25 | |
| 26 | class Reader { |
| 27 | public: |
| 28 | virtual ~Reader(); |
Martin Storsjo | 0a5d5b1 | 2018-12-30 20:35:43 +0000 | [diff] [blame] | 29 | virtual Expected<std::unique_ptr<Object>> create() const = 0; |
Martin Storsjo | e84a0b5 | 2018-12-19 07:24:38 +0000 | [diff] [blame] | 30 | }; |
| 31 | |
| 32 | class COFFReader : public Reader { |
| 33 | const COFFObjectFile &COFFObj; |
| 34 | |
Martin Storsjo | 0a5d5b1 | 2018-12-30 20:35:43 +0000 | [diff] [blame] | 35 | Error readExecutableHeaders(Object &Obj) const; |
| 36 | Error readSections(Object &Obj) const; |
| 37 | Error readSymbols(Object &Obj, bool IsBigObj) const; |
Martin Storsjo | e84a0b5 | 2018-12-19 07:24:38 +0000 | [diff] [blame] | 38 | |
| 39 | public: |
| 40 | explicit COFFReader(const COFFObjectFile &O) : COFFObj(O) {} |
Martin Storsjo | 0a5d5b1 | 2018-12-30 20:35:43 +0000 | [diff] [blame] | 41 | Expected<std::unique_ptr<Object>> create() const override; |
Martin Storsjo | e84a0b5 | 2018-12-19 07:24:38 +0000 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | } // end namespace coff |
| 45 | } // end namespace objcopy |
| 46 | } // end namespace llvm |
| 47 | |
| 48 | #endif // LLVM_TOOLS_OBJCOPY_COFF_READER_H |