LLVM: lib/Object/Binary.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

28#include

29#include <system_error>

30

31using namespace llvm;

32using namespace object;

33

35

38

40

42

44

47 bool InitContent) {

49

50 switch (Type) {

85

94

102 }

104}

105

110 false);

111 if (std::error_code EC = FileOrErr.getError())

113 std::unique_ptr &Buffer = FileOrErr.get();

114

116 createBinary(Buffer->getMemBufferRef(), Context, InitContent);

117 if (!BinOrErr)

119 std::unique_ptr &Bin = BinOrErr.get();

120

122}

Provides ErrorOr smart pointer.

Represents either an error or a value T.

std::error_code getError() const

Tagged union holding either a T or a Error.

Error takeError()

Take ownership of the stored error.

reference get()

Returns a reference to the stored T value.

This is an important class for using LLVM in a threaded context.

StringRef getBuffer() const

static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileOrSTDIN(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, std::optional< Align > Alignment=std::nullopt)

Open the specified file as a MemoryBuffer, or open stdin if the Filename is "-".

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

The instances of the Type class are immutable: once they are created, they are never changed.

static Expected< std::unique_ptr< Archive > > create(MemoryBufferRef Source)

StringRef getData() const

Definition Binary.cpp:39

MemoryBufferRef getMemoryBufferRef() const

Definition Binary.cpp:43

StringRef getFileName() const

Definition Binary.cpp:41

static Expected< std::unique_ptr< MachOUniversalBinary > > create(MemoryBufferRef Source)

static LLVM_ABI Expected< std::unique_ptr< MinidumpFile > > create(MemoryBufferRef Source)

Construct a new MinidumpFile object from the given memory buffer.

static LLVM_ABI Expected< std::unique_ptr< OffloadBinary > > create(MemoryBufferRef)

Attempt to parse the offloading binary stored in Data.

static Expected< std::unique_ptr< SymbolicFile > > createSymbolicFile(MemoryBufferRef Object, llvm::file_magic Type, LLVMContext *Context, bool InitContent=true)

static Expected< std::unique_ptr< TapiUniversal > > create(MemoryBufferRef Source)

static LLVM_ABI Expected< std::unique_ptr< WindowsResource > > createWindowsResource(MemoryBufferRef Source)

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

LLVM_ABI Expected< std::unique_ptr< Binary > > createBinary(MemoryBufferRef Source, LLVMContext *Context=nullptr, bool InitContent=true)

Create a Binary from Source, autodetecting the file type.

Definition Binary.cpp:45

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.

LLVM_ABI Error errorCodeToError(std::error_code EC)

Helper for converting an std::error_code to a Error.

file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...

@ coff_import_library

COFF import library.

@ pdb

Windows PDB debug info file.

@ spirv_object

A binary SPIR-V file.

@ elf_relocatable

ELF Relocatable object file.

@ archive

ar style archive file

@ elf_shared_object

ELF dynamically linked shared lib.

@ goff_object

GOFF object file.

@ minidump

Windows minidump file.

@ macho_dynamically_linked_shared_lib

Mach-O dynlinked shared lib.

@ xcoff_object_64

64-bit XCOFF object file

@ elf_executable

ELF Executable image.

@ macho_dynamically_linked_shared_lib_stub

Mach-O Shared lib stub.

@ macho_preload_executable

Mach-O Preloaded Executable.

@ offload_bundle

Clang offload bundle file.

@ offload_bundle_compressed

Compressed clang offload bundle file.

@ macho_file_set

Mach-O file set binary.

@ dxcontainer_object

DirectX container file.

@ macho_kext_bundle

Mach-O kext bundle file.

@ pecoff_executable

PECOFF executable file.

@ offload_binary

LLVM offload object file.

@ macho_universal_binary

Mach-O universal binary.

@ macho_core

Mach-O Core File.

@ wasm_object

WebAssembly Object file.

@ xcoff_object_32

32-bit XCOFF object file

@ windows_resource

Windows compiled resource file (.res)

@ clang_ast

Clang PCH or PCM.

@ elf_core

ELF core image.

@ macho_object

Mach-O Object file.

@ coff_object

COFF object file.

@ macho_bundle

Mach-O Bundle file.

@ coff_cl_gl_object

Microsoft cl.exe's intermediate code file.

@ cuda_fatbinary

CUDA Fatbinary object file.

@ macho_executable

Mach-O Executable.

@ macho_dsym_companion

Mach-O dSYM companion file.

@ unknown

Unrecognized file.

@ macho_fixed_virtual_memory_shared_lib

Mach-O Shared Lib, FVM.

@ macho_dynamic_linker

The Mach-O dynamic linker.

@ tapi_file

Text-based Dynamic Library Stub file.