LLVM 20.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
21#include "llvm/Support/Error.h"
24
25namespace llvm {
26namespace orc {
27
29
31 Never, // Linkable file must not be an archive.
32 Allowed, // Linkable file is allowed to be an archive.
33 Required // Linkable file is required to be an archive.
34};
35
36/// Create a MemoryBuffer covering the "linkable" part of the given path.
37///
38/// The path must contain a relocatable object file or universal binary, or
39/// (if AllowArchives is true) an archive.
40///
41/// If the path is a universal binary then it must contain a slice whose
42/// architecture matches the architecture in the triple (an error will be
43/// returned if there is no such slice, or if the triple does not specify an
44/// architectur).
45///
46/// If the path (or universal binary slice) is a relocatable object file then
47/// its architecture must match the architecture in the triple (if given).
48///
49/// If the path (or universal binary slice) is a relocatable object file then
50/// its format must match the format in the triple (if given).
51///
52/// No verification (e.g. architecture or format) is performed on the contents
53/// of archives.
54///
55/// If IdentifierOverride is provided then it will be used as the name of the
56/// resulting buffer, rather than Path.
59 std::optional<StringRef> IdentifierOverride = std::nullopt);
60
61} // End namespace orc
62} // End namespace llvm
63
64#endif // LLVM_EXECUTIONENGINE_ORC_LOADLINKABLEFILE_H
Tagged union holding either a T or a Error.
Definition: Error.h:481
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
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