LLVM  14.0.0git
MachO.h
Go to the documentation of this file.
1 //===- MachO.h - MachO object file implementation ---------------*- 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 // This file declares the MachOObjectFile class, which implement the ObjectFile
10 // interface for MachO files.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_OBJECT_MACHO_H
15 #define LLVM_OBJECT_MACHO_H
16 
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/SmallString.h"
19 #include "llvm/ADT/SmallVector.h"
20 #include "llvm/ADT/StringExtras.h"
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/ADT/Triple.h"
26 #include "llvm/Object/Binary.h"
27 #include "llvm/Object/ObjectFile.h"
29 #include "llvm/Support/Error.h"
30 #include "llvm/Support/Format.h"
33 #include <cstdint>
34 #include <memory>
35 #include <string>
36 #include <system_error>
37 
38 namespace llvm {
39 namespace object {
40 
41 /// DiceRef - This is a value type class that represents a single
42 /// data in code entry in the table in a Mach-O object file.
43 class DiceRef {
44  DataRefImpl DicePimpl;
45  const ObjectFile *OwningObject = nullptr;
46 
47 public:
48  DiceRef() = default;
49  DiceRef(DataRefImpl DiceP, const ObjectFile *Owner);
50 
51  bool operator==(const DiceRef &Other) const;
52  bool operator<(const DiceRef &Other) const;
53 
54  void moveNext();
55 
56  std::error_code getOffset(uint32_t &Result) const;
57  std::error_code getLength(uint16_t &Result) const;
58  std::error_code getKind(uint16_t &Result) const;
59 
61  const ObjectFile *getObjectFile() const;
62 };
64 
65 /// ExportEntry encapsulates the current-state-of-the-walk used when doing a
66 /// non-recursive walk of the trie data structure. This allows you to iterate
67 /// across all exported symbols using:
68 /// Error Err = Error::success();
69 /// for (const llvm::object::ExportEntry &AnExport : Obj->exports(&Err)) {
70 /// }
71 /// if (Err) { report error ...
72 class ExportEntry {
73 public:
74  ExportEntry(Error *Err, const MachOObjectFile *O, ArrayRef<uint8_t> Trie);
75 
76  StringRef name() const;
77  uint64_t flags() const;
78  uint64_t address() const;
79  uint64_t other() const;
80  StringRef otherName() const;
81  uint32_t nodeOffset() const;
82 
83  bool operator==(const ExportEntry &) const;
84 
85  void moveNext();
86 
87 private:
88  friend class MachOObjectFile;
89 
90  void moveToFirst();
91  void moveToEnd();
92  uint64_t readULEB128(const uint8_t *&p, const char **error);
93  void pushDownUntilBottom();
94  void pushNode(uint64_t Offset);
95 
96  // Represents a node in the mach-o exports trie.
97  struct NodeState {
98  NodeState(const uint8_t *Ptr);
99 
100  const uint8_t *Start;
101  const uint8_t *Current;
102  uint64_t Flags = 0;
103  uint64_t Address = 0;
104  uint64_t Other = 0;
105  const char *ImportName = nullptr;
106  unsigned ChildCount = 0;
107  unsigned NextChildIndex = 0;
108  unsigned ParentStringLength = 0;
109  bool IsExportNode = false;
110  };
112  using node_iterator = NodeList::const_iterator;
113 
114  Error *E;
115  const MachOObjectFile *O;
116  ArrayRef<uint8_t> Trie;
117  SmallString<256> CumulativeString;
118  NodeList Stack;
119  bool Done = false;
120 
121  iterator_range<node_iterator> nodes() const {
122  return make_range(Stack.begin(), Stack.end());
123  }
124 };
126 
127 // Segment info so SegIndex/SegOffset pairs in a Mach-O Bind or Rebase entry
128 // can be checked and translated. Only the SegIndex/SegOffset pairs from
129 // checked entries are to be used with the segmentName(), sectionName() and
130 // address() methods below.
132 public:
134 
135  // Used to check a Mach-O Bind or Rebase entry for errors when iterating.
136  const char* checkSegAndOffsets(int32_t SegIndex, uint64_t SegOffset,
137  uint8_t PointerSize, uint32_t Count=1,
138  uint32_t Skip=0);
139  // Used with valid SegIndex/SegOffset values from checked entries.
140  StringRef segmentName(int32_t SegIndex);
141  StringRef sectionName(int32_t SegIndex, uint64_t SegOffset);
142  uint64_t address(uint32_t SegIndex, uint64_t SegOffset);
143 
144 private:
145  struct SectionInfo {
147  uint64_t Size;
149  StringRef SegmentName;
150  uint64_t OffsetInSegment;
151  uint64_t SegmentStartAddress;
152  int32_t SegmentIndex;
153  };
154  const SectionInfo &findSection(int32_t SegIndex, uint64_t SegOffset);
155 
157  int32_t MaxSegIndex;
158 };
159 
160 /// MachORebaseEntry encapsulates the current state in the decompression of
161 /// rebasing opcodes. This allows you to iterate through the compressed table of
162 /// rebasing using:
163 /// Error Err = Error::success();
164 /// for (const llvm::object::MachORebaseEntry &Entry : Obj->rebaseTable(&Err)) {
165 /// }
166 /// if (Err) { report error ...
168 public:
169  MachORebaseEntry(Error *Err, const MachOObjectFile *O,
170  ArrayRef<uint8_t> opcodes, bool is64Bit);
171 
172  int32_t segmentIndex() const;
173  uint64_t segmentOffset() const;
174  StringRef typeName() const;
175  StringRef segmentName() const;
176  StringRef sectionName() const;
177  uint64_t address() const;
178 
179  bool operator==(const MachORebaseEntry &) const;
180 
181  void moveNext();
182 
183 private:
184  friend class MachOObjectFile;
185 
186  void moveToFirst();
187  void moveToEnd();
188  uint64_t readULEB128(const char **error);
189 
190  Error *E;
191  const MachOObjectFile *O;
192  ArrayRef<uint8_t> Opcodes;
193  const uint8_t *Ptr;
195  int32_t SegmentIndex = -1;
196  uint64_t RemainingLoopCount = 0;
197  uint64_t AdvanceAmount = 0;
198  uint8_t RebaseType = 0;
199  uint8_t PointerSize;
200  bool Done = false;
201 };
203 
204 /// MachOBindEntry encapsulates the current state in the decompression of
205 /// binding opcodes. This allows you to iterate through the compressed table of
206 /// bindings using:
207 /// Error Err = Error::success();
208 /// for (const llvm::object::MachOBindEntry &Entry : Obj->bindTable(&Err)) {
209 /// }
210 /// if (Err) { report error ...
212 public:
213  enum class Kind { Regular, Lazy, Weak };
214 
215  MachOBindEntry(Error *Err, const MachOObjectFile *O,
217 
218  int32_t segmentIndex() const;
219  uint64_t segmentOffset() const;
220  StringRef typeName() const;
221  StringRef symbolName() const;
222  uint32_t flags() const;
223  int64_t addend() const;
224  int ordinal() const;
225 
226  StringRef segmentName() const;
227  StringRef sectionName() const;
228  uint64_t address() const;
229 
230  bool operator==(const MachOBindEntry &) const;
231 
232  void moveNext();
233 
234 private:
235  friend class MachOObjectFile;
236 
237  void moveToFirst();
238  void moveToEnd();
239  uint64_t readULEB128(const char **error);
240  int64_t readSLEB128(const char **error);
241 
242  Error *E;
243  const MachOObjectFile *O;
244  ArrayRef<uint8_t> Opcodes;
245  const uint8_t *Ptr;
247  int32_t SegmentIndex = -1;
249  bool LibraryOrdinalSet = false;
250  int Ordinal = 0;
251  uint32_t Flags = 0;
252  int64_t Addend = 0;
253  uint64_t RemainingLoopCount = 0;
254  uint64_t AdvanceAmount = 0;
255  uint8_t BindType = 0;
256  uint8_t PointerSize;
257  Kind TableKind;
258  bool Done = false;
259 };
261 
262 class MachOObjectFile : public ObjectFile {
263 public:
265  const char *Ptr; // Where in memory the load command is.
266  MachO::load_command C; // The command itself.
267  };
270 
272  create(MemoryBufferRef Object, bool IsLittleEndian, bool Is64Bits,
273  uint32_t UniversalCputype = 0, uint32_t UniversalIndex = 0);
274 
275  void moveSymbolNext(DataRefImpl &Symb) const override;
276 
277  uint64_t getNValue(DataRefImpl Sym) const;
278  Expected<StringRef> getSymbolName(DataRefImpl Symb) const override;
279 
280  // MachO specific.
281  Error checkSymbolTable() const;
282 
283  std::error_code getIndirectName(DataRefImpl Symb, StringRef &Res) const;
284  unsigned getSectionType(SectionRef Sec) const;
285 
286  Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const override;
287  uint32_t getSymbolAlignment(DataRefImpl Symb) const override;
288  uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;
290  Expected<uint32_t> getSymbolFlags(DataRefImpl Symb) const override;
292  unsigned getSymbolSectionID(SymbolRef Symb) const;
293  unsigned getSectionID(SectionRef Sec) const;
294 
295  void moveSectionNext(DataRefImpl &Sec) const override;
296  Expected<StringRef> getSectionName(DataRefImpl Sec) const override;
297  uint64_t getSectionAddress(DataRefImpl Sec) const override;
298  uint64_t getSectionIndex(DataRefImpl Sec) const override;
299  uint64_t getSectionSize(DataRefImpl Sec) const override;
302  getSectionContents(DataRefImpl Sec) const override;
303  uint64_t getSectionAlignment(DataRefImpl Sec) const override;
304  Expected<SectionRef> getSection(unsigned SectionIndex) const;
306  bool isSectionCompressed(DataRefImpl Sec) const override;
307  bool isSectionText(DataRefImpl Sec) const override;
308  bool isSectionData(DataRefImpl Sec) const override;
309  bool isSectionBSS(DataRefImpl Sec) const override;
310  bool isSectionVirtual(DataRefImpl Sec) const override;
311  bool isSectionBitcode(DataRefImpl Sec) const override;
312  bool isDebugSection(DataRefImpl Sec) const override;
313 
314  /// When dsymutil generates the companion file, it strips all unnecessary
315  /// sections (e.g. everything in the _TEXT segment) by omitting their body
316  /// and setting the offset in their corresponding load command to zero.
317  ///
318  /// While the load command itself is valid, reading the section corresponds
319  /// to reading the number of bytes specified in the load command, starting
320  /// from offset 0 (i.e. the Mach-O header at the beginning of the file).
321  bool isSectionStripped(DataRefImpl Sec) const override;
322 
324  relocation_iterator section_rel_end(DataRefImpl Sec) const override;
325 
329  return make_range(extrel_begin(), extrel_end());
330  }
331 
334 
335  void moveRelocationNext(DataRefImpl &Rel) const override;
336  uint64_t getRelocationOffset(DataRefImpl Rel) const override;
337  symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
339  uint64_t getRelocationType(DataRefImpl Rel) const override;
341  SmallVectorImpl<char> &Result) const override;
342  uint8_t getRelocationLength(DataRefImpl Rel) const;
343 
344  // MachO specific.
345  std::error_code getLibraryShortNameByIndex(unsigned Index, StringRef &) const;
346  uint32_t getLibraryCount() const;
347 
349 
350  // TODO: Would be useful to have an iterator based version
351  // of the load command interface too.
352 
353  basic_symbol_iterator symbol_begin() const override;
354  basic_symbol_iterator symbol_end() const override;
355 
356  // MachO specific.
357  symbol_iterator getSymbolByIndex(unsigned Index) const;
358  uint64_t getSymbolIndex(DataRefImpl Symb) const;
359 
360  section_iterator section_begin() const override;
361  section_iterator section_end() const override;
362 
363  uint8_t getBytesInAddress() const override;
364 
365  StringRef getFileFormatName() const override;
366  Triple::ArchType getArch() const override;
367  SubtargetFeatures getFeatures() const override { return SubtargetFeatures(); }
368  Triple getArchTriple(const char **McpuDefault = nullptr) const;
369 
371  relocation_iterator section_rel_end(unsigned Index) const;
372 
373  dice_iterator begin_dices() const;
374  dice_iterator end_dices() const;
375 
379 
380  /// For use iterating over all exported symbols.
382 
383  /// For use examining a trie not in a MachOObjectFile.
385  ArrayRef<uint8_t> Trie,
386  const MachOObjectFile *O =
387  nullptr);
388 
389  /// For use iterating over all rebase table entries.
391 
392  /// For use examining rebase opcodes in a MachOObjectFile.
395  ArrayRef<uint8_t> Opcodes,
396  bool is64);
397 
398  /// For use iterating over all bind table entries.
400 
401  /// For use iterating over all lazy bind table entries.
403 
404  /// For use iterating over all weak bind table entries.
406 
407  /// For use examining bind opcodes in a MachOObjectFile.
410  ArrayRef<uint8_t> Opcodes,
411  bool is64,
413 
414  // Given a SegIndex, SegOffset, and PointerSize, verify a valid section exists
415  // that fully contains a pointer at that location. Multiple fixups in a bind
416  // (such as with the BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB opcode) can
417  // be tested via the Count and Skip parameters.
418  //
419  // This is used by MachOBindEntry::moveNext() to validate a MachOBindEntry.
420  const char *BindEntryCheckSegAndOffsets(int32_t SegIndex, uint64_t SegOffset,
421  uint8_t PointerSize, uint32_t Count=1,
422  uint32_t Skip=0) const {
423  return BindRebaseSectionTable->checkSegAndOffsets(SegIndex, SegOffset,
424  PointerSize, Count, Skip);
425  }
426 
427  // Given a SegIndex, SegOffset, and PointerSize, verify a valid section exists
428  // that fully contains a pointer at that location. Multiple fixups in a rebase
429  // (such as with the REBASE_OPCODE_DO_*_TIMES* opcodes) can be tested via the
430  // Count and Skip parameters.
431  //
432  // This is used by MachORebaseEntry::moveNext() to validate a MachORebaseEntry
433  const char *RebaseEntryCheckSegAndOffsets(int32_t SegIndex,
434  uint64_t SegOffset,
435  uint8_t PointerSize,
436  uint32_t Count=1,
437  uint32_t Skip=0) const {
438  return BindRebaseSectionTable->checkSegAndOffsets(SegIndex, SegOffset,
439  PointerSize, Count, Skip);
440  }
441 
442  /// For use with the SegIndex of a checked Mach-O Bind or Rebase entry to
443  /// get the segment name.
444  StringRef BindRebaseSegmentName(int32_t SegIndex) const {
445  return BindRebaseSectionTable->segmentName(SegIndex);
446  }
447 
448  /// For use with a SegIndex,SegOffset pair from a checked Mach-O Bind or
449  /// Rebase entry to get the section name.
450  StringRef BindRebaseSectionName(uint32_t SegIndex, uint64_t SegOffset) const {
451  return BindRebaseSectionTable->sectionName(SegIndex, SegOffset);
452  }
453 
454  /// For use with a SegIndex,SegOffset pair from a checked Mach-O Bind or
455  /// Rebase entry to get the address.
456  uint64_t BindRebaseAddress(uint32_t SegIndex, uint64_t SegOffset) const {
457  return BindRebaseSectionTable->address(SegIndex, SegOffset);
458  }
459 
460  // In a MachO file, sections have a segment name. This is used in the .o
461  // files. They have a single segment, but this field specifies which segment
462  // a section should be put in the final object.
464 
465  // Names are stored as 16 bytes. These returns the raw 16 bytes without
466  // interpreting them as a C string.
469 
470  // MachO specific Info about relocations.
473  const MachO::any_relocation_info &RE) const;
476  const MachO::any_relocation_info &RE) const;
478  const MachO::any_relocation_info &RE) const;
480  const MachO::any_relocation_info &RE) const;
481  unsigned getAnyRelocationAddress(const MachO::any_relocation_info &RE) const;
482  unsigned getAnyRelocationPCRel(const MachO::any_relocation_info &RE) const;
483  unsigned getAnyRelocationLength(const MachO::any_relocation_info &RE) const;
484  unsigned getAnyRelocationType(const MachO::any_relocation_info &RE) const;
486 
487  // MachO specific structures.
490  MachO::section getSection(const LoadCommandInfo &L, unsigned Index) const;
491  MachO::section_64 getSection64(const LoadCommandInfo &L,unsigned Index) const;
494 
496  getLinkeditDataLoadCommand(const LoadCommandInfo &L) const;
498  getSegmentLoadCommand(const LoadCommandInfo &L) const;
500  getSegment64LoadCommand(const LoadCommandInfo &L) const;
502  getLinkerOptionLoadCommand(const LoadCommandInfo &L) const;
504  getVersionMinLoadCommand(const LoadCommandInfo &L) const;
506  getNoteLoadCommand(const LoadCommandInfo &L) const;
508  getBuildVersionLoadCommand(const LoadCommandInfo &L) const;
510  getBuildToolVersion(unsigned index) const;
512  getDylibIDLoadCommand(const LoadCommandInfo &L) const;
514  getDyldInfoLoadCommand(const LoadCommandInfo &L) const;
516  getDylinkerCommand(const LoadCommandInfo &L) const;
518  getUuidCommand(const LoadCommandInfo &L) const;
520  getRpathCommand(const LoadCommandInfo &L) const;
522  getSourceVersionCommand(const LoadCommandInfo &L) const;
524  getEntryPointCommand(const LoadCommandInfo &L) const;
526  getEncryptionInfoCommand(const LoadCommandInfo &L) const;
528  getEncryptionInfoCommand64(const LoadCommandInfo &L) const;
530  getSubFrameworkCommand(const LoadCommandInfo &L) const;
532  getSubUmbrellaCommand(const LoadCommandInfo &L) const;
534  getSubLibraryCommand(const LoadCommandInfo &L) const;
536  getSubClientCommand(const LoadCommandInfo &L) const;
538  getRoutinesCommand(const LoadCommandInfo &L) const;
540  getRoutinesCommand64(const LoadCommandInfo &L) const;
542  getThreadCommand(const LoadCommandInfo &L) const;
543 
546  const MachO::mach_header &getHeader() const;
547  const MachO::mach_header_64 &getHeader64() const;
548  uint32_t
550  unsigned Index) const;
552  unsigned Index) const;
562  ArrayRef<uint8_t> getUuid() const;
563 
565  bool is64Bit() const;
567 
568  static StringRef guessLibraryShortName(StringRef Name, bool &isFramework,
569  StringRef &Suffix);
570 
571  static Triple::ArchType getArch(uint32_t CPUType, uint32_t CPUSubType);
572  static Triple getArchTriple(uint32_t CPUType, uint32_t CPUSubType,
573  const char **McpuDefault = nullptr,
574  const char **ArchFlag = nullptr);
575  static bool isValidArch(StringRef ArchFlag);
577  static Triple getHostArch();
578 
579  bool isRelocatableObject() const override;
580 
582 
583  bool hasPageZeroSegment() const { return HasPageZeroSegment; }
584 
585  static bool classof(const Binary *v) {
586  return v->isMachO();
587  }
588 
589  static uint32_t
591  uint32_t VersionOrSDK = (SDK) ? C.sdk : C.version;
592  return (VersionOrSDK >> 16) & 0xffff;
593  }
594 
595  static uint32_t
597  uint32_t VersionOrSDK = (SDK) ? C.sdk : C.version;
598  return (VersionOrSDK >> 8) & 0xff;
599  }
600 
601  static uint32_t
603  uint32_t VersionOrSDK = (SDK) ? C.sdk : C.version;
604  return VersionOrSDK & 0xff;
605  }
606 
607  static std::string getBuildPlatform(uint32_t platform) {
608  switch (platform) {
609  case MachO::PLATFORM_MACOS: return "macos";
610  case MachO::PLATFORM_IOS: return "ios";
611  case MachO::PLATFORM_TVOS: return "tvos";
612  case MachO::PLATFORM_WATCHOS: return "watchos";
613  case MachO::PLATFORM_BRIDGEOS: return "bridgeos";
614  case MachO::PLATFORM_MACCATALYST: return "macCatalyst";
615  case MachO::PLATFORM_IOSSIMULATOR: return "iossimulator";
616  case MachO::PLATFORM_TVOSSIMULATOR: return "tvossimulator";
617  case MachO::PLATFORM_WATCHOSSIMULATOR: return "watchossimulator";
618  case MachO::PLATFORM_DRIVERKIT: return "driverkit";
619  default:
620  std::string ret;
622  ss << format_hex(platform, 8, true);
623  return ss.str();
624  }
625  }
626 
627  static std::string getBuildTool(uint32_t tools) {
628  switch (tools) {
629  case MachO::TOOL_CLANG: return "clang";
630  case MachO::TOOL_SWIFT: return "swift";
631  case MachO::TOOL_LD: return "ld";
632  default:
633  std::string ret;
635  ss << format_hex(tools, 8, true);
636  return ss.str();
637  }
638  }
639 
640  static std::string getVersionString(uint32_t version) {
641  uint32_t major = (version >> 16) & 0xffff;
642  uint32_t minor = (version >> 8) & 0xff;
643  uint32_t update = version & 0xff;
644 
646  Version = utostr(major) + "." + utostr(minor);
647  if (update != 0)
648  Version += "." + utostr(update);
649  return std::string(std::string(Version.str()));
650  }
651 
652 private:
653  MachOObjectFile(MemoryBufferRef Object, bool IsLittleEndian, bool Is64Bits,
654  Error &Err, uint32_t UniversalCputype = 0,
655  uint32_t UniversalIndex = 0);
656 
657  uint64_t getSymbolValueImpl(DataRefImpl Symb) const override;
658 
659  union {
662  };
663  using SectionList = SmallVector<const char*, 1>;
664  SectionList Sections;
665  using LibraryList = SmallVector<const char*, 1>;
666  LibraryList Libraries;
667  LoadCommandList LoadCommands;
668  using LibraryShortName = SmallVector<StringRef, 1>;
669  using BuildToolList = SmallVector<const char*, 1>;
670  BuildToolList BuildTools;
671  mutable LibraryShortName LibrariesShortNames;
672  std::unique_ptr<BindRebaseSegInfo> BindRebaseSectionTable;
673  const char *SymtabLoadCmd = nullptr;
674  const char *DysymtabLoadCmd = nullptr;
675  const char *DataInCodeLoadCmd = nullptr;
676  const char *LinkOptHintsLoadCmd = nullptr;
677  const char *DyldInfoLoadCmd = nullptr;
678  const char *UuidLoadCmd = nullptr;
679  bool HasPageZeroSegment = false;
680 };
681 
682 /// DiceRef
683 inline DiceRef::DiceRef(DataRefImpl DiceP, const ObjectFile *Owner)
684  : DicePimpl(DiceP) , OwningObject(Owner) {}
685 
686 inline bool DiceRef::operator==(const DiceRef &Other) const {
687  return DicePimpl == Other.DicePimpl;
688 }
689 
690 inline bool DiceRef::operator<(const DiceRef &Other) const {
691  return DicePimpl < Other.DicePimpl;
692 }
693 
694 inline void DiceRef::moveNext() {
696  reinterpret_cast<const MachO::data_in_code_entry *>(DicePimpl.p);
697  DicePimpl.p = reinterpret_cast<uintptr_t>(P + 1);
698 }
699 
700 // Since a Mach-O data in code reference, a DiceRef, can only be created when
701 // the OwningObject ObjectFile is a MachOObjectFile a static_cast<> is used for
702 // the methods that get the values of the fields of the reference.
703 
704 inline std::error_code DiceRef::getOffset(uint32_t &Result) const {
705  const MachOObjectFile *MachOOF =
706  static_cast<const MachOObjectFile *>(OwningObject);
707  MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl);
708  Result = Dice.offset;
709  return std::error_code();
710 }
711 
712 inline std::error_code DiceRef::getLength(uint16_t &Result) const {
713  const MachOObjectFile *MachOOF =
714  static_cast<const MachOObjectFile *>(OwningObject);
715  MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl);
716  Result = Dice.length;
717  return std::error_code();
718 }
719 
720 inline std::error_code DiceRef::getKind(uint16_t &Result) const {
721  const MachOObjectFile *MachOOF =
722  static_cast<const MachOObjectFile *>(OwningObject);
723  MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl);
724  Result = Dice.kind;
725  return std::error_code();
726 }
727 
729  return DicePimpl;
730 }
731 
732 inline const ObjectFile *DiceRef::getObjectFile() const {
733  return OwningObject;
734 }
735 
737 public:
738  uint32_t getRawSize() const;
739  uint32_t getSize() const;
740 
741  static constexpr int Align = 16;
742  static constexpr uint8_t BlockSizeShift = 12;
743  static constexpr size_t BlockSize = (1 << BlockSizeShift); // 4 KiB
744  static constexpr size_t HashSize = 256 / 8;
745  static constexpr size_t BlobHeadersSize =
746  alignTo<8>(sizeof(MachO::CS_SuperBlob) + sizeof(MachO::CS_BlobIndex));
747  static constexpr uint32_t FixedHeadersSize =
749 
750  CodeSignatureSection(uint64_t FileOff, StringRef OutputFilePath,
752  uint64_t TextSegmentFileOff,
753  uint64_t TextSegmentFileSize);
754 
755  void write(uint8_t *Buf) const;
756 
757 private:
758  uint32_t getAllHeadersSize() const;
759  uint32_t getBlockCount() const;
760  uint32_t getFileNamePad() const;
761 
762  StringRef stripOutputFilePath(const StringRef OutputFilePath);
763 
764  // FileOff is the offset relative to the start of the file
765  // used to access the start of code signature section
766  // in __LINKEDIT segment
767  uint64_t FileOff;
768  StringRef OutputFileName;
770  uint64_t TextSegmentFileOff;
771  uint64_t TextSegmentFileSize;
772 };
773 
774 } // end namespace object
775 } // end namespace llvm
776 
777 #endif // LLVM_OBJECT_MACHO_H
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::object::MachOObjectFile::getRelocationSymbol
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override
Definition: MachOObjectFile.cpp:2146
llvm::MachO::sub_library_command
Definition: MachO.h:641
MemoryBuffer.h
llvm::object::MachOObjectFile::getSubUmbrellaCommand
MachO::sub_umbrella_command getSubUmbrellaCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4394
llvm::object::MachOObjectFile::getPlainRelocationExternal
bool getPlainRelocationExternal(const MachO::any_relocation_info &RE) const
Definition: MachOObjectFile.cpp:4205
llvm::MachO::section
Definition: MachO.h:563
llvm::object::MachOObjectFile::getVersionString
static std::string getVersionString(uint32_t version)
Definition: MachO.h:640
llvm::object::ExportEntry::nodeOffset
uint32_t nodeOffset() const
Definition: MachOObjectFile.cpp:2889
llvm::object::MachOObjectFile::getStringTableData
StringRef getStringTableData() const
Definition: MachOObjectFile.cpp:4630
llvm::MachO::PLATFORM_MACOS
@ PLATFORM_MACOS
Definition: MachO.h:492
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::OutputFileType
OutputFileType
Definition: DWARFStreamer.h:24
llvm::MachO::PLATFORM_WATCHOSSIMULATOR
@ PLATFORM_WATCHOSSIMULATOR
Definition: MachO.h:500
llvm::object::MachORebaseEntry::address
uint64_t address() const
Definition: MachOObjectFile.cpp:3449
llvm::object::MachOObjectFile::getVersionMinMajor
static uint32_t getVersionMinMajor(MachO::version_min_command &C, bool SDK)
Definition: MachO.h:590
llvm::MachO::any_relocation_info
Definition: MachO.h:975
llvm::make_range
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Definition: iterator_range.h:53
llvm::MachO::sub_umbrella_command
Definition: MachO.h:635
llvm::MachO::data_in_code_entry::length
uint16_t length
Definition: MachO.h:807
llvm::MachO::data_in_code_entry::kind
uint16_t kind
Definition: MachO.h:808
llvm::object::CodeSignatureSection::CodeSignatureSection
CodeSignatureSection(uint64_t FileOff, StringRef OutputFilePath, MachO::HeaderFileType OutputFileType, uint64_t TextSegmentFileOff, uint64_t TextSegmentFileSize)
Definition: CodeSignatureSection.cpp:30
llvm::object::MachOObjectFile::getUuidCommand
MachO::uuid_command getUuidCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4359
llvm::object::MachOObjectFile::getSourceVersionCommand
MachO::source_version_command getSourceVersionCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4369
llvm::MachO::TOOL_LD
@ TOOL_LD
Definition: MachO.h:505
llvm::object::MachOObjectFile::getRelocationLength
uint8_t getRelocationLength(DataRefImpl Rel) const
Definition: MachOObjectFile.cpp:2286
return
return
Definition: README.txt:242
llvm::object::MachOBindEntry::flags
uint32_t flags() const
Definition: MachOObjectFile.cpp:3983
StringRef.h
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::MachO::nlist
Definition: MachO.h:987
is64Bit
static bool is64Bit(const char *name)
Definition: X86Disassembler.cpp:1023
llvm::object::MachOObjectFile::ReadULEB128s
void ReadULEB128s(uint64_t Index, SmallVectorImpl< uint64_t > &Out) const
Definition: MachOObjectFile.cpp:4640
llvm::object::MachOObjectFile::getRelocationRelocatedSection
section_iterator getRelocationRelocatedSection(relocation_iterator Rel) const
Definition: MachOObjectFile.cpp:2492
llvm::raw_string_ostream
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:625
llvm::object::MachOObjectFile::getSectionIndex
uint64_t getSectionIndex(DataRefImpl Sec) const override
Definition: MachOObjectFile.cpp:1923
llvm::object::MachOObjectFile::getSectionSize
uint64_t getSectionSize(DataRefImpl Sec) const override
Definition: MachOObjectFile.cpp:1927
llvm::SmallVector< NodeState, 16 >
llvm::object::MachOBindEntry::typeName
StringRef typeName() const
Definition: MachOObjectFile.cpp:3967
llvm::object::BindRebaseSegInfo::sectionName
StringRef sectionName(int32_t SegIndex, uint64_t SegOffset)
Definition: MachOObjectFile.cpp:4111
llvm::object::MachOBindEntry::moveNext
void moveNext()
Definition: MachOObjectFile.cpp:3498
llvm::object::CodeSignatureSection
Definition: MachO.h:736
tools
The object format emitted by the WebAssembly backed is documented see the home tools
Definition: README.txt:16
llvm::object::MachOBindEntry::segmentName
StringRef segmentName() const
Definition: MachOObjectFile.cpp:3989
llvm::object::MachOObjectFile::isSectionText
bool isSectionText(DataRefImpl Sec) const override
Definition: MachOObjectFile.cpp:2016
llvm::object::MachOObjectFile::getSegmentLoadCommand
MachO::segment_command getSegmentLoadCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4309
llvm::MachO::rpath_command
Definition: MachO.h:792
llvm::object::MachOObjectFile::getRoutinesCommand
MachO::routines_command getRoutinesCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4409
Error.h
llvm::object::MachOObjectFile::weakBindTable
iterator_range< bind_iterator > weakBindTable(Error &Err)
For use iterating over all weak bind table entries.
Definition: MachOObjectFile.cpp:4148
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
llvm::MachO::PLATFORM_IOS
@ PLATFORM_IOS
Definition: MachO.h:493
llvm::MachO::sub_framework_command
Definition: MachO.h:623
llvm::MachO::data_in_code_entry::offset
uint32_t offset
Definition: MachO.h:806
llvm::object::MachOObjectFile::isValidArch
static bool isValidArch(StringRef ArchFlag)
Definition: MachOObjectFile.cpp:2752
llvm::object::DiceRef::moveNext
void moveNext()
Definition: MachO.h:694
llvm::MachO::TOOL_CLANG
@ TOOL_CLANG
Definition: MachO.h:505
llvm::object::MachOObjectFile::LoadCommandInfo
Definition: MachO.h:264
llvm::object::MachOObjectFile::locrel_begin
relocation_iterator locrel_begin() const
Definition: MachOObjectFile.cpp:2116
llvm::object::MachORebaseEntry::operator==
bool operator==(const MachORebaseEntry &) const
Definition: MachOObjectFile.cpp:3453
llvm::object::MachOObjectFile::BindRebaseAddress
uint64_t BindRebaseAddress(uint32_t SegIndex, uint64_t SegOffset) const
For use with a SegIndex,SegOffset pair from a checked Mach-O Bind or Rebase entry to get the address.
Definition: MachO.h:456
llvm::MachO::PLATFORM_MACCATALYST
@ PLATFORM_MACCATALYST
Definition: MachO.h:497
llvm::object::MachOObjectFile::getAnyRelocationAddress
unsigned getAnyRelocationAddress(const MachO::any_relocation_info &RE) const
Definition: MachOObjectFile.cpp:4227
llvm::MachO::symtab_command
Definition: MachO.h:693
llvm::MachO::build_version_command
Definition: MachO.h:855
llvm::object::MachOBindEntry::segmentOffset
uint64_t segmentOffset() const
Definition: MachOObjectFile.cpp:3965
llvm::object::MachOObjectFile::checkSymbolTable
Error checkSymbolTable() const
Definition: MachOObjectFile.cpp:1680
llvm::object::MachOObjectFile::BindRebaseSegmentName
StringRef BindRebaseSegmentName(int32_t SegIndex) const
For use with the SegIndex of a checked Mach-O Bind or Rebase entry to get the segment name.
Definition: MachO.h:444
llvm::object::MachOObjectFile::getSectionRawName
ArrayRef< char > getSectionRawName(DataRefImpl Sec) const
Definition: MachOObjectFile.cpp:4175
llvm::object::MachOObjectFile::getDyldInfoLoadCommand
MachO::dyld_info_command getDyldInfoLoadCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4349
llvm::object::MachOObjectFile::getAnyRelocationPCRel
unsigned getAnyRelocationPCRel(const MachO::any_relocation_info &RE) const
Definition: MachOObjectFile.cpp:4234
llvm::MachO::CPUType
CPUType
Definition: MachO.h:1418
error
#define error(X)
Definition: SymbolRecordMapping.cpp:14
llvm::object::MachOObjectFile::getBuildPlatform
static std::string getBuildPlatform(uint32_t platform)
Definition: MachO.h:607
ret
to esp esp setne al movzbw ax esp setg cl movzbw cx cmove cx cl jne LBB1_2 esp ret(also really horrible code on ppc). This is due to the expand code for 64-bit compares. GCC produces multiple branches
llvm::object::MachOObjectFile::load_command_iterator
LoadCommandList::const_iterator load_command_iterator
Definition: MachO.h:269
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::object::MachOObjectFile::isSectionStripped
bool isSectionStripped(DataRefImpl Sec) const override
When dsymutil generates the companion file, it strips all unnecessary sections (e....
Definition: MachOObjectFile.cpp:2069
llvm::object::MachOObjectFile::mapDebugSectionName
StringRef mapDebugSectionName(StringRef Name) const override
Maps a debug section name to a standard DWARF section name.
Definition: MachOObjectFile.cpp:4677
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
llvm::object::MachOObjectFile::getBuildVersionLoadCommand
MachO::build_version_command getBuildVersionLoadCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4334
llvm::object::MachOObjectFile::getRelocationSection
section_iterator getRelocationSection(DataRefImpl Rel) const
Definition: MachOObjectFile.cpp:2167
SymbolicFile.h
llvm::object::ExportEntry
ExportEntry encapsulates the current-state-of-the-walk used when doing a non-recursive walk of the tr...
Definition: MachO.h:72
Format.h
llvm::MachO::TOOL_SWIFT
@ TOOL_SWIFT
Definition: MachO.h:505
llvm::object::MachOObjectFile::getSymbolByIndex
symbol_iterator getSymbolByIndex(unsigned Index) const
Definition: MachOObjectFile.cpp:2522
llvm::object::MachOObjectFile::rebaseTable
iterator_range< rebase_iterator > rebaseTable(Error &Err)
For use iterating over all rebase table entries.
Definition: MachOObjectFile.cpp:3478
llvm::object::MachOObjectFile::classof
static bool classof(const Binary *v)
Definition: MachO.h:585
llvm::object::DiceRef::operator==
bool operator==(const DiceRef &Other) const
Definition: MachO.h:686
p
the resulting code requires compare and branches when and if * p
Definition: README.txt:396
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
llvm::object::MachOObjectFile::getSymbolIndex
uint64_t getSymbolIndex(DataRefImpl Symb) const
Definition: MachOObjectFile.cpp:2534
llvm::MachO::thread_command
Definition: MachO.h:662
llvm::object::MachOObjectFile::getSection
Expected< SectionRef > getSection(unsigned SectionIndex) const
Definition: MachOObjectFile.cpp:1992
llvm::MachO::uuid_command
Definition: MachO.h:786
llvm::object::MachOObjectFile::getDylibIDLoadCommand
MachO::dylib_command getDylibIDLoadCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4344
llvm::MachO::PLATFORM_IOSSIMULATOR
@ PLATFORM_IOSSIMULATOR
Definition: MachO.h:498
llvm::object::MachOObjectFile::symbol_end
basic_symbol_iterator symbol_end() const override
Definition: MachOObjectFile.cpp:2507
llvm::MachO::dyld_info_command
Definition: MachO.h:865
llvm::object::MachOObjectFile::getIndirectSymbolTableEntry
uint32_t getIndirectSymbolTableEntry(const MachO::dysymtab_command &DLC, unsigned Index) const
Definition: MachOObjectFile.cpp:4465
llvm::object::MachOObjectFile::getSectionContents
ArrayRef< uint8_t > getSectionContents(uint32_t Offset, uint64_t Size) const
Definition: MachOObjectFile.cpp:1956
llvm::object::MachOBindEntry::sectionName
StringRef sectionName() const
Definition: MachOObjectFile.cpp:3995
readULEB128
static uint64_t readULEB128(WasmObjectFile::ReadContext &Ctx)
Definition: WasmObjectFile.cpp:104
llvm::object::MachOObjectFile::getSectionAlignment
uint64_t getSectionAlignment(DataRefImpl Sec) const override
Definition: MachOObjectFile.cpp:1979
llvm::object::MachOObjectFile::getLinkOptHintsLoadCommand
MachO::linkedit_data_command getLinkOptHintsLoadCommand() const
Definition: MachOObjectFile.cpp:4538
llvm::MachO::data_in_code_entry
Definition: MachO.h:805
llvm::MachO::sub_client_command
Definition: MachO.h:629
llvm::object::MachOObjectFile::getSubFrameworkCommand
MachO::sub_framework_command getSubFrameworkCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4389
llvm::object::MachOObjectFile::getScatteredRelocationType
uint32_t getScatteredRelocationType(const MachO::any_relocation_info &RE) const
Definition: MachOObjectFile.cpp:4222
SubtargetFeature.h
llvm::object::MachOObjectFile::getSymbolAddress
Expected< uint64_t > getSymbolAddress(DataRefImpl Symb) const override
Definition: MachOObjectFile.cpp:1804
llvm::object::MachOObjectFile::getDysymtabLoadCommand
MachO::dysymtab_command getDysymtabLoadCommand() const
Definition: MachOObjectFile.cpp:4494
llvm::object::MachOObjectFile::getRpathCommand
MachO::rpath_command getRpathCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4364
llvm::Triple::ArchType
ArchType
Definition: Triple.h:47
llvm::MachO::routines_command
Definition: MachO.h:667
llvm::object::MachOObjectFile::getVersionMinLoadCommand
MachO::version_min_command getVersionMinLoadCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4324
llvm::object::BindRebaseSegInfo::checkSegAndOffsets
const char * checkSegAndOffsets(int32_t SegIndex, uint64_t SegOffset, uint8_t PointerSize, uint32_t Count=1, uint32_t Skip=0)
Definition: MachOObjectFile.cpp:4052
SmallString.h
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::object::MachOObjectFile::isSectionCompressed
bool isSectionCompressed(DataRefImpl Sec) const override
Definition: MachOObjectFile.cpp:2012
llvm::object::MachORebaseEntry::sectionName
StringRef sectionName() const
Definition: MachOObjectFile.cpp:3443
llvm::object::CodeSignatureSection::getSize
uint32_t getSize() const
Definition: CodeSignatureSection.cpp:64
llvm::AMDGPU::CPol::DLC
@ DLC
Definition: SIDefines.h:291
llvm::object::MachOObjectFile::getLinkeditDataLoadCommand
MachO::linkedit_data_command getLinkeditDataLoadCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4304
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::object::MachOObjectFile::LoadCommandInfo::C
MachO::load_command C
Definition: MachO.h:266
llvm::object::MachOObjectFile::getBuildTool
static std::string getBuildTool(uint32_t tools)
Definition: MachO.h:627
llvm::object::MachOObjectFile::getBuildToolVersion
MachO::build_tool_version getBuildToolVersion(unsigned index) const
Definition: MachOObjectFile.cpp:4339
llvm::MachO::CS_BlobIndex
Definition: MachO.h:2185
llvm::object::MachOObjectFile::getUuid
ArrayRef< uint8_t > getUuid() const
Definition: MachOObjectFile.cpp:4622
llvm::object::MachOObjectFile::getDyldInfoLazyBindOpcodes
ArrayRef< uint8_t > getDyldInfoLazyBindOpcodes() const
Definition: MachOObjectFile.cpp:4594
llvm::SubtargetFeatures
Manages the enabling and disabling of subtarget specific features.
Definition: SubtargetFeature.h:183
llvm::object::MachOObjectFile::getRelocation
MachO::any_relocation_info getRelocation(DataRefImpl Rel) const
Definition: MachOObjectFile.cpp:4424
llvm::MachO::source_version_command
Definition: MachO.h:811
NodeList
Definition: MicrosoftDemangle.cpp:37
llvm::object::DiceRef::getLength
std::error_code getLength(uint16_t &Result) const
Definition: MachO.h:712
llvm::object::MachOObjectFile::getRelocationOffset
uint64_t getRelocationOffset(DataRefImpl Rel) const override
Definition: MachOObjectFile.cpp:2137
llvm::MachO::linkedit_data_command
Definition: MachO.h:798
llvm::object::MachOBindEntry::operator==
bool operator==(const MachOBindEntry &) const
Definition: MachOObjectFile.cpp:4005
llvm::object::DiceRef::getObjectFile
const ObjectFile * getObjectFile() const
Definition: MachO.h:732
llvm::object::MachOObjectFile::getSymbolSectionID
unsigned getSymbolSectionID(SymbolRef Symb) const
Definition: MachOObjectFile.cpp:1902
llvm::object::MachOObjectFile::isSectionVirtual
bool isSectionVirtual(DataRefImpl Sec) const override
Definition: MachOObjectFile.cpp:2055
llvm::AMDGPU::ElfNote::SectionName
const char SectionName[]
Definition: AMDGPUPTNote.h:24
llvm::object::BindRebaseSegInfo::address
uint64_t address(uint32_t SegIndex, uint64_t SegOffset)
Definition: MachOObjectFile.cpp:4118
llvm::object::MachOObjectFile::moveRelocationNext
void moveRelocationNext(DataRefImpl &Rel) const override
Definition: MachOObjectFile.cpp:2133
llvm::object::DataRefImpl::p
uintptr_t p
Definition: SymbolicFile.h:39
llvm::IndexedInstrProf::Version
const uint64_t Version
Definition: InstrProf.h:991
llvm::MachO::BindType
BindType
Definition: MachO.h:249
llvm::object::MachOObjectFile::getDataInCodeLoadCommand
MachO::linkedit_data_command getDataInCodeLoadCommand() const
Definition: MachOObjectFile.cpp:4524
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::object::MachOObjectFile::create
static Expected< std::unique_ptr< MachOObjectFile > > create(MemoryBufferRef Object, bool IsLittleEndian, bool Is64Bits, uint32_t UniversalCputype=0, uint32_t UniversalIndex=0)
Definition: MachOObjectFile.cpp:1244
llvm::MachO::HeaderFileType
HeaderFileType
Definition: MachO.h:40
llvm::object::MachORebaseEntry::segmentName
StringRef segmentName() const
Definition: MachOObjectFile.cpp:3437
llvm::object::MachOBindEntry::Kind::Lazy
@ Lazy
llvm::SmallString< 256 >
llvm::object::MachOObjectFile::getCommonSymbolSizeImpl
uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override
Definition: MachOObjectFile.cpp:1817
llvm::object::MachOObjectFile::getSectionRawFinalSegmentName
ArrayRef< char > getSectionRawFinalSegmentName(DataRefImpl Sec) const
Definition: MachOObjectFile.cpp:4183
llvm::object::MachOObjectFile::getSection64
MachO::section_64 getSection64(DataRefImpl DRI) const
Definition: MachOObjectFile.cpp:4274
llvm::object::ExportEntry::operator==
bool operator==(const ExportEntry &) const
Definition: MachOObjectFile.cpp:2839
llvm::object::SectionRef
This is a value type class that represents a single section in the list of sections in the object fil...
Definition: ObjectFile.h:80
llvm::object::MachOObjectFile
Definition: MachO.h:262
llvm::MachO::mach_header_64
Definition: MachO.h:519
llvm::object::MachOObjectFile::getDyldInfoWeakBindOpcodes
ArrayRef< uint8_t > getDyldInfoWeakBindOpcodes() const
Definition: MachOObjectFile.cpp:4580
llvm::object::ExportEntry::moveNext
void moveNext()
Definition: MachOObjectFile.cpp:3097
llvm::object::MachOObjectFile::getSectionType
unsigned getSectionType(SectionRef Sec) const
Definition: MachOObjectFile.cpp:1769
llvm::object::MachOObjectFile::getEntryPointCommand
MachO::entry_point_command getEntryPointCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4374
llvm::object::MachOObjectFile::getSectionID
unsigned getSectionID(SectionRef Sec) const
Definition: MachOObjectFile.cpp:2051
llvm::object::MachOObjectFile::LoadCommandList
SmallVector< LoadCommandInfo, 4 > LoadCommandList
Definition: MachO.h:268
llvm::object::MachOObjectFile::getFeatures
SubtargetFeatures getFeatures() const override
Definition: MachO.h:367
llvm::object::MachOObjectFile::getPlainRelocationSymbolNum
unsigned getPlainRelocationSymbolNum(const MachO::any_relocation_info &RE) const
Definition: MachOObjectFile.cpp:4198
llvm::object::MachOObjectFile::getDylinkerCommand
MachO::dylinker_command getDylinkerCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4354
llvm::MachO::dylib_command
Definition: MachO.h:617
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:197
llvm::object::MachOObjectFile::is64Bit
bool is64Bit() const
Definition: MachOObjectFile.cpp:4635
llvm::MachO::note_command
Definition: MachO.h:842
object
bar al al movzbl eax ret Missed when stored in a memory object
Definition: README.txt:1411
llvm::object::MachOObjectFile::getNoteLoadCommand
MachO::note_command getNoteLoadCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4329
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
index
splat index
Definition: README_ALTIVEC.txt:181
llvm::object::MachOObjectFile::getSymbol64TableEntry
MachO::nlist_64 getSymbol64TableEntry(DataRefImpl DRI) const
Definition: MachOObjectFile.cpp:4298
uint64_t
llvm::object::symbol_iterator
Definition: ObjectFile.h:207
llvm::object::MachOObjectFile::external_relocations
iterator_range< relocation_iterator > external_relocations() const
Definition: MachO.h:328
llvm::object::MachOObjectFile::LoadCommandInfo::Ptr
const char * Ptr
Definition: MachO.h:265
llvm::object::MachOObjectFile::isSectionBitcode
bool isSectionBitcode(DataRefImpl Sec) const override
Definition: MachOObjectFile.cpp:2062
llvm::object::MachOObjectFile::BindEntryCheckSegAndOffsets
const char * BindEntryCheckSegAndOffsets(int32_t SegIndex, uint64_t SegOffset, uint8_t PointerSize, uint32_t Count=1, uint32_t Skip=0) const
Definition: MachO.h:420
llvm::MachO::build_tool_version
Definition: MachO.h:850
llvm::object::MachOObjectFile::getSymbolType
Expected< SymbolRef::Type > getSymbolType(DataRefImpl Symb) const override
Definition: MachOObjectFile.cpp:1822
llvm::object::MachOObjectFile::symbol_begin
basic_symbol_iterator symbol_begin() const override
Definition: MachOObjectFile.cpp:2498
llvm::object::MachORebaseEntry::MachORebaseEntry
MachORebaseEntry(Error *Err, const MachOObjectFile *O, ArrayRef< uint8_t > opcodes, bool is64Bit)
Definition: MachOObjectFile.cpp:3145
llvm::object::MachOObjectFile::getRoutinesCommand64
MachO::routines_command_64 getRoutinesCommand64(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4414
StringExtras.h
llvm::object::MachOObjectFile::getDice
MachO::data_in_code_entry getDice(DataRefImpl Rel) const
Definition: MachOObjectFile.cpp:4451
llvm::object::MachOObjectFile::end_load_commands
load_command_iterator end_load_commands() const
Definition: MachOObjectFile.cpp:4159
llvm::object::MachOObjectFile::getVersionMinMinor
static uint32_t getVersionMinMinor(MachO::version_min_command &C, bool SDK)
Definition: MachO.h:596
ArrayRef.h
llvm::object::MachOObjectFile::getArchTriple
Triple getArchTriple(const char **McpuDefault=nullptr) const
llvm::MachO::PLATFORM_BRIDGEOS
@ PLATFORM_BRIDGEOS
Definition: MachO.h:496
llvm::HighlightColor::Address
@ Address
llvm::MachO::linker_option_command
Definition: MachO.h:880
llvm::object::ExportEntry::other
uint64_t other() const
Definition: MachOObjectFile.cpp:2878
llvm::MachO::RebaseType
RebaseType
Definition: MachO.h:229
llvm::SmallVectorImpl< NodeState >::const_iterator
typename SuperClass::const_iterator const_iterator
Definition: SmallVector.h:563
llvm::object::MachOObjectFile::section_end
section_iterator section_end() const override
Definition: MachOObjectFile.cpp:2551
ObjectFile.h
llvm::object::MachOObjectFile::getLibraryShortNameByIndex
std::error_code getLibraryShortNameByIndex(unsigned Index, StringRef &) const
Definition: MachOObjectFile.cpp:2453
llvm::object::content_iterator
Definition: SymbolicFile.h:67
llvm::MachO::segment_command
Definition: MachO.h:535
llvm::object::MachOObjectFile::getDyldInfoRebaseOpcodes
ArrayRef< uint8_t > getDyldInfoRebaseOpcodes() const
Definition: MachOObjectFile.cpp:4552
iterator_range.h
llvm::MachO::dylinker_command
Definition: MachO.h:656
llvm::object::DiceRef
DiceRef - This is a value type class that represents a single data in code entry in the table in a Ma...
Definition: MachO.h:43
llvm::object::CodeSignatureSection::HashSize
static constexpr size_t HashSize
Definition: MachO.h:744
llvm::object::DiceRef::getRawDataRefImpl
DataRefImpl getRawDataRefImpl() const
Definition: MachO.h:728
llvm::object::MachOObjectFile::getScatteredRelocationScattered
bool getScatteredRelocationScattered(const MachO::any_relocation_info &RE) const
Definition: MachOObjectFile.cpp:4212
llvm::object::MachOObjectFile::getDyldInfoBindOpcodes
ArrayRef< uint8_t > getDyldInfoBindOpcodes() const
Definition: MachOObjectFile.cpp:4566
llvm::object::MachOObjectFile::getDataInCodeTableEntry
MachO::data_in_code_entry getDataInCodeTableEntry(uint32_t DataOffset, unsigned Index) const
Definition: MachOObjectFile.cpp:4473
Triple.h
llvm::object::MachOObjectFile::getArch
Triple::ArchType getArch() const override
llvm::object::DiceRef::getKind
std::error_code getKind(uint16_t &Result) const
Definition: MachO.h:720
llvm::object::MachOObjectFile::begin_load_commands
load_command_iterator begin_load_commands() const
Definition: MachOObjectFile.cpp:4154
llvm::MachO::load_command
Definition: MachO.h:530
llvm::object::BindRebaseSegInfo::segmentName
StringRef segmentName(int32_t SegIndex)
Definition: MachOObjectFile.cpp:4085
llvm::object::MachOObjectFile::extrel_begin
relocation_iterator extrel_begin() const
Definition: MachOObjectFile.cpp:2099
llvm::ArrayRef< uint8_t >
llvm::object::MachORebaseEntry::moveNext
void moveNext()
Definition: MachOObjectFile.cpp:3161
llvm::object::MachOObjectFile::getAnyRelocationSection
SectionRef getAnyRelocationSection(const MachO::any_relocation_info &RE) const
Definition: MachOObjectFile.cpp:4257
llvm::object::MachOObjectFile::getSymbolSection
Expected< section_iterator > getSymbolSection(DataRefImpl Symb) const override
Definition: MachOObjectFile.cpp:1887
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::object::ObjectFile
This class is the base class for all object file types.
Definition: ObjectFile.h:228
llvm::object::Binary
Definition: Binary.h:32
SegmentOffset
static Constant * SegmentOffset(IRBuilderBase &IRB, int Offset, unsigned AddressSpace)
Definition: X86ISelLowering.cpp:2689
llvm::object::DiceRef::getOffset
std::error_code getOffset(uint32_t &Result) const
Definition: MachO.h:704
uint32_t
llvm::object::ExportEntry::address
uint64_t address() const
Definition: MachOObjectFile.cpp:2874
llvm::MachO::segment_command_64
Definition: MachO.h:549
llvm::object::MachOObjectFile::exports
iterator_range< export_iterator > exports(Error &Err) const
For use iterating over all exported symbols.
Definition: MachOObjectFile.cpp:3141
llvm::object::DataRefImpl
Definition: SymbolicFile.h:33
llvm::object::MachOObjectFile::getRelocationTypeName
void getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl< char > &Result) const override
Definition: MachOObjectFile.cpp:2176
llvm::object::MachOObjectFile::getEncryptionInfoCommand64
MachO::encryption_info_command_64 getEncryptionInfoCommand64(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4384
llvm::object::MachOObjectFile::locrel_end
relocation_iterator locrel_end() const
Definition: MachOObjectFile.cpp:2124
llvm::object::MachOBindEntry::ordinal
int ordinal() const
Definition: MachOObjectFile.cpp:3985
llvm::object::MachOBindEntry::segmentIndex
int32_t segmentIndex() const
Definition: MachOObjectFile.cpp:3963
llvm::object::CodeSignatureSection::getRawSize
uint32_t getRawSize() const
Definition: CodeSignatureSection.cpp:60
llvm::object::MachOObjectFile::isRelocationScattered
bool isRelocationScattered(const MachO::any_relocation_info &RE) const
Definition: MachOObjectFile.cpp:4191
llvm::object::MachOObjectFile::section_begin
section_iterator section_begin() const override
Definition: MachOObjectFile.cpp:2546
llvm::MachO::PLATFORM_TVOS
@ PLATFORM_TVOS
Definition: MachO.h:494
llvm::object::MachOObjectFile::getVersionMinUpdate
static uint32_t getVersionMinUpdate(MachO::version_min_command &C, bool SDK)
Definition: MachO.h:602
llvm::MachO::encryption_info_command_64
Definition: MachO.h:825
llvm::object::BindRebaseSegInfo
Definition: MachO.h:131
llvm::object::MachOObjectFile::getSymbolFlags
Expected< uint32_t > getSymbolFlags(DataRefImpl Symb) const override
Definition: MachOObjectFile.cpp:1847
llvm::MachO::dysymtab_command
Definition: MachO.h:702
llvm::object::MachOObjectFile::Header
MachO::mach_header Header
Definition: MachO.h:661
llvm::object::MachOObjectFile::getSymtabLoadCommand
MachO::symtab_command getSymtabLoadCommand() const
Definition: MachOObjectFile.cpp:4479
llvm::object::MachOObjectFile::moveSectionNext
void moveSectionNext(DataRefImpl &Sec) const override
Definition: MachOObjectFile.cpp:1908
llvm::object::MachOObjectFile::extrel_end
relocation_iterator extrel_end() const
Definition: MachOObjectFile.cpp:2107
llvm::object::MachOObjectFile::getAnyRelocationType
unsigned getAnyRelocationType(const MachO::any_relocation_info &RE) const
Definition: MachOObjectFile.cpp:4249
llvm::MachO::CS_CodeDirectory
Definition: MachO.h:2151
llvm::AMDGPU::HSAMD::Kernel::Key::SymbolName
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
Definition: AMDGPUMetadata.h:381
llvm::MachO::section_64
Definition: MachO.h:577
llvm::object::MachOBindEntry::Kind
Kind
Definition: MachO.h:213
llvm::object::MachOObjectFile::getSymbolTableEntry
MachO::nlist getSymbolTableEntry(DataRefImpl DRI) const
Definition: MachOObjectFile.cpp:4292
llvm::object::MachOObjectFile::load_commands
iterator_range< load_command_iterator > load_commands() const
Definition: MachOObjectFile.cpp:4164
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::object::MachOObjectFile::getSegment64LoadCommand
MachO::segment_command_64 getSegment64LoadCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4314
uint16_t
llvm::MachO::PLATFORM_TVOSSIMULATOR
@ PLATFORM_TVOSSIMULATOR
Definition: MachO.h:499
llvm::object::MachORebaseEntry::segmentIndex
int32_t segmentIndex() const
Definition: MachOObjectFile.cpp:3419
llvm::SectionName
Definition: DWARFSection.h:21
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::object::ExportEntry::name
StringRef name() const
Definition: MachOObjectFile.cpp:2866
llvm::object::MachOObjectFile::getHeader64
const MachO::mach_header_64 & getHeader64() const
Definition: MachOObjectFile.cpp:4460
llvm::MachO::routines_command_64
Definition: MachO.h:680
llvm::object::MachOBindEntry::Kind::Regular
@ Regular
llvm::object::ExportEntry::flags
uint64_t flags() const
Definition: MachOObjectFile.cpp:2870
llvm::object::MachOBindEntry::symbolName
StringRef symbolName() const
Definition: MachOObjectFile.cpp:3979
llvm::MachO::entry_point_command
Definition: MachO.h:926
llvm::object::MachOBindEntry::addend
int64_t addend() const
Definition: MachOObjectFile.cpp:3981
llvm::object::MachOBindEntry
MachOBindEntry encapsulates the current state in the decompression of binding opcodes.
Definition: MachO.h:211
llvm::MachO::mach_header
Definition: MachO.h:509
llvm::object::CodeSignatureSection::BlockSize
static constexpr size_t BlockSize
Definition: MachO.h:743
llvm::object::MachOObjectFile::getNValue
uint64_t getNValue(DataRefImpl Sym) const
Definition: MachOObjectFile.cpp:1775
llvm::object::Binary::isMachO
bool isMachO() const
Definition: Binary.h:124
llvm::object::MachOObjectFile::isDebugSection
bool isDebugSection(DataRefImpl Sec) const override
Definition: MachOObjectFile.cpp:2037
llvm::object::MachOObjectFile::getLibraryCount
uint32_t getLibraryCount() const
Definition: MachOObjectFile.cpp:2487
llvm::MachO::PLATFORM_WATCHOS
@ PLATFORM_WATCHOS
Definition: MachO.h:495
llvm::object::DiceRef::operator<
bool operator<(const DiceRef &Other) const
Definition: MachO.h:690
llvm::object::MachOObjectFile::hasPageZeroSegment
bool hasPageZeroSegment() const
Definition: MachO.h:583
llvm::object::MachOObjectFile::getSubClientCommand
MachO::sub_client_command getSubClientCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4404
llvm::object::MachOObjectFile::getIndirectName
std::error_code getIndirectName(DataRefImpl Symb, StringRef &Res) const
Definition: MachOObjectFile.cpp:1786
llvm::object::MachOObjectFile::getRelocationType
uint64_t getRelocationType(DataRefImpl Rel) const override
Definition: MachOObjectFile.cpp:2171
llvm::object::MachOObjectFile::getHostArch
static Triple getHostArch()
Definition: MachOObjectFile.cpp:2748
llvm::object::MachOObjectFile::getBytesInAddress
uint8_t getBytesInAddress() const override
The number of bytes used to represent an address in this object file format.
Definition: MachOObjectFile.cpp:2557
llvm::object::MachOObjectFile::getDyldInfoExportsTrie
ArrayRef< uint8_t > getDyldInfoExportsTrie() const
Definition: MachOObjectFile.cpp:4608
Binary.h
llvm::MachO::nlist_64
Definition: MachO.h:995
llvm::object::MachOObjectFile::getScatteredRelocationValue
uint32_t getScatteredRelocationValue(const MachO::any_relocation_info &RE) const
Definition: MachOObjectFile.cpp:4217
llvm::object::MachOObjectFile::RebaseEntryCheckSegAndOffsets
const char * RebaseEntryCheckSegAndOffsets(int32_t SegIndex, uint64_t SegOffset, uint8_t PointerSize, uint32_t Count=1, uint32_t Skip=0) const
Definition: MachO.h:433
llvm::object::MachOObjectFile::bindTable
iterator_range< bind_iterator > bindTable(Error &Err)
For use iterating over all bind table entries.
Definition: MachOObjectFile.cpp:4138
SmallVector.h
llvm::MachO::CS_SuperBlob
Definition: MachO.h:2190
llvm::object::CodeSignatureSection::BlockSizeShift
static constexpr uint8_t BlockSizeShift
Definition: MachO.h:742
llvm::object::MachOObjectFile::section_rel_begin
relocation_iterator section_rel_begin(DataRefImpl Sec) const override
llvm::object::MachOObjectFile::getSectionFinalSegmentName
StringRef getSectionFinalSegmentName(DataRefImpl Sec) const
Definition: MachOObjectFile.cpp:4169
llvm::object::MachORebaseEntry
MachORebaseEntry encapsulates the current state in the decompression of rebasing opcodes.
Definition: MachO.h:167
llvm::object::MachORebaseEntry::typeName
StringRef typeName() const
Definition: MachOObjectFile.cpp:3423
llvm::MachO::PLATFORM_DRIVERKIT
@ PLATFORM_DRIVERKIT
Definition: MachO.h:501
llvm::object::MachOObjectFile::Header64
MachO::mach_header_64 Header64
Definition: MachO.h:660
llvm::object::MachOBindEntry::Kind::Weak
@ Weak
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition: iterator_range.h:30
llvm::object::MachOObjectFile::begin_dices
dice_iterator begin_dices() const
Definition: MachOObjectFile.cpp:2802
llvm::object::MachOObjectFile::getAnyRelocationLength
unsigned getAnyRelocationLength(const MachO::any_relocation_info &RE) const
Definition: MachOObjectFile.cpp:4241
llvm::object::CodeSignatureSection::write
void write(uint8_t *Buf) const
Definition: CodeSignatureSection.cpp:68
llvm::SmallVectorImpl< char >
llvm::object::MachOObjectFile::end_dices
dice_iterator end_dices() const
Definition: MachOObjectFile.cpp:2812
llvm::object::MachOObjectFile::getValidArchs
static ArrayRef< StringRef > getValidArchs()
Definition: MachOObjectFile.cpp:2757
llvm::object::SymbolRef
This is a value type class that represents a single symbol in the list of symbols in the object file.
Definition: ObjectFile.h:167
llvm::object::ExportEntry::ExportEntry
ExportEntry(Error *Err, const MachOObjectFile *O, ArrayRef< uint8_t > Trie)
Definition: MachOObjectFile.cpp:2823
llvm::object::CodeSignatureSection::FixedHeadersSize
static constexpr uint32_t FixedHeadersSize
Definition: MachO.h:747
llvm::object::MachOObjectFile::guessLibraryShortName
static StringRef guessLibraryShortName(StringRef Name, bool &isFramework, StringRef &Suffix)
Definition: MachOObjectFile.cpp:2327
llvm::object::MachOBindEntry::address
uint64_t address() const
Definition: MachOObjectFile.cpp:4001
llvm::object::MachOObjectFile::isSectionBSS
bool isSectionBSS(DataRefImpl Sec) const override
Definition: MachOObjectFile.cpp:2029
llvm::object::MachOObjectFile::getSectionAddress
uint64_t getSectionAddress(DataRefImpl Sec) const override
Definition: MachOObjectFile.cpp:1917
llvm::object::MachOObjectFile::getThreadCommand
MachO::thread_command getThreadCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4419
MachO.h
llvm::object::DiceRef::DiceRef
DiceRef()=default
llvm::object::MachOObjectFile::getHeader
const MachO::mach_header & getHeader() const
Definition: MachOObjectFile.cpp:4456
llvm::object::MachOObjectFile::BindRebaseSectionName
StringRef BindRebaseSectionName(uint32_t SegIndex, uint64_t SegOffset) const
For use with a SegIndex,SegOffset pair from a checked Mach-O Bind or Rebase entry to get the section ...
Definition: MachO.h:450
raw_ostream.h
llvm::object::MachOObjectFile::moveSymbolNext
void moveSymbolNext(DataRefImpl &Symb) const override
Definition: MachOObjectFile.cpp:1747
llvm::object::MachOObjectFile::getEncryptionInfoCommand
MachO::encryption_info_command getEncryptionInfoCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4379
llvm::object::MachOObjectFile::getFileFormatName
StringRef getFileFormatName() const override
Definition: MachOObjectFile.cpp:2561
llvm::object::MachOObjectFile::getSymbolName
Expected< StringRef > getSymbolName(DataRefImpl Symb) const override
Definition: MachOObjectFile.cpp:1754
llvm::raw_string_ostream::str
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
Definition: raw_ostream.h:643
llvm::format_hex
FormattedNumber format_hex(uint64_t N, unsigned Width, bool Upper=false)
format_hex - Output N as a fixed width hexadecimal.
Definition: Format.h:186
llvm::object::MachOObjectFile::isSectionData
bool isSectionData(DataRefImpl Sec) const override
Definition: MachOObjectFile.cpp:2021
llvm::object::MachOObjectFile::lazyBindTable
iterator_range< bind_iterator > lazyBindTable(Error &Err)
For use iterating over all lazy bind table entries.
Definition: MachOObjectFile.cpp:4143
llvm::object::CodeSignatureSection::BlobHeadersSize
static constexpr size_t BlobHeadersSize
Definition: MachO.h:745
llvm::object::BindRebaseSegInfo::BindRebaseSegInfo
BindRebaseSegInfo(const MachOObjectFile *Obj)
Definition: MachOObjectFile.cpp:4017
llvm::MachO::version_min_command
Definition: MachO.h:834
llvm::object::MachOObjectFile::getSectionName
Expected< StringRef > getSectionName(DataRefImpl Sec) const override
Definition: MachOObjectFile.cpp:1912
llvm::object::MachOObjectFile::section_rel_end
relocation_iterator section_rel_end(DataRefImpl Sec) const override
llvm::object::MachOObjectFile::getSubLibraryCommand
MachO::sub_library_command getSubLibraryCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4399
llvm::object::MachORebaseEntry::segmentOffset
uint64_t segmentOffset() const
Definition: MachOObjectFile.cpp:3421
llvm::object::MachOObjectFile::getLinkerOptionLoadCommand
MachO::linker_option_command getLinkerOptionLoadCommand(const LoadCommandInfo &L) const
Definition: MachOObjectFile.cpp:4319
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1172
llvm::object::MachOObjectFile::isRelocatableObject
bool isRelocatableObject() const override
True if this is a relocatable object (.o/.obj).
Definition: MachOObjectFile.cpp:4652
llvm::MachO::encryption_info_command
Definition: MachO.h:817
llvm::object::ExportEntry::otherName
StringRef otherName() const
Definition: MachOObjectFile.cpp:2882
llvm::object::MachOObjectFile::getSymbolAlignment
uint32_t getSymbolAlignment(DataRefImpl Symb) const override
Definition: MachOObjectFile.cpp:1808
llvm::object::MachOBindEntry::MachOBindEntry
MachOBindEntry(Error *Err, const MachOObjectFile *O, ArrayRef< uint8_t > Opcodes, bool is64Bit, MachOBindEntry::Kind)
Definition: MachOObjectFile.cpp:3482