1*d415bd75Srobert //===- MachOObject.h - Mach-O object file model -----------------*- C++ -*-===//
2*d415bd75Srobert //
3*d415bd75Srobert // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*d415bd75Srobert // See https://llvm.org/LICENSE.txt for license information.
5*d415bd75Srobert // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*d415bd75Srobert //
7*d415bd75Srobert //===----------------------------------------------------------------------===//
8*d415bd75Srobert 
9*d415bd75Srobert #ifndef LLVM_LIB_OBJCOPY_MACHO_MACHOOBJECT_H
10*d415bd75Srobert #define LLVM_LIB_OBJCOPY_MACHO_MACHOOBJECT_H
11*d415bd75Srobert 
12*d415bd75Srobert #include "llvm/ADT/StringRef.h"
13*d415bd75Srobert #include "llvm/BinaryFormat/MachO.h"
14*d415bd75Srobert #include "llvm/MC/StringTableBuilder.h"
15*d415bd75Srobert #include "llvm/ObjectYAML/DWARFYAML.h"
16*d415bd75Srobert #include "llvm/Support/StringSaver.h"
17*d415bd75Srobert #include "llvm/Support/YAMLTraits.h"
18*d415bd75Srobert #include <cstdint>
19*d415bd75Srobert #include <string>
20*d415bd75Srobert #include <vector>
21*d415bd75Srobert 
22*d415bd75Srobert namespace llvm {
23*d415bd75Srobert namespace objcopy {
24*d415bd75Srobert namespace macho {
25*d415bd75Srobert 
26*d415bd75Srobert struct MachHeader {
27*d415bd75Srobert   uint32_t Magic;
28*d415bd75Srobert   uint32_t CPUType;
29*d415bd75Srobert   uint32_t CPUSubType;
30*d415bd75Srobert   uint32_t FileType;
31*d415bd75Srobert   uint32_t NCmds;
32*d415bd75Srobert   uint32_t SizeOfCmds;
33*d415bd75Srobert   uint32_t Flags;
34*d415bd75Srobert   uint32_t Reserved = 0;
35*d415bd75Srobert };
36*d415bd75Srobert 
37*d415bd75Srobert struct RelocationInfo;
38*d415bd75Srobert struct Section {
39*d415bd75Srobert   uint32_t Index;
40*d415bd75Srobert   std::string Segname;
41*d415bd75Srobert   std::string Sectname;
42*d415bd75Srobert   // CanonicalName is a string formatted as “<Segname>,<Sectname>".
43*d415bd75Srobert   std::string CanonicalName;
44*d415bd75Srobert   uint64_t Addr = 0;
45*d415bd75Srobert   uint64_t Size = 0;
46*d415bd75Srobert   // Offset in the input file.
47*d415bd75Srobert   std::optional<uint32_t> OriginalOffset;
48*d415bd75Srobert   uint32_t Offset = 0;
49*d415bd75Srobert   uint32_t Align = 0;
50*d415bd75Srobert   uint32_t RelOff = 0;
51*d415bd75Srobert   uint32_t NReloc = 0;
52*d415bd75Srobert   uint32_t Flags = 0;
53*d415bd75Srobert   uint32_t Reserved1 = 0;
54*d415bd75Srobert   uint32_t Reserved2 = 0;
55*d415bd75Srobert   uint32_t Reserved3 = 0;
56*d415bd75Srobert   StringRef Content;
57*d415bd75Srobert   std::vector<RelocationInfo> Relocations;
58*d415bd75Srobert 
59*d415bd75Srobert   Section(StringRef SegName, StringRef SectName);
60*d415bd75Srobert 
61*d415bd75Srobert   Section(StringRef SegName, StringRef SectName, StringRef Content);
62*d415bd75Srobert 
getTypeSection63*d415bd75Srobert   MachO::SectionType getType() const {
64*d415bd75Srobert     return static_cast<MachO::SectionType>(Flags & MachO::SECTION_TYPE);
65*d415bd75Srobert   }
66*d415bd75Srobert 
isVirtualSectionSection67*d415bd75Srobert   bool isVirtualSection() const {
68*d415bd75Srobert     return (getType() == MachO::S_ZEROFILL ||
69*d415bd75Srobert             getType() == MachO::S_GB_ZEROFILL ||
70*d415bd75Srobert             getType() == MachO::S_THREAD_LOCAL_ZEROFILL);
71*d415bd75Srobert   }
72*d415bd75Srobert 
hasValidOffsetSection73*d415bd75Srobert   bool hasValidOffset() const {
74*d415bd75Srobert     return !(isVirtualSection() || (OriginalOffset && *OriginalOffset == 0));
75*d415bd75Srobert   }
76*d415bd75Srobert };
77*d415bd75Srobert 
78*d415bd75Srobert struct LoadCommand {
79*d415bd75Srobert   // The type MachO::macho_load_command is defined in llvm/BinaryFormat/MachO.h
80*d415bd75Srobert   // and it is a union of all the structs corresponding to various load
81*d415bd75Srobert   // commands.
82*d415bd75Srobert   MachO::macho_load_command MachOLoadCommand;
83*d415bd75Srobert 
84*d415bd75Srobert   // The raw content of the payload of the load command (located right after the
85*d415bd75Srobert   // corresponding struct). In some cases it is either empty or can be
86*d415bd75Srobert   // copied-over without digging into its structure.
87*d415bd75Srobert   std::vector<uint8_t> Payload;
88*d415bd75Srobert 
89*d415bd75Srobert   // Some load commands can contain (inside the payload) an array of sections,
90*d415bd75Srobert   // though the contents of the sections are stored separately. The struct
91*d415bd75Srobert   // Section describes only sections' metadata and where to find the
92*d415bd75Srobert   // corresponding content inside the binary.
93*d415bd75Srobert   std::vector<std::unique_ptr<Section>> Sections;
94*d415bd75Srobert 
95*d415bd75Srobert   // Returns the segment name if the load command is a segment command.
96*d415bd75Srobert   std::optional<StringRef> getSegmentName() const;
97*d415bd75Srobert 
98*d415bd75Srobert   // Returns the segment vm address if the load command is a segment command.
99*d415bd75Srobert   std::optional<uint64_t> getSegmentVMAddr() const;
100*d415bd75Srobert };
101*d415bd75Srobert 
102*d415bd75Srobert // A symbol information. Fields which starts with "n_" are same as them in the
103*d415bd75Srobert // nlist.
104*d415bd75Srobert struct SymbolEntry {
105*d415bd75Srobert   std::string Name;
106*d415bd75Srobert   bool Referenced = false;
107*d415bd75Srobert   uint32_t Index;
108*d415bd75Srobert   uint8_t n_type;
109*d415bd75Srobert   uint8_t n_sect;
110*d415bd75Srobert   uint16_t n_desc;
111*d415bd75Srobert   uint64_t n_value;
112*d415bd75Srobert 
isExternalSymbolSymbolEntry113*d415bd75Srobert   bool isExternalSymbol() const { return n_type & MachO::N_EXT; }
114*d415bd75Srobert 
isLocalSymbolSymbolEntry115*d415bd75Srobert   bool isLocalSymbol() const { return !isExternalSymbol(); }
116*d415bd75Srobert 
isUndefinedSymbolSymbolEntry117*d415bd75Srobert   bool isUndefinedSymbol() const {
118*d415bd75Srobert     return (n_type & MachO::N_TYPE) == MachO::N_UNDF;
119*d415bd75Srobert   }
120*d415bd75Srobert 
isSwiftSymbolSymbolEntry121*d415bd75Srobert   bool isSwiftSymbol() const {
122*d415bd75Srobert     return StringRef(Name).startswith("_$s") ||
123*d415bd75Srobert            StringRef(Name).startswith("_$S");
124*d415bd75Srobert   }
125*d415bd75Srobert 
sectionSymbolEntry126*d415bd75Srobert   std::optional<uint32_t> section() const {
127*d415bd75Srobert     return n_sect == MachO::NO_SECT ? std::nullopt
128*d415bd75Srobert                                     : std::optional<uint32_t>(n_sect);
129*d415bd75Srobert   }
130*d415bd75Srobert };
131*d415bd75Srobert 
132*d415bd75Srobert /// The location of the symbol table inside the binary is described by LC_SYMTAB
133*d415bd75Srobert /// load command.
134*d415bd75Srobert struct SymbolTable {
135*d415bd75Srobert   std::vector<std::unique_ptr<SymbolEntry>> Symbols;
136*d415bd75Srobert 
137*d415bd75Srobert   using iterator = pointee_iterator<
138*d415bd75Srobert       std::vector<std::unique_ptr<SymbolEntry>>::const_iterator>;
139*d415bd75Srobert 
beginSymbolTable140*d415bd75Srobert   iterator begin() const { return iterator(Symbols.begin()); }
endSymbolTable141*d415bd75Srobert   iterator end() const { return iterator(Symbols.end()); }
142*d415bd75Srobert 
143*d415bd75Srobert   const SymbolEntry *getSymbolByIndex(uint32_t Index) const;
144*d415bd75Srobert   SymbolEntry *getSymbolByIndex(uint32_t Index);
145*d415bd75Srobert   void removeSymbols(
146*d415bd75Srobert       function_ref<bool(const std::unique_ptr<SymbolEntry> &)> ToRemove);
147*d415bd75Srobert };
148*d415bd75Srobert 
149*d415bd75Srobert struct IndirectSymbolEntry {
150*d415bd75Srobert   // The original value in an indirect symbol table. Higher bits encode extra
151*d415bd75Srobert   // information (INDIRECT_SYMBOL_LOCAL and INDIRECT_SYMBOL_ABS).
152*d415bd75Srobert   uint32_t OriginalIndex;
153*d415bd75Srobert   /// The Symbol referenced by this entry. It's std::nullopt if the index is
154*d415bd75Srobert   /// INDIRECT_SYMBOL_LOCAL or INDIRECT_SYMBOL_ABS.
155*d415bd75Srobert   std::optional<SymbolEntry *> Symbol;
156*d415bd75Srobert 
IndirectSymbolEntryIndirectSymbolEntry157*d415bd75Srobert   IndirectSymbolEntry(uint32_t OriginalIndex,
158*d415bd75Srobert                       std::optional<SymbolEntry *> Symbol)
159*d415bd75Srobert       : OriginalIndex(OriginalIndex), Symbol(Symbol) {}
160*d415bd75Srobert };
161*d415bd75Srobert 
162*d415bd75Srobert struct IndirectSymbolTable {
163*d415bd75Srobert   std::vector<IndirectSymbolEntry> Symbols;
164*d415bd75Srobert };
165*d415bd75Srobert 
166*d415bd75Srobert /// The location of the string table inside the binary is described by LC_SYMTAB
167*d415bd75Srobert /// load command.
168*d415bd75Srobert struct StringTable {
169*d415bd75Srobert   std::vector<std::string> Strings;
170*d415bd75Srobert };
171*d415bd75Srobert 
172*d415bd75Srobert struct RelocationInfo {
173*d415bd75Srobert   // The referenced symbol entry. Set if !Scattered && Extern.
174*d415bd75Srobert   std::optional<const SymbolEntry *> Symbol;
175*d415bd75Srobert   // The referenced section. Set if !Scattered && !Extern.
176*d415bd75Srobert   std::optional<const Section *> Sec;
177*d415bd75Srobert   // True if Info is a scattered_relocation_info.
178*d415bd75Srobert   bool Scattered;
179*d415bd75Srobert   // True if the type is an ADDEND. r_symbolnum holds the addend instead of a
180*d415bd75Srobert   // symbol index.
181*d415bd75Srobert   bool IsAddend;
182*d415bd75Srobert   // True if the r_symbolnum points to a section number (i.e. r_extern=0).
183*d415bd75Srobert   bool Extern;
184*d415bd75Srobert   MachO::any_relocation_info Info;
185*d415bd75Srobert 
getPlainRelocationSymbolNumRelocationInfo186*d415bd75Srobert   unsigned getPlainRelocationSymbolNum(bool IsLittleEndian) {
187*d415bd75Srobert     if (IsLittleEndian)
188*d415bd75Srobert       return Info.r_word1 & 0xffffff;
189*d415bd75Srobert     return Info.r_word1 >> 8;
190*d415bd75Srobert   }
191*d415bd75Srobert 
setPlainRelocationSymbolNumRelocationInfo192*d415bd75Srobert   void setPlainRelocationSymbolNum(unsigned SymbolNum, bool IsLittleEndian) {
193*d415bd75Srobert     assert(SymbolNum < (1 << 24) && "SymbolNum out of range");
194*d415bd75Srobert     if (IsLittleEndian)
195*d415bd75Srobert       Info.r_word1 = (Info.r_word1 & ~0x00ffffff) | SymbolNum;
196*d415bd75Srobert     else
197*d415bd75Srobert       Info.r_word1 = (Info.r_word1 & ~0xffffff00) | (SymbolNum << 8);
198*d415bd75Srobert   }
199*d415bd75Srobert };
200*d415bd75Srobert 
201*d415bd75Srobert /// The location of the rebase info inside the binary is described by
202*d415bd75Srobert /// LC_DYLD_INFO load command. Dyld rebases an image whenever dyld loads it at
203*d415bd75Srobert /// an address different from its preferred address.  The rebase information is
204*d415bd75Srobert /// a stream of byte sized opcodes whose symbolic names start with
205*d415bd75Srobert /// REBASE_OPCODE_. Conceptually the rebase information is a table of tuples:
206*d415bd75Srobert ///   <seg-index, seg-offset, type>
207*d415bd75Srobert /// The opcodes are a compressed way to encode the table by only
208*d415bd75Srobert /// encoding when a column changes.  In addition simple patterns
209*d415bd75Srobert /// like "every n'th offset for m times" can be encoded in a few
210*d415bd75Srobert /// bytes.
211*d415bd75Srobert struct RebaseInfo {
212*d415bd75Srobert   // At the moment we do not parse this info (and it is simply copied over),
213*d415bd75Srobert   // but the proper support will be added later.
214*d415bd75Srobert   ArrayRef<uint8_t> Opcodes;
215*d415bd75Srobert };
216*d415bd75Srobert 
217*d415bd75Srobert /// The location of the bind info inside the binary is described by
218*d415bd75Srobert /// LC_DYLD_INFO load command. Dyld binds an image during the loading process,
219*d415bd75Srobert /// if the image requires any pointers to be initialized to symbols in other
220*d415bd75Srobert /// images. The bind information is a stream of byte sized opcodes whose
221*d415bd75Srobert /// symbolic names start with BIND_OPCODE_. Conceptually the bind information is
222*d415bd75Srobert /// a table of tuples: <seg-index, seg-offset, type, symbol-library-ordinal,
223*d415bd75Srobert /// symbol-name, addend> The opcodes are a compressed way to encode the table by
224*d415bd75Srobert /// only encoding when a column changes.  In addition simple patterns like for
225*d415bd75Srobert /// runs of pointers initialized to the same value can be encoded in a few
226*d415bd75Srobert /// bytes.
227*d415bd75Srobert struct BindInfo {
228*d415bd75Srobert   // At the moment we do not parse this info (and it is simply copied over),
229*d415bd75Srobert   // but the proper support will be added later.
230*d415bd75Srobert   ArrayRef<uint8_t> Opcodes;
231*d415bd75Srobert };
232*d415bd75Srobert 
233*d415bd75Srobert /// The location of the weak bind info inside the binary is described by
234*d415bd75Srobert /// LC_DYLD_INFO load command. Some C++ programs require dyld to unique symbols
235*d415bd75Srobert /// so that all images in the process use the same copy of some code/data. This
236*d415bd75Srobert /// step is done after binding. The content of the weak_bind info is an opcode
237*d415bd75Srobert /// stream like the bind_info.  But it is sorted alphabetically by symbol name.
238*d415bd75Srobert /// This enable dyld to walk all images with weak binding information in order
239*d415bd75Srobert /// and look for collisions.  If there are no collisions, dyld does no updating.
240*d415bd75Srobert /// That means that some fixups are also encoded in the bind_info.  For
241*d415bd75Srobert /// instance, all calls to "operator new" are first bound to libstdc++.dylib
242*d415bd75Srobert /// using the information in bind_info.  Then if some image overrides operator
243*d415bd75Srobert /// new that is detected when the weak_bind information is processed and the
244*d415bd75Srobert /// call to operator new is then rebound.
245*d415bd75Srobert struct WeakBindInfo {
246*d415bd75Srobert   // At the moment we do not parse this info (and it is simply copied over),
247*d415bd75Srobert   // but the proper support will be added later.
248*d415bd75Srobert   ArrayRef<uint8_t> Opcodes;
249*d415bd75Srobert };
250*d415bd75Srobert 
251*d415bd75Srobert /// The location of the lazy bind info inside the binary is described by
252*d415bd75Srobert /// LC_DYLD_INFO load command. Some uses of external symbols do not need to be
253*d415bd75Srobert /// bound immediately. Instead they can be lazily bound on first use.  The
254*d415bd75Srobert /// lazy_bind contains a stream of BIND opcodes to bind all lazy symbols. Normal
255*d415bd75Srobert /// use is that dyld ignores the lazy_bind section when loading an image.
256*d415bd75Srobert /// Instead the static linker arranged for the lazy pointer to initially point
257*d415bd75Srobert /// to a helper function which pushes the offset into the lazy_bind area for the
258*d415bd75Srobert /// symbol needing to be bound, then jumps to dyld which simply adds the offset
259*d415bd75Srobert /// to lazy_bind_off to get the information on what to bind.
260*d415bd75Srobert struct LazyBindInfo {
261*d415bd75Srobert   ArrayRef<uint8_t> Opcodes;
262*d415bd75Srobert };
263*d415bd75Srobert 
264*d415bd75Srobert /// The location of the export info inside the binary is described by
265*d415bd75Srobert /// LC_DYLD_INFO load command. The symbols exported by a dylib are encoded in a
266*d415bd75Srobert /// trie.  This is a compact representation that factors out common prefixes. It
267*d415bd75Srobert /// also reduces LINKEDIT pages in RAM because it encodes all information (name,
268*d415bd75Srobert /// address, flags) in one small, contiguous range. The export area is a stream
269*d415bd75Srobert /// of nodes.  The first node sequentially is the start node for the trie. Nodes
270*d415bd75Srobert /// for a symbol start with a uleb128 that is the length of the exported symbol
271*d415bd75Srobert /// information for the string so far. If there is no exported symbol, the node
272*d415bd75Srobert /// starts with a zero byte. If there is exported info, it follows the length.
273*d415bd75Srobert /// First is a uleb128 containing flags. Normally, it is followed by
274*d415bd75Srobert /// a uleb128 encoded offset which is location of the content named
275*d415bd75Srobert /// by the symbol from the mach_header for the image.  If the flags
276*d415bd75Srobert /// is EXPORT_SYMBOL_FLAGS_REEXPORT, then following the flags is
277*d415bd75Srobert /// a uleb128 encoded library ordinal, then a zero terminated
278*d415bd75Srobert /// UTF8 string.  If the string is zero length, then the symbol
279*d415bd75Srobert /// is re-export from the specified dylib with the same name.
280*d415bd75Srobert /// If the flags is EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER, then following
281*d415bd75Srobert /// the flags is two uleb128s: the stub offset and the resolver offset.
282*d415bd75Srobert /// The stub is used by non-lazy pointers.  The resolver is used
283*d415bd75Srobert /// by lazy pointers and must be called to get the actual address to use.
284*d415bd75Srobert /// After the optional exported symbol information is a byte of
285*d415bd75Srobert /// how many edges (0-255) that this node has leaving it,
286*d415bd75Srobert /// followed by each edge.
287*d415bd75Srobert /// Each edge is a zero terminated UTF8 of the addition chars
288*d415bd75Srobert /// in the symbol, followed by a uleb128 offset for the node that
289*d415bd75Srobert /// edge points to.
290*d415bd75Srobert struct ExportInfo {
291*d415bd75Srobert   ArrayRef<uint8_t> Trie;
292*d415bd75Srobert };
293*d415bd75Srobert 
294*d415bd75Srobert struct LinkData {
295*d415bd75Srobert   ArrayRef<uint8_t> Data;
296*d415bd75Srobert };
297*d415bd75Srobert 
298*d415bd75Srobert struct Object {
299*d415bd75Srobert   MachHeader Header;
300*d415bd75Srobert   std::vector<LoadCommand> LoadCommands;
301*d415bd75Srobert 
302*d415bd75Srobert   SymbolTable SymTable;
303*d415bd75Srobert   StringTable StrTable;
304*d415bd75Srobert 
305*d415bd75Srobert   RebaseInfo Rebases;
306*d415bd75Srobert   BindInfo Binds;
307*d415bd75Srobert   WeakBindInfo WeakBinds;
308*d415bd75Srobert   LazyBindInfo LazyBinds;
309*d415bd75Srobert   ExportInfo Exports;
310*d415bd75Srobert   IndirectSymbolTable IndirectSymTable;
311*d415bd75Srobert   LinkData DataInCode;
312*d415bd75Srobert   LinkData LinkerOptimizationHint;
313*d415bd75Srobert   LinkData FunctionStarts;
314*d415bd75Srobert   LinkData ExportsTrie;
315*d415bd75Srobert   LinkData ChainedFixups;
316*d415bd75Srobert   LinkData DylibCodeSignDRs;
317*d415bd75Srobert 
318*d415bd75Srobert   std::optional<uint32_t> SwiftVersion;
319*d415bd75Srobert 
320*d415bd75Srobert   /// The index of LC_CODE_SIGNATURE load command if present.
321*d415bd75Srobert   std::optional<size_t> CodeSignatureCommandIndex;
322*d415bd75Srobert   /// The index of LC_DYLIB_CODE_SIGN_DRS load command if present.
323*d415bd75Srobert   std::optional<size_t> DylibCodeSignDRsIndex;
324*d415bd75Srobert   /// The index of LC_SYMTAB load command if present.
325*d415bd75Srobert   std::optional<size_t> SymTabCommandIndex;
326*d415bd75Srobert   /// The index of LC_DYLD_INFO or LC_DYLD_INFO_ONLY load command if present.
327*d415bd75Srobert   std::optional<size_t> DyLdInfoCommandIndex;
328*d415bd75Srobert   /// The index LC_DYSYMTAB load command if present.
329*d415bd75Srobert   std::optional<size_t> DySymTabCommandIndex;
330*d415bd75Srobert   /// The index LC_DATA_IN_CODE load command if present.
331*d415bd75Srobert   std::optional<size_t> DataInCodeCommandIndex;
332*d415bd75Srobert   /// The index of LC_LINKER_OPTIMIZATIN_HINT load command if present.
333*d415bd75Srobert   std::optional<size_t> LinkerOptimizationHintCommandIndex;
334*d415bd75Srobert   /// The index LC_FUNCTION_STARTS load command if present.
335*d415bd75Srobert   std::optional<size_t> FunctionStartsCommandIndex;
336*d415bd75Srobert   /// The index LC_DYLD_CHAINED_FIXUPS load command if present.
337*d415bd75Srobert   std::optional<size_t> ChainedFixupsCommandIndex;
338*d415bd75Srobert   /// The index LC_DYLD_EXPORTS_TRIE load command if present.
339*d415bd75Srobert   std::optional<size_t> ExportsTrieCommandIndex;
340*d415bd75Srobert   /// The index of the LC_SEGMENT or LC_SEGMENT_64 load command
341*d415bd75Srobert   /// corresponding to the __TEXT segment.
342*d415bd75Srobert   std::optional<size_t> TextSegmentCommandIndex;
343*d415bd75Srobert 
344*d415bd75Srobert   BumpPtrAllocator Alloc;
345*d415bd75Srobert   StringSaver NewSectionsContents;
346*d415bd75Srobert 
ObjectObject347*d415bd75Srobert   Object() : NewSectionsContents(Alloc) {}
348*d415bd75Srobert 
349*d415bd75Srobert   Error
350*d415bd75Srobert   removeSections(function_ref<bool(const std::unique_ptr<Section> &)> ToRemove);
351*d415bd75Srobert 
352*d415bd75Srobert   Error removeLoadCommands(function_ref<bool(const LoadCommand &)> ToRemove);
353*d415bd75Srobert 
354*d415bd75Srobert   void updateLoadCommandIndexes();
355*d415bd75Srobert 
356*d415bd75Srobert   /// Creates a new segment load command in the object and returns a reference
357*d415bd75Srobert   /// to the newly created load command. The caller should verify that SegName
358*d415bd75Srobert   /// is not too long (SegName.size() should be less than or equal to 16).
359*d415bd75Srobert   LoadCommand &addSegment(StringRef SegName, uint64_t SegVMSize);
360*d415bd75Srobert 
is64BitObject361*d415bd75Srobert   bool is64Bit() const {
362*d415bd75Srobert     return Header.Magic == MachO::MH_MAGIC_64 ||
363*d415bd75Srobert            Header.Magic == MachO::MH_CIGAM_64;
364*d415bd75Srobert   }
365*d415bd75Srobert 
366*d415bd75Srobert   uint64_t nextAvailableSegmentAddress() const;
367*d415bd75Srobert };
368*d415bd75Srobert 
369*d415bd75Srobert } // end namespace macho
370*d415bd75Srobert } // end namespace objcopy
371*d415bd75Srobert } // end namespace llvm
372*d415bd75Srobert 
373*d415bd75Srobert #endif // LLVM_LIB_OBJCOPY_MACHO_MACHOOBJECT_H
374