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