Martin Storsjo | e84a0b5 | 2018-12-19 07:24:38 +0000 | [diff] [blame^] | 1 | //===- COFFObjcopy.cpp ----------------------------------------------------===// |
| 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 | #include "COFFObjcopy.h" |
| 11 | #include "Buffer.h" |
| 12 | #include "CopyConfig.h" |
| 13 | #include "Object.h" |
| 14 | #include "Reader.h" |
| 15 | #include "Writer.h" |
| 16 | #include "llvm-objcopy.h" |
| 17 | |
| 18 | #include "llvm/Object/Binary.h" |
| 19 | #include "llvm/Object/COFF.h" |
| 20 | #include <cassert> |
| 21 | |
| 22 | namespace llvm { |
| 23 | namespace objcopy { |
| 24 | namespace coff { |
| 25 | |
| 26 | using namespace object; |
| 27 | using namespace COFF; |
| 28 | |
| 29 | void executeObjcopyOnBinary(const CopyConfig &Config, |
| 30 | object::COFFObjectFile &In, Buffer &Out) { |
| 31 | COFFReader Reader(In); |
| 32 | std::unique_ptr<Object> Obj = Reader.create(); |
| 33 | assert(Obj && "Unable to deserialize COFF object"); |
| 34 | COFFWriter Writer(*Obj, Out); |
| 35 | Writer.write(); |
| 36 | } |
| 37 | |
| 38 | } // end namespace coff |
| 39 | } // end namespace objcopy |
| 40 | } // end namespace llvm |