| 1 | //===- XCOFFObjcopy.cpp ---------------------------------------------------===// |
| 2 | // |
| 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 |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "llvm/ObjCopy/XCOFF/XCOFFObjcopy.h" |
| 10 | #include "XCOFFObject.h" |
| 11 | #include "XCOFFReader.h" |
| 12 | #include "XCOFFWriter.h" |
| 13 | #include "llvm/ObjCopy/CommonConfig.h" |
| 14 | #include "llvm/ObjCopy/XCOFF/XCOFFConfig.h" |
| 15 | |
| 16 | namespace llvm { |
| 17 | namespace objcopy { |
| 18 | namespace xcoff { |
| 19 | |
| 20 | using namespace object; |
| 21 | |
| 22 | static Error handleArgs(const CommonConfig &Config, Object &Obj) { |
| 23 | return Error::success(); |
| 24 | } |
| 25 | |
| 26 | Error executeObjcopyOnBinary(const CommonConfig &Config, const XCOFFConfig &, |
| 27 | XCOFFObjectFile &In, raw_ostream &Out) { |
| 28 | XCOFFReader Reader(In); |
| 29 | Expected<std::unique_ptr<Object>> ObjOrErr = Reader.create(); |
| 30 | if (!ObjOrErr) |
| 31 | return createFileError(F: Config.InputFilename, E: ObjOrErr.takeError()); |
| 32 | Object *Obj = ObjOrErr->get(); |
| 33 | assert(Obj && "Unable to deserialize XCOFF object" ); |
| 34 | if (Error E = handleArgs(Config, Obj&: *Obj)) |
| 35 | return createFileError(F: Config.InputFilename, E: std::move(E)); |
| 36 | XCOFFWriter Writer(*Obj, Out); |
| 37 | if (Error E = Writer.write()) |
| 38 | return createFileError(F: Config.OutputFilename, E: std::move(E)); |
| 39 | return Error::success(); |
| 40 | } |
| 41 | |
| 42 | } // end namespace xcoff |
| 43 | } // end namespace objcopy |
| 44 | } // end namespace llvm |
| 45 | |