LLVM  15.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 
12 #include "llvm/Support/Errc.h"
13 #include "XCOFFObject.h"
14 #include "XCOFFReader.h"
15 #include "XCOFFWriter.h"
16 
17 namespace llvm {
18 namespace objcopy {
19 namespace xcoff {
20 
21 using namespace object;
22 
23 static Error handleArgs(const CommonConfig &Config, Object &Obj) {
24  return Error::success();
25 }
26 
29  XCOFFReader Reader(In);
30  Expected<std::unique_ptr<Object>> ObjOrErr = Reader.create();
31  if (!ObjOrErr)
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();
41 }
42 
43 } // end namespace xcoff
44 } // end namespace objcopy
45 } // end namespace llvm
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::objcopy::CommonConfig::OutputFilename
StringRef OutputFilename
Definition: CommonConfig.h:205
llvm::objcopy::CommonConfig::InputFilename
StringRef InputFilename
Definition: CommonConfig.h:203
XCOFFWriter.h
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:329
Errc.h
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
llvm::createFileError
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
Definition: Error.h:1320
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:54
CommonConfig.h
XCOFFObject.h
llvm::tgtok::In
@ In
Definition: TGLexer.h:51
object
bar al al movzbl eax ret Missed when stored in a memory object
Definition: README.txt:1411
llvm::objcopy::xcoff::XCOFFWriter::write
Error write()
Definition: XCOFFWriter.cpp:108
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
XCOFFConfig.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
XCOFFReader.h
llvm::objcopy::xcoff::XCOFFReader::create
Expected< std::unique_ptr< Object > > create() const
Definition: XCOFFReader.cpp:75
llvm::objcopy::xcoff::executeObjcopyOnBinary
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.
Definition: XCOFFObjcopy.cpp:27
llvm::Expected::get
reference get()
Returns a reference to the stored T value.
Definition: Error.h:567
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition: Error.h:597
llvm::object::XCOFFObjectFile
Definition: XCOFFObjectFile.h:445
llvm::objcopy::xcoff::handleArgs
static Error handleArgs(const CommonConfig &Config, Object &Obj)
Definition: XCOFFObjcopy.cpp:23
llvm::objcopy::xcoff::XCOFFReader
Definition: XCOFFReader.h:20
XCOFFObjcopy.h
llvm::objcopy::CommonConfig
Definition: CommonConfig.h:201
llvm::objcopy::xcoff::Object
Definition: XCOFFObject.h:36
llvm::objcopy::XCOFFConfig
Definition: XCOFFConfig.h:16
llvm::objcopy::xcoff::XCOFFWriter
Definition: XCOFFWriter.h:22