1 //===---- LoadRelocatableObject.h - Load relocatable objects ----*- 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. Adds file paths to errors by default. 12 // 2. Checks architecture compatibility up-front. 13 // 3. Handles MachO universal binaries, returning the MemoryBuffer for the 14 // requested slice only. 15 // 16 //===----------------------------------------------------------------------===// 17 18 #ifndef LLVM_EXECUTIONENGINE_ORC_LOADRELOCATABLEOBJECT_H 19 #define LLVM_EXECUTIONENGINE_ORC_LOADRELOCATABLEOBJECT_H 20 21 #include "llvm/Support/Error.h" 22 #include "llvm/Support/MemoryBuffer.h" 23 #include "llvm/TargetParser/Triple.h" 24 25 namespace llvm { 26 namespace orc { 27 28 // Load an object file compatible with the given triple (if given) from the 29 // given path. May return a file slice if the path contains a universal binary. 30 Expected<std::unique_ptr<MemoryBuffer>> loadRelocatableObject( 31 StringRef Path, const Triple &TT, 32 std::optional<StringRef> IdentifierOverride = std::nullopt); 33 34 } // End namespace orc 35 } // End namespace llvm 36 37 #endif // LLVM_EXECUTIONENGINE_ORC_LOADRELOCATABLEOBJECT_H 38