Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:53

0001 //===--- LoadLinkableFile.h -- Load relocatables and archives ---*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // A wrapper for `MemoryBuffer::getFile` / `MemoryBuffer::getFileSlice` that:
0010 //
0011 //   1. Handles relocatable object files, archives, and macho universal
0012 //      binaries.
0013 //   2. Adds file paths to errors by default.
0014 //   3. Checks architecture compatibility up-front.
0015 //
0016 //===----------------------------------------------------------------------===//
0017 
0018 #ifndef LLVM_EXECUTIONENGINE_ORC_LOADLINKABLEFILE_H
0019 #define LLVM_EXECUTIONENGINE_ORC_LOADLINKABLEFILE_H
0020 
0021 #include "llvm/Support/Error.h"
0022 #include "llvm/Support/MemoryBuffer.h"
0023 #include "llvm/TargetParser/Triple.h"
0024 
0025 namespace llvm {
0026 namespace orc {
0027 
0028 enum class LinkableFileKind { Archive, RelocatableObject };
0029 
0030 enum LoadArchives {
0031   Never,   // Linkable file must not be an archive.
0032   Allowed, // Linkable file is allowed to be an archive.
0033   Required // Linkable file is required to be an archive.
0034 };
0035 
0036 /// Create a MemoryBuffer covering the "linkable" part of the given path.
0037 ///
0038 /// The path must contain a relocatable object file or universal binary, or
0039 /// (if AllowArchives is true) an archive.
0040 ///
0041 /// If the path is a universal binary then it must contain a slice whose
0042 /// architecture matches the architecture in the triple (an error will be
0043 /// returned if there is no such slice, or if the triple does not specify an
0044 /// architectur).
0045 ///
0046 /// If the path (or universal binary slice) is a relocatable object file then
0047 /// its architecture must match the architecture in the triple (if given).
0048 ///
0049 /// If the path (or universal binary slice) is a relocatable object file then
0050 /// its format must match the format in the triple (if given).
0051 ///
0052 /// No verification (e.g. architecture or format) is performed on the contents
0053 /// of archives.
0054 ///
0055 /// If IdentifierOverride is provided then it will be used as the name of the
0056 /// resulting buffer, rather than Path.
0057 Expected<std::pair<std::unique_ptr<MemoryBuffer>, LinkableFileKind>>
0058 loadLinkableFile(StringRef Path, const Triple &TT, LoadArchives LA,
0059                  std::optional<StringRef> IdentifierOverride = std::nullopt);
0060 
0061 } // End namespace orc
0062 } // End namespace llvm
0063 
0064 #endif // LLVM_EXECUTIONENGINE_ORC_LOADLINKABLEFILE_H