1 //===- MachOLayoutBuilder.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_OBJCOPY_MACHO_MACHOLAYOUTBUILDER_H
10 #define LLVM_OBJCOPY_MACHO_MACHOLAYOUTBUILDER_H
12 #include "MachOObjcopy.h"
19 class MachOLayoutBuilder
{
24 // Points to the __LINKEDIT segment if it exists.
25 MachO::macho_load_command
*LinkEditLoadCommand
= nullptr;
26 StringTableBuilder StrTableBuilder
{StringTableBuilder::MachO
};
28 uint32_t computeSizeOfCmds() const;
29 void constructStringTable();
30 void updateSymbolIndexes();
31 void updateDySymTab(MachO::macho_load_command
&MLC
);
32 uint64_t layoutSegments();
33 uint64_t layoutRelocations(uint64_t Offset
);
34 Error
layoutTail(uint64_t Offset
);
37 MachOLayoutBuilder(Object
&O
, bool Is64Bit
, uint64_t PageSize
)
38 : O(O
), Is64Bit(Is64Bit
), PageSize(PageSize
) {}
40 // Recomputes and updates fields in the given object such as file offsets.
43 StringTableBuilder
&getStringTableBuilder() { return StrTableBuilder
; }
46 } // end namespace macho
47 } // end namespace objcopy
48 } // end namespace llvm
50 #endif // LLVM_OBJCOPY_MACHO_MACHOLAYOUTBUILDER_H