LLVM 20.0.0git
XCOFFObjcopy.cpp
Go to the documentation of this file.
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
10#include "XCOFFObject.h"
11#include "XCOFFReader.h"
12#include "XCOFFWriter.h"
15
16namespace llvm {
17namespace objcopy {
18namespace xcoff {
19
20using namespace object;
21
23 return Error::success();
24}
25
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 xcoff
43} // end namespace objcopy
44} // end namespace llvm
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
RelaxConfig Config
Definition: ELF_riscv.cpp:506
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
static ErrorSuccess success()
Create a success value.
Definition: Error.h:337
Tagged union holding either a T or a Error.
Definition: Error.h:481
Error takeError()
Take ownership of the stored error.
Definition: Error.h:608
reference get()
Returns a reference to the stored T value.
Definition: Error.h:578
Expected< std::unique_ptr< Object > > create() const
Definition: XCOFFReader.cpp:75
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
Error executeObjcopyOnBinary(const CommonConfig &Config, const XCOFFConfig &, object::XCOFFObjectFile &In, raw_ostream &Out)
Apply the transformations described by Config and XCOFFConfig to In and writes the result into Out.
static Error handleArgs(const CommonConfig &Config, Object &Obj)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
Definition: Error.h:1385