[ARM] Tighten up VLDRH.32 with low alignments
[llvm-complete.git] / tools / llvm-objcopy / MachO / MachOWriter.h
blobecf12d62de2cb08aa4baf5c4e2eeb4e4825d2180
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 "MachOObjcopy.h"
11 #include "Object.h"
12 #include "llvm/BinaryFormat/MachO.h"
13 #include "llvm/Object/MachO.h"
15 namespace llvm {
16 class Error;
18 namespace objcopy {
19 namespace macho {
21 class MachOWriter {
22 Object &O;
23 bool Is64Bit;
24 bool IsLittleEndian;
25 Buffer &B;
26 StringTableBuilder StrTableBuilder{StringTableBuilder::MachO};
28 size_t headerSize() const;
29 size_t loadCommandsSize() const;
30 size_t symTableSize() const;
31 size_t strTableSize() const;
33 void updateDySymTab(MachO::macho_load_command &MLC);
34 void updateSizeOfCmds();
35 void updateSymbolIndexes();
36 void constructStringTable();
37 Error layout();
39 void writeHeader();
40 void writeLoadCommands();
41 template <typename StructType>
42 void writeSectionInLoadCommand(const Section &Sec, uint8_t *&Out);
43 void writeSections();
44 void writeSymbolTable();
45 void writeStringTable();
46 void writeRebaseInfo();
47 void writeBindInfo();
48 void writeWeakBindInfo();
49 void writeLazyBindInfo();
50 void writeExportInfo();
51 void writeTail();
53 public:
54 MachOWriter(Object &O, bool Is64Bit, bool IsLittleEndian, Buffer &B)
55 : O(O), Is64Bit(Is64Bit), IsLittleEndian(IsLittleEndian), B(B) {}
57 size_t totalSize() const;
58 Error finalize();
59 Error write();
62 } // end namespace macho
63 } // end namespace objcopy
64 } // end namespace llvm