LLVM 20.0.0git
MachO.h
Go to the documentation of this file.
1//===------------- MachO.h - MachO format utilities -------------*- 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// Contains utilities for load MachO relocatable object files.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_EXECUTIONENGINE_ORC_MACHO_H
14#define LLVM_EXECUTIONENGINE_ORC_MACHO_H
15
16#include "llvm/Support/Error.h"
19
20namespace llvm {
21
22namespace object {
23
24class MachOUniversalBinary;
25
26} // namespace object
27
28namespace orc {
29
30/// Check that the given buffer contains a MachO object file compatible with the
31/// given triple.
32/// ObjIsSlice should be set to true if Obj is a slice of a universal binary
33/// (that fact will then be reported in the error messages).
34Expected<std::unique_ptr<MemoryBuffer>>
35checkMachORelocatableObject(std::unique_ptr<MemoryBuffer> Obj, const Triple &TT,
36 bool ObjIsSlice);
37
38/// Load a relocatable object compatible with TT from Path.
39/// If Path is a universal binary, this function will return a buffer for the
40/// slice compatible with Triple (if one is present).
41Expected<std::unique_ptr<MemoryBuffer>>
42loadMachORelocatableObject(StringRef Path, const Triple &TT);
43
44/// Load a compatible relocatable object (if available) from a MachO universal
45/// binary.
46Expected<std::unique_ptr<MemoryBuffer>>
48 StringRef UBPath, std::unique_ptr<MemoryBuffer> UBBuf, const Triple &TT);
49
50/// Utility for identifying the file-slice compatible with TT in a universal
51/// binary.
52Expected<std::pair<size_t, size_t>>
53getMachOSliceRangeForTriple(object::MachOUniversalBinary &UB, const Triple &TT);
54
55/// Utility for identifying the file-slice compatible with TT in a universal
56/// binary.
57Expected<std::pair<size_t, size_t>>
58getMachOSliceRangeForTriple(MemoryBufferRef UBBuf, const Triple &TT);
59
60} // namespace orc
61} // namespace llvm
62
63#endif // LLVM_EXECUTIONENGINE_ORC_MACHO_H
Expected< std::unique_ptr< MemoryBuffer > > checkMachORelocatableObject(std::unique_ptr< MemoryBuffer > Obj, const Triple &TT, bool ObjIsSlice)
Check that the given buffer contains a MachO object file compatible with the given triple.
Definition: MachO.cpp:57
Expected< std::pair< size_t, size_t > > getMachOSliceRangeForTriple(object::MachOUniversalBinary &UB, const Triple &TT)
Utility for identifying the file-slice compatible with TT in a universal binary.
Definition: MachO.cpp:133
Expected< std::unique_ptr< MemoryBuffer > > loadMachORelocatableObjectFromUniversalBinary(StringRef UBPath, std::unique_ptr< MemoryBuffer > UBBuf, const Triple &TT)
Load a compatible relocatable object (if available) from a MachO universal binary.
Definition: MachO.cpp:112
Expected< std::unique_ptr< MemoryBuffer > > loadMachORelocatableObject(StringRef Path, const Triple &TT)
Load a relocatable object compatible with TT from Path.
Definition: MachO.cpp:88
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18