45 lines · cpp
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-exception6//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 16namespace llvm {17namespace objcopy {18namespace xcoff {19 20using namespace object;21 22static Error handleArgs(const CommonConfig &Config, Object &Obj) {23 return Error::success();24}25 26Error 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(Config.InputFilename, ObjOrErr.takeError());32 Object *Obj = ObjOrErr->get();33 assert(Obj && "Unable to deserialize XCOFF object");34 if (Error E = handleArgs(Config, *Obj))35 return createFileError(Config.InputFilename, std::move(E));36 XCOFFWriter Writer(*Obj, Out);37 if (Error E = Writer.write())38 return createFileError(Config.OutputFilename, std::move(E));39 return Error::success();40}41 42} // end namespace xcoff43} // end namespace objcopy44} // end namespace llvm45