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