LLVM 24.0.0git
MachOWriter.h
Go to the documentation of this file.
1//===- MachOWriter.h --------------------------------------------*- 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#ifndef LLVM_LIB_OBJCOPY_MACHO_MACHOWRITER_H
10#define LLVM_LIB_OBJCOPY_MACHO_MACHOWRITER_H
11
12#include "MachOLayoutBuilder.h"
13#include "MachOObject.h"
16#include "llvm/Object/MachO.h"
17
18namespace llvm {
19class Error;
20
21namespace objcopy {
22namespace macho {
23
25 Object &O;
26 bool Is64Bit;
27 bool IsLittleEndian;
28 std::unique_ptr<WritableMemoryBuffer> Buf;
29 raw_ostream &Out;
30 MachOLayoutBuilder LayoutBuilder;
31
32 size_t headerSize() const;
33 size_t loadCommandsSize() const;
34 size_t symTableSize() const;
35
36 void writeHeader();
37 void writeLoadCommands();
38 template <typename StructType>
39 void writeSectionInLoadCommand(const Section &Sec, uint8_t *&Out);
40 void writeSections();
41 void writeSymbolTable();
42 void writeStringTable();
43 void writeRebaseInfo();
44 void writeBindInfo();
45 void writeWeakBindInfo();
46 void writeLazyBindInfo();
47 void writeExportInfo();
48 void writeIndirectSymbolTable();
49 void writeLinkData(std::optional<size_t> LCIndex, const LinkData &LD);
50 void writeCodeSignatureData();
51 void writeDataInCodeData();
52 void writeLinkerOptimizationHint();
53 void writeFunctionStartsData();
54 void writeDylibCodeSignDRsData();
55 void writeChainedFixupsData();
56 void writeExportsTrieData();
57 void writeTail();
58
59public:
60 MachOWriter(Object &O, bool Is64Bit, bool IsLittleEndian,
61 StringRef OutputFileName, uint64_t PageSize, raw_ostream &Out)
62 : O(O), Is64Bit(Is64Bit), IsLittleEndian(IsLittleEndian), Out(Out),
63 LayoutBuilder(O, Is64Bit, OutputFileName, PageSize) {}
64
65 size_t totalSize() const;
67 Error write();
68};
69
70} // end namespace macho
71} // end namespace objcopy
72} // end namespace llvm
73
74#endif // LLVM_LIB_OBJCOPY_MACHO_MACHOWRITER_H
uint64_t uint64_t
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
MachOWriter(Object &O, bool Is64Bit, bool IsLittleEndian, StringRef OutputFileName, uint64_t PageSize, raw_ostream &Out)
Definition MachOWriter.h:60
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.