1 //===- MachOWriter.h --------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIB_OBJCOPY_MACHO_MACHOWRITER_H
10 #define LLVM_LIB_OBJCOPY_MACHO_MACHOWRITER_H
12 #include "MachOLayoutBuilder.h"
13 #include "MachOObject.h"
14 #include "llvm/BinaryFormat/MachO.h"
15 #include "llvm/ObjCopy/MachO/MachOObjcopy.h"
16 #include "llvm/Object/MachO.h"
29 std::unique_ptr
<WritableMemoryBuffer
> Buf
;
31 MachOLayoutBuilder LayoutBuilder
;
33 size_t headerSize() const;
34 size_t loadCommandsSize() const;
35 size_t symTableSize() const;
36 size_t strTableSize() const;
39 void writeLoadCommands();
40 template <typename StructType
>
41 void writeSectionInLoadCommand(const Section
&Sec
, uint8_t *&Out
);
43 void writeSymbolTable();
44 void writeStringTable();
45 void writeRebaseInfo();
47 void writeWeakBindInfo();
48 void writeLazyBindInfo();
49 void writeExportInfo();
50 void writeIndirectSymbolTable();
51 void writeLinkData(std::optional
<size_t> LCIndex
, const LinkData
&LD
);
52 void writeCodeSignatureData();
53 void writeDataInCodeData();
54 void writeLinkerOptimizationHint();
55 void writeFunctionStartsData();
56 void writeDylibCodeSignDRsData();
57 void writeChainedFixupsData();
58 void writeExportsTrieData();
62 MachOWriter(Object
&O
, bool Is64Bit
, bool IsLittleEndian
,
63 StringRef OutputFileName
, uint64_t PageSize
, raw_ostream
&Out
)
64 : O(O
), Is64Bit(Is64Bit
), IsLittleEndian(IsLittleEndian
),
65 PageSize(PageSize
), Out(Out
),
66 LayoutBuilder(O
, Is64Bit
, OutputFileName
, PageSize
) {}
68 size_t totalSize() const;
73 } // end namespace macho
74 } // end namespace objcopy
75 } // end namespace llvm
77 #endif // LLVM_LIB_OBJCOPY_MACHO_MACHOWRITER_H