1 //===- COFFObjcopy.cpp ----------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "COFFObjcopy.h"
12 #include "CopyConfig.h"
16 #include "llvm-objcopy.h"
18 #include "llvm/Object/Binary.h"
19 #include "llvm/Object/COFF.h"
26 using namespace object
;
29 void executeObjcopyOnBinary(const CopyConfig
&Config
,
30 object::COFFObjectFile
&In
, Buffer
&Out
) {
31 COFFReader
Reader(In
);
32 Expected
<std::unique_ptr
<Object
>> ObjOrErr
= Reader
.create();
34 reportError(Config
.InputFilename
, ObjOrErr
.takeError());
35 Object
*Obj
= ObjOrErr
->get();
36 assert(Obj
&& "Unable to deserialize COFF object");
37 COFFWriter
Writer(*Obj
, Out
);
38 if (Error E
= Writer
.write())
39 reportError(Config
.OutputFilename
, std::move(E
));
42 } // end namespace coff
43 } // end namespace objcopy
44 } // end namespace llvm