[InstCombine] Signed saturation patterns
[llvm-core.git] / tools / llvm-objcopy / MachO / MachOWriter.h
blob22abbad56f41c3947da95a59271c0dc28afff77b
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 //===----------------------------------------------------------------------===//
9 #include "../Buffer.h"
10 #include "MachOLayoutBuilder.h"
11 #include "MachOObjcopy.h"
12 #include "Object.h"
13 #include "llvm/BinaryFormat/MachO.h"
14 #include "llvm/Object/MachO.h"
16 namespace llvm {
17 class Error;
19 namespace objcopy {
20 namespace macho {
22 class MachOWriter {
23 Object &O;
24 bool Is64Bit;
25 bool IsLittleEndian;
26 uint64_t PageSize;
27 Buffer &B;
28 MachOLayoutBuilder LayoutBuilder;
30 size_t headerSize() const;
31 size_t loadCommandsSize() const;
32 size_t symTableSize() const;
33 size_t strTableSize() const;
35 void writeHeader();
36 void writeLoadCommands();
37 template <typename StructType>
38 void writeSectionInLoadCommand(const Section &Sec, uint8_t *&Out);
39 void writeSections();
40 void writeSymbolTable();
41 void writeStringTable();
42 void writeRebaseInfo();
43 void writeBindInfo();
44 void writeWeakBindInfo();
45 void writeLazyBindInfo();
46 void writeExportInfo();
47 void writeIndirectSymbolTable();
48 void writeDataInCodeData();
49 void writeFunctionStartsData();
50 void writeTail();
52 public:
53 MachOWriter(Object &O, bool Is64Bit, bool IsLittleEndian, uint64_t PageSize,
54 Buffer &B)
55 : O(O), Is64Bit(Is64Bit), IsLittleEndian(IsLittleEndian),
56 PageSize(PageSize), B(B), LayoutBuilder(O, Is64Bit, PageSize) {}
58 size_t totalSize() const;
59 Error finalize();
60 Error write();
63 } // end namespace macho
64 } // end namespace objcopy
65 } // end namespace llvm