LLVM: lib/ExecutionEngine/Orc/LoadLinkableFile.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

10

15

16#define DEBUG_TYPE "orc"

17

18namespace llvm {

19namespace orc {

20

21static Expected<std::unique_ptr>

24

25 return std::move(Obj);

26}

27

31

32 return std::move(Obj);

33}

34

37

38 return std::move(Obj);

39}

40

43 std::optional IdentifierOverride) {

44 if (!IdentifierOverride)

45 IdentifierOverride = Path;

46

49 if (!FDOrErr)

53

54 auto Buf =

56 if (!Buf)

58 StringRef("Could not load object at path ") + Path, Buf.getError());

59

60 std::optionalTriple::ObjectFormatType RequireFormat;

62 RequireFormat = TT.getObjectFormat();

63

69 Path + " does not contain a relocatable object file",

75

76 if (!RequireFormat || *RequireFormat == Triple::COFF) {

78 if (!CheckedBuf)

79 return CheckedBuf.takeError();

80 return std::make_pair(std::move(*CheckedBuf),

82 }

83 break;

88

89 if (!RequireFormat || *RequireFormat == Triple::ELF) {

91 if (!CheckedBuf)

92 return CheckedBuf.takeError();

93 return std::make_pair(std::move(*CheckedBuf),

95 }

96 break;

101

102 if (!RequireFormat || *RequireFormat == Triple::MachO) {

104 if (!CheckedBuf)

105 return CheckedBuf.takeError();

106 return std::make_pair(std::move(*CheckedBuf),

108 }

109 break;

111 if (!RequireFormat || *RequireFormat == Triple::MachO)

113 FD, std::move(*Buf), TT, LA, Path, *IdentifierOverride);

114 break;

116 if (!RequireFormat || *RequireFormat == Triple::XCOFF) {

118 if (!CheckedBuf)

119 return CheckedBuf.takeError();

120 return std::make_pair(std::move(*CheckedBuf),

122 }

123 break;

124 default:

125 break;

126 }

127

129 Path +

130 " does not contain a relocatable object file or archive compatible "

131 "with " +

132 TT.str(),

134}

135

136}

137}

This file defines the make_scope_exit function, which executes user-defined cleanup logic at scope ex...

Tagged union holding either a T or a Error.

Error takeError()

Take ownership of the stored error.

static ErrorOr< std::unique_ptr< MemoryBuffer > > getOpenFile(sys::fs::file_t FD, const Twine &Filename, uint64_t FileSize, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)

Given an already-open file descriptor, read the file and return a MemoryBuffer.

StringRef - Represent a constant reference to a string, i.e.

Triple - Helper class for working with autoconf configuration names.

LLVM_ABI Expected< std::pair< std::unique_ptr< MemoryBuffer >, LinkableFileKind > > loadLinkableFile(StringRef Path, const Triple &TT, LoadArchives LA, std::optional< StringRef > IdentifierOverride=std::nullopt)

Create a MemoryBuffer covering the "linkable" part of the given path.

Definition LoadLinkableFile.cpp:42

LLVM_ABI Expected< std::pair< std::unique_ptr< MemoryBuffer >, LinkableFileKind > > loadLinkableSliceFromMachOUniversalBinary(sys::fs::file_t FD, std::unique_ptr< MemoryBuffer > UBBuf, const Triple &TT, LoadArchives LA, StringRef UBPath, StringRef Identifier)

Load a compatible relocatable object (if available) from a MachO universal binary.

static Expected< std::unique_ptr< MemoryBuffer > > checkCOFFRelocatableObject(std::unique_ptr< MemoryBuffer > Obj, const Triple &TT)

Definition LoadLinkableFile.cpp:22

LLVM_ABI Error checkMachORelocatableObject(MemoryBufferRef Obj, const Triple &TT, bool ObjIsSlice)

Check that the given buffer contains a MachO object file compatible with the given triple.

static Expected< std::unique_ptr< MemoryBuffer > > checkELFRelocatableObject(std::unique_ptr< MemoryBuffer > Obj, const Triple &TT)

Definition LoadLinkableFile.cpp:36

static Expected< std::unique_ptr< MemoryBuffer > > checkXCOFFRelocatableObject(std::unique_ptr< MemoryBuffer > Obj, const Triple &TT)

Definition LoadLinkableFile.cpp:29

LLVM_ABI std::error_code closeFile(file_t &F)

Close the file object.

LLVM_ABI Expected< file_t > openNativeFileForRead(const Twine &Name, OpenFlags Flags=OF_None, SmallVectorImpl< char > *RealPath=nullptr)

Opens the file with the given name in a read-only mode, returning its open file descriptor.

This is an optimization pass for GlobalISel generic memory operations.

LLVM_ABI file_magic identify_magic(StringRef magic)

Identify the type of a binary file based on how magical it is.

Error createFileError(const Twine &F, Error E)

Concatenate a source file path and/or name with an Error.

detail::scope_exit< std::decay_t< Callable > > make_scope_exit(Callable &&F)

LLVM_ABI std::error_code inconvertibleErrorCode()

The value returned by this function can be returned from convertToErrorCode for Error values where no...

Error make_error(ArgTs &&... Args)

Make a Error instance representing failure using the given error info type.

@ elf_relocatable

ELF Relocatable object file.

@ archive

ar style archive file

@ xcoff_object_64

64-bit XCOFF object file

@ macho_universal_binary

Mach-O universal binary.

@ macho_object

Mach-O Object file.

@ coff_object

COFF object file.