XCOFFObjcopy.cpp 1.5 KB

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