1 //===- XCOFFObjcopy.cpp ---------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ObjCopy/CommonConfig.h"
10 #include "llvm/ObjCopy/XCOFF/XCOFFConfig.h"
11 #include "llvm/ObjCopy/XCOFF/XCOFFObjcopy.h"
12 #include "llvm/Support/Errc.h"
13 #include "XCOFFObject.h"
14 #include "XCOFFReader.h"
15 #include "XCOFFWriter.h"
21 using namespace object
;
23 static Error
handleArgs(const CommonConfig
&Config
, Object
&Obj
) {
24 return Error::success();
27 Error
executeObjcopyOnBinary(const CommonConfig
&Config
, const XCOFFConfig
&,
28 XCOFFObjectFile
&In
, raw_ostream
&Out
) {
29 XCOFFReader
Reader(In
);
30 Expected
<std::unique_ptr
<Object
>> ObjOrErr
= Reader
.create();
32 return createFileError(Config
.InputFilename
, ObjOrErr
.takeError());
33 Object
*Obj
= ObjOrErr
->get();
34 assert(Obj
&& "Unable to deserialize XCOFF object");
35 if (Error E
= handleArgs(Config
, *Obj
))
36 return createFileError(Config
.InputFilename
, std::move(E
));
37 XCOFFWriter
Writer(*Obj
, Out
);
38 if (Error E
= Writer
.write())
39 return createFileError(Config
.OutputFilename
, std::move(E
));
40 return Error::success();
43 } // end namespace xcoff
44 } // end namespace objcopy
45 } // end namespace llvm