LLVM 22.0.0git
LoadLinkableFile.h
Go to the documentation of this file.
1//===--- LoadLinkableFile.h -- Load relocatables and archives ---*- C++ -*-===//
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//
9// A wrapper for `MemoryBuffer::getFile` / `MemoryBuffer::getFileSlice` that:
10//
11// 1. Handles relocatable object files, archives, and macho universal
12// binaries.
13// 2. Adds file paths to errors by default.
14// 3. Checks architecture compatibility up-front.
15//
16//===----------------------------------------------------------------------===//
17
18#ifndef LLVM_EXECUTIONENGINE_ORC_LOADLINKABLEFILE_H
19#define LLVM_EXECUTIONENGINE_ORC_LOADLINKABLEFILE_H
20
22#include "llvm/Support/Error.h"
25
26namespace llvm {
27namespace orc {
28
30
31enum class LoadArchives {
32 Never, // Linkable file must not be an archive.
33 Allowed, // Linkable file is allowed to be an archive.
34 Required // Linkable file is required to be an archive.
35};
36
37/// Create a MemoryBuffer covering the "linkable" part of the given path.
38///
39/// The path must contain a relocatable object file or universal binary, or
40/// (if AllowArchives is true) an archive.
41///
42/// If the path is a universal binary then it must contain a slice whose
43/// architecture matches the architecture in the triple (an error will be
44/// returned if there is no such slice, or if the triple does not specify an
45/// architectur).
46///
47/// If the path (or universal binary slice) is a relocatable object file then
48/// its architecture must match the architecture in the triple (if given).
49///
50/// If the path (or universal binary slice) is a relocatable object file then
51/// its format must match the format in the triple (if given).
52///
53/// No verification (e.g. architecture or format) is performed on the contents
54/// of archives.
55///
56/// If IdentifierOverride is provided then it will be used as the name of the
57/// resulting buffer, rather than Path.
60 std::optional<StringRef> IdentifierOverride = std::nullopt);
61
62} // End namespace orc
63} // End namespace llvm
64
65#endif // LLVM_EXECUTIONENGINE_ORC_LOADLINKABLEFILE_H
#define LLVM_ABI
Definition: Compiler.h:213
Tagged union holding either a T or a Error.
Definition: Error.h:485
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:47
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.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18