LLVM 22.0.0git
MachO.h
Go to the documentation of this file.
1//===------- MachO.h - Generic JIT link function for MachO ------*- 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// Generic jit-link functions for MachO.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_EXECUTIONENGINE_JITLINK_MACHO_H
14#define LLVM_EXECUTIONENGINE_JITLINK_MACHO_H
15
19
20namespace llvm {
21namespace jitlink {
22
23/// Create a LinkGraph from a MachO relocatable object.
24///
25/// Note: The graph does not take ownership of the underlying buffer, nor copy
26/// its contents. The caller is responsible for ensuring that the object buffer
27/// outlives the graph.
28LLVM_ABI Expected<std::unique_ptr<LinkGraph>>
29createLinkGraphFromMachOObject(MemoryBufferRef ObjectBuffer,
30 std::shared_ptr<orc::SymbolStringPool> SSP);
31
32/// jit-link the given ObjBuffer, which must be a MachO object file.
33///
34/// Uses conservative defaults for GOT and stub handling based on the target
35/// platform.
36LLVM_ABI void link_MachO(std::unique_ptr<LinkGraph> G,
37 std::unique_ptr<JITLinkContext> Ctx);
38
39/// Get a pointer to the standard MachO data section (creates an empty
40/// section with RW- permissions and standard lifetime if one does not
41/// already exist).
43 if (auto *DataSec = G.findSectionByName(orc::MachODataDataSectionName))
44 return *DataSec;
45 return G.createSection(orc::MachODataDataSectionName,
47}
48
49/// Get a pointer to the standard MachO text section (creates an empty
50/// section with R-X permissions and standard lifetime if one does not
51/// already exist).
53 if (auto *TextSec = G.findSectionByName(orc::MachOTextTextSectionName))
54 return *TextSec;
55 return G.createSection(orc::MachOTextTextSectionName,
57}
58
59/// Gets or creates a MachO header for the current LinkGraph.
61
62} // end namespace jitlink
63} // end namespace llvm
64
65#endif // LLVM_EXECUTIONENGINE_JITLINK_MACHO_H
#define LLVM_ABI
Definition: Compiler.h:213
#define G(x, y, z)
Definition: MD5.cpp:56
Tagged union holding either a T or a Error.
Definition: Error.h:485
LLVM_ABI StringRef MachODataDataSectionName
LLVM_ABI StringRef MachOTextTextSectionName
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18