LLVM  4.0.0
Object/MachO.h
Go to the documentation of this file.
1 //===- MachO.h - MachO object file implementation ---------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the MachOObjectFile class, which implement the ObjectFile
11 // interface for MachO files.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_OBJECT_MACHO_H
16 #define LLVM_OBJECT_MACHO_H
17 
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/SmallVector.h"
20 #include "llvm/ADT/Triple.h"
21 #include "llvm/Object/ObjectFile.h"
22 #include "llvm/Support/MachO.h"
23 
24 namespace llvm {
25 namespace object {
26 
27 /// DiceRef - This is a value type class that represents a single
28 /// data in code entry in the table in a Mach-O object file.
29 class DiceRef {
30  DataRefImpl DicePimpl;
31  const ObjectFile *OwningObject;
32 
33 public:
34  DiceRef() : OwningObject(nullptr) { }
35 
36  DiceRef(DataRefImpl DiceP, const ObjectFile *Owner);
37 
38  bool operator==(const DiceRef &Other) const;
39  bool operator<(const DiceRef &Other) const;
40 
41  void moveNext();
42 
43  std::error_code getOffset(uint32_t &Result) const;
44  std::error_code getLength(uint16_t &Result) const;
45  std::error_code getKind(uint16_t &Result) const;
46 
48  const ObjectFile *getObjectFile() const;
49 };
51 
52 /// ExportEntry encapsulates the current-state-of-the-walk used when doing a
53 /// non-recursive walk of the trie data structure. This allows you to iterate
54 /// across all exported symbols using:
55 /// for (const llvm::object::ExportEntry &AnExport : Obj->exports()) {
56 /// }
57 class ExportEntry {
58 public:
60 
61  StringRef name() const;
62  uint64_t flags() const;
63  uint64_t address() const;
64  uint64_t other() const;
65  StringRef otherName() const;
66  uint32_t nodeOffset() const;
67 
68  bool operator==(const ExportEntry &) const;
69 
70  void moveNext();
71 
72 private:
73  friend class MachOObjectFile;
74  void moveToFirst();
75  void moveToEnd();
76  uint64_t readULEB128(const uint8_t *&p);
77  void pushDownUntilBottom();
78  void pushNode(uint64_t Offset);
79 
80  // Represents a node in the mach-o exports trie.
81  struct NodeState {
82  NodeState(const uint8_t *Ptr);
83  const uint8_t *Start;
84  const uint8_t *Current;
85  uint64_t Flags;
86  uint64_t Address;
87  uint64_t Other;
88  const char *ImportName;
89  unsigned ChildCount;
90  unsigned NextChildIndex;
91  unsigned ParentStringLength;
92  bool IsExportNode;
93  };
94 
95  ArrayRef<uint8_t> Trie;
96  SmallString<256> CumulativeString;
98  bool Malformed;
99  bool Done;
100 };
102 
103 /// MachORebaseEntry encapsulates the current state in the decompression of
104 /// rebasing opcodes. This allows you to iterate through the compressed table of
105 /// rebasing using:
106 /// for (const llvm::object::MachORebaseEntry &Entry : Obj->rebaseTable()) {
107 /// }
109 public:
111 
112  uint32_t segmentIndex() const;
113  uint64_t segmentOffset() const;
114  StringRef typeName() const;
115 
116  bool operator==(const MachORebaseEntry &) const;
117 
118  void moveNext();
119 
120 private:
121  friend class MachOObjectFile;
122  void moveToFirst();
123  void moveToEnd();
124  uint64_t readULEB128();
125 
126  ArrayRef<uint8_t> Opcodes;
127  const uint8_t *Ptr;
128  uint64_t SegmentOffset;
129  uint32_t SegmentIndex;
130  uint64_t RemainingLoopCount;
131  uint64_t AdvanceAmount;
132  uint8_t RebaseType;
133  uint8_t PointerSize;
134  bool Malformed;
135  bool Done;
136 };
138 
139 /// MachOBindEntry encapsulates the current state in the decompression of
140 /// binding opcodes. This allows you to iterate through the compressed table of
141 /// bindings using:
142 /// for (const llvm::object::MachOBindEntry &Entry : Obj->bindTable()) {
143 /// }
145 public:
146  enum class Kind { Regular, Lazy, Weak };
147 
149 
150  uint32_t segmentIndex() const;
151  uint64_t segmentOffset() const;
152  StringRef typeName() const;
153  StringRef symbolName() const;
154  uint32_t flags() const;
155  int64_t addend() const;
156  int ordinal() const;
157 
158  bool operator==(const MachOBindEntry &) const;
159 
160  void moveNext();
161 
162 private:
163  friend class MachOObjectFile;
164  void moveToFirst();
165  void moveToEnd();
166  uint64_t readULEB128();
167  int64_t readSLEB128();
168 
169  ArrayRef<uint8_t> Opcodes;
170  const uint8_t *Ptr;
171  uint64_t SegmentOffset;
172  uint32_t SegmentIndex;
173  StringRef SymbolName;
174  int Ordinal;
175  uint32_t Flags;
176  int64_t Addend;
177  uint64_t RemainingLoopCount;
178  uint64_t AdvanceAmount;
179  uint8_t BindType;
180  uint8_t PointerSize;
181  Kind TableKind;
182  bool Malformed;
183  bool Done;
184 };
186 
187 class MachOObjectFile : public ObjectFile {
188 public:
190  const char *Ptr; // Where in memory the load command is.
191  MachO::load_command C; // The command itself.
192  };
195 
197  create(MemoryBufferRef Object, bool IsLittleEndian, bool Is64Bits,
198  uint32_t UniversalCputype = 0, uint32_t UniversalIndex = 0);
199 
200  void moveSymbolNext(DataRefImpl &Symb) const override;
201 
202  uint64_t getNValue(DataRefImpl Sym) const;
203  Expected<StringRef> getSymbolName(DataRefImpl Symb) const override;
204 
205  // MachO specific.
206  Error checkSymbolTable() const;
207 
208  std::error_code getIndirectName(DataRefImpl Symb, StringRef &Res) const;
209  unsigned getSectionType(SectionRef Sec) const;
210 
211  Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const override;
212  uint32_t getSymbolAlignment(DataRefImpl Symb) const override;
213  uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;
215  uint32_t getSymbolFlags(DataRefImpl Symb) const override;
217  unsigned getSymbolSectionID(SymbolRef Symb) const;
218  unsigned getSectionID(SectionRef Sec) const;
219 
220  void moveSectionNext(DataRefImpl &Sec) const override;
221  std::error_code getSectionName(DataRefImpl Sec,
222  StringRef &Res) const override;
223  uint64_t getSectionAddress(DataRefImpl Sec) const override;
224  uint64_t getSectionSize(DataRefImpl Sec) const override;
225  std::error_code getSectionContents(DataRefImpl Sec,
226  StringRef &Res) const override;
227  uint64_t getSectionAlignment(DataRefImpl Sec) const override;
228  bool isSectionCompressed(DataRefImpl Sec) const override;
229  bool isSectionText(DataRefImpl Sec) const override;
230  bool isSectionData(DataRefImpl Sec) const override;
231  bool isSectionBSS(DataRefImpl Sec) const override;
232  bool isSectionVirtual(DataRefImpl Sec) const override;
233  bool isSectionBitcode(DataRefImpl Sec) const override;
235  relocation_iterator section_rel_end(DataRefImpl Sec) const override;
236 
237  void moveRelocationNext(DataRefImpl &Rel) const override;
238  uint64_t getRelocationOffset(DataRefImpl Rel) const override;
239  symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
241  uint64_t getRelocationType(DataRefImpl Rel) const override;
243  SmallVectorImpl<char> &Result) const override;
244  uint8_t getRelocationLength(DataRefImpl Rel) const;
245 
246  // MachO specific.
247  std::error_code getLibraryShortNameByIndex(unsigned Index, StringRef &) const;
248 
250 
251  // TODO: Would be useful to have an iterator based version
252  // of the load command interface too.
253 
254  basic_symbol_iterator symbol_begin() const override;
255  basic_symbol_iterator symbol_end() const override;
256 
257  // MachO specific.
258  basic_symbol_iterator getSymbolByIndex(unsigned Index) const;
259  uint64_t getSymbolIndex(DataRefImpl Symb) const;
260 
261  section_iterator section_begin() const override;
262  section_iterator section_end() const override;
263 
264  uint8_t getBytesInAddress() const override;
265 
266  StringRef getFileFormatName() const override;
267  unsigned getArch() const override;
268  SubtargetFeatures getFeatures() const override { return SubtargetFeatures(); }
269  Triple getArchTriple(const char **McpuDefault = nullptr) const;
270 
271  relocation_iterator section_rel_begin(unsigned Index) const;
272  relocation_iterator section_rel_end(unsigned Index) const;
273 
274  dice_iterator begin_dices() const;
275  dice_iterator end_dices() const;
276 
280 
281  /// For use iterating over all exported symbols.
283 
284  /// For use examining a trie not in a MachOObjectFile.
286 
287  /// For use iterating over all rebase table entries.
289 
290  /// For use examining rebase opcodes not in a MachOObjectFile.
292  bool is64);
293 
294  /// For use iterating over all bind table entries.
296 
297  /// For use iterating over all lazy bind table entries.
299 
300  /// For use iterating over all lazy bind table entries.
302 
303  /// For use examining bind opcodes not in a MachOObjectFile.
305  bool is64,
307 
308 
309  // In a MachO file, sections have a segment name. This is used in the .o
310  // files. They have a single segment, but this field specifies which segment
311  // a section should be put in in the final object.
313 
314  // Names are stored as 16 bytes. These returns the raw 16 bytes without
315  // interpreting them as a C string.
318 
319  // MachO specific Info about relocations.
322  const MachO::any_relocation_info &RE) const;
325  const MachO::any_relocation_info &RE) const;
327  const MachO::any_relocation_info &RE) const;
329  const MachO::any_relocation_info &RE) const;
330  unsigned getAnyRelocationAddress(const MachO::any_relocation_info &RE) const;
331  unsigned getAnyRelocationPCRel(const MachO::any_relocation_info &RE) const;
332  unsigned getAnyRelocationLength(const MachO::any_relocation_info &RE) const;
333  unsigned getAnyRelocationType(const MachO::any_relocation_info &RE) const;
335 
336  // MachO specific structures.
339  MachO::section getSection(const LoadCommandInfo &L, unsigned Index) const;
340  MachO::section_64 getSection64(const LoadCommandInfo &L,unsigned Index) const;
343 
345  getLinkeditDataLoadCommand(const LoadCommandInfo &L) const;
347  getSegmentLoadCommand(const LoadCommandInfo &L) const;
349  getSegment64LoadCommand(const LoadCommandInfo &L) const;
351  getLinkerOptionLoadCommand(const LoadCommandInfo &L) const;
353  getVersionMinLoadCommand(const LoadCommandInfo &L) const;
355  getDylibIDLoadCommand(const LoadCommandInfo &L) const;
357  getDyldInfoLoadCommand(const LoadCommandInfo &L) const;
359  getDylinkerCommand(const LoadCommandInfo &L) const;
361  getUuidCommand(const LoadCommandInfo &L) const;
363  getRpathCommand(const LoadCommandInfo &L) const;
365  getSourceVersionCommand(const LoadCommandInfo &L) const;
367  getEntryPointCommand(const LoadCommandInfo &L) const;
369  getEncryptionInfoCommand(const LoadCommandInfo &L) const;
371  getEncryptionInfoCommand64(const LoadCommandInfo &L) const;
373  getSubFrameworkCommand(const LoadCommandInfo &L) const;
375  getSubUmbrellaCommand(const LoadCommandInfo &L) const;
377  getSubLibraryCommand(const LoadCommandInfo &L) const;
379  getSubClientCommand(const LoadCommandInfo &L) const;
381  getRoutinesCommand(const LoadCommandInfo &L) const;
383  getRoutinesCommand64(const LoadCommandInfo &L) const;
385  getThreadCommand(const LoadCommandInfo &L) const;
386 
389  const MachO::mach_header &getHeader() const;
390  const MachO::mach_header_64 &getHeader64() const;
391  uint32_t
393  unsigned Index) const;
395  unsigned Index) const;
405  ArrayRef<uint8_t> getUuid() const;
406 
408  bool is64Bit() const;
409  void ReadULEB128s(uint64_t Index, SmallVectorImpl<uint64_t> &Out) const;
410 
411  static StringRef guessLibraryShortName(StringRef Name, bool &isFramework,
412  StringRef &Suffix);
413 
415  static Triple getArchTriple(uint32_t CPUType, uint32_t CPUSubType,
416  const char **McpuDefault = nullptr,
417  const char **ArchFlag = nullptr);
418  static bool isValidArch(StringRef ArchFlag);
419  static Triple getHostArch();
420 
421  bool isRelocatableObject() const override;
422 
423  bool hasPageZeroSegment() const { return HasPageZeroSegment; }
424 
425  static bool classof(const Binary *v) {
426  return v->isMachO();
427  }
428 
429  static uint32_t
431  uint32_t VersionOrSDK = (SDK) ? C.sdk : C.version;
432  return (VersionOrSDK >> 16) & 0xffff;
433  }
434 
435  static uint32_t
437  uint32_t VersionOrSDK = (SDK) ? C.sdk : C.version;
438  return (VersionOrSDK >> 8) & 0xff;
439  }
440 
441  static uint32_t
443  uint32_t VersionOrSDK = (SDK) ? C.sdk : C.version;
444  return VersionOrSDK & 0xff;
445  }
446 
447 private:
448 
449  MachOObjectFile(MemoryBufferRef Object, bool IsLittleEndian, bool Is64Bits,
450  Error &Err, uint32_t UniversalCputype = 0,
451  uint32_t UniversalIndex = 0);
452 
453  uint64_t getSymbolValueImpl(DataRefImpl Symb) const override;
454 
455  union {
458  };
459  typedef SmallVector<const char*, 1> SectionList;
460  SectionList Sections;
461  typedef SmallVector<const char*, 1> LibraryList;
462  LibraryList Libraries;
463  LoadCommandList LoadCommands;
464  typedef SmallVector<StringRef, 1> LibraryShortName;
465  mutable LibraryShortName LibrariesShortNames;
466  const char *SymtabLoadCmd;
467  const char *DysymtabLoadCmd;
468  const char *DataInCodeLoadCmd;
469  const char *LinkOptHintsLoadCmd;
470  const char *DyldInfoLoadCmd;
471  const char *UuidLoadCmd;
472  bool HasPageZeroSegment;
473 };
474 
475 /// DiceRef
476 inline DiceRef::DiceRef(DataRefImpl DiceP, const ObjectFile *Owner)
477  : DicePimpl(DiceP) , OwningObject(Owner) {}
478 
479 inline bool DiceRef::operator==(const DiceRef &Other) const {
480  return DicePimpl == Other.DicePimpl;
481 }
482 
483 inline bool DiceRef::operator<(const DiceRef &Other) const {
484  return DicePimpl < Other.DicePimpl;
485 }
486 
487 inline void DiceRef::moveNext() {
489  reinterpret_cast<const MachO::data_in_code_entry *>(DicePimpl.p);
490  DicePimpl.p = reinterpret_cast<uintptr_t>(P + 1);
491 }
492 
493 // Since a Mach-O data in code reference, a DiceRef, can only be created when
494 // the OwningObject ObjectFile is a MachOObjectFile a static_cast<> is used for
495 // the methods that get the values of the fields of the reference.
496 
497 inline std::error_code DiceRef::getOffset(uint32_t &Result) const {
498  const MachOObjectFile *MachOOF =
499  static_cast<const MachOObjectFile *>(OwningObject);
500  MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl);
501  Result = Dice.offset;
502  return std::error_code();
503 }
504 
505 inline std::error_code DiceRef::getLength(uint16_t &Result) const {
506  const MachOObjectFile *MachOOF =
507  static_cast<const MachOObjectFile *>(OwningObject);
508  MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl);
509  Result = Dice.length;
510  return std::error_code();
511 }
512 
513 inline std::error_code DiceRef::getKind(uint16_t &Result) const {
514  const MachOObjectFile *MachOOF =
515  static_cast<const MachOObjectFile *>(OwningObject);
516  MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl);
517  Result = Dice.kind;
518  return std::error_code();
519 }
520 
522  return DicePimpl;
523 }
524 
525 inline const ObjectFile *DiceRef::getObjectFile() const {
526  return OwningObject;
527 }
528 
529 }
530 }
531 
532 #endif
void getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl< char > &Result) const override
MachineLoop * L
bool getPlainRelocationExternal(const MachO::any_relocation_info &RE) const
iterator_range< export_iterator > exports() const
For use iterating over all exported symbols.
static uint32_t getVersionMinUpdate(MachO::version_min_command &C, bool SDK)
Definition: Object/MachO.h:442
load_command_iterator end_load_commands() const
std::error_code getIndirectName(DataRefImpl Symb, StringRef &Res) const
StringRef getStringTableData() const
std::error_code getKind(uint16_t &Result) const
Definition: Object/MachO.h:513
StringRef getFileFormatName() const override
MachO::linkedit_data_command getLinkOptHintsLoadCommand() const
uint64_t getRelocationOffset(DataRefImpl Rel) const override
bool isSectionVirtual(DataRefImpl Sec) const override
ArrayRef< char > getSectionRawFinalSegmentName(DataRefImpl Sec) const
ArrayRef< char > getSectionRawName(DataRefImpl Sec) const
MachO::data_in_code_entry getDataInCodeTableEntry(uint32_t DataOffset, unsigned Index) const
std::error_code getSectionName(DataRefImpl Sec, StringRef &Res) const override
void moveRelocationNext(DataRefImpl &Rel) const override
ExportEntry encapsulates the current-state-of-the-walk used when doing a non-recursive walk of the tr...
Definition: Object/MachO.h:57
bool isRelocatableObject() const override
True if this is a relocatable object (.o/.obj).
unsigned getAnyRelocationType(const MachO::any_relocation_info &RE) const
uint32_t getScatteredRelocationType(const MachO::any_relocation_info &RE) const
uint8_t getRelocationLength(DataRefImpl Rel) const
This class is the base class for all object file types.
Definition: ObjectFile.h:178
uint8_t getBytesInAddress() const override
The number of bytes used to represent an address in this object file format.
uint64_t getRelocationType(DataRefImpl Rel) const override
StringRef otherName() const
MachORebaseEntry encapsulates the current state in the decompression of rebasing opcodes.
Definition: Object/MachO.h:108
uint64_t getSectionAlignment(DataRefImpl Sec) const override
ArrayRef< uint8_t > getDyldInfoLazyBindOpcodes() const
load_command_iterator begin_load_commands() const
uint32_t getIndirectSymbolTableEntry(const MachO::dysymtab_command &DLC, unsigned Index) const
bool operator==(const MachORebaseEntry &) const
iterator_range< rebase_iterator > rebaseTable() const
For use iterating over all rebase table entries.
bool isSectionBitcode(DataRefImpl Sec) const override
uint64_t getSectionAddress(DataRefImpl Sec) const override
content_iterator< ExportEntry > export_iterator
Definition: Object/MachO.h:101
basic_symbol_iterator symbol_begin() const override
bool operator==(const ExportEntry &) const
DataRefImpl getRawDataRefImpl() const
Definition: Object/MachO.h:521
bool isSectionText(DataRefImpl Sec) const override
struct fuzzer::@269 Flags
std::error_code getOffset(uint32_t &Result) const
Definition: Object/MachO.h:497
Expected< StringRef > getSymbolName(DataRefImpl Symb) const override
MachO::segment_command_64 getSegment64LoadCommand(const LoadCommandInfo &L) const
MachO::uuid_command getUuidCommand(const LoadCommandInfo &L) const
uint16_t length
uint64_t getSymbolIndex(DataRefImpl Symb) const
Tagged union holding either a T or a Error.
uint32_t getSymbolAlignment(DataRefImpl Symb) const override
void ReadULEB128s(uint64_t Index, SmallVectorImpl< uint64_t > &Out) const
MachOBindEntry encapsulates the current state in the decompression of binding opcodes.
Definition: Object/MachO.h:144
MachO::linker_option_command getLinkerOptionLoadCommand(const LoadCommandInfo &L) const
ELFYAML::ELF_STO Other
Definition: ELFYAML.cpp:662
MachO::encryption_info_command_64 getEncryptionInfoCommand64(const LoadCommandInfo &L) const
dice_iterator end_dices() const
uint32_t getScatteredRelocationValue(const MachO::any_relocation_info &RE) const
MachO::dylib_command getDylibIDLoadCommand(const LoadCommandInfo &L) const
unsigned getArch() const override
MachO::routines_command getRoutinesCommand(const LoadCommandInfo &L) const
ExportEntry(ArrayRef< uint8_t > Trie)
SubtargetFeatures getFeatures() const override
Definition: Object/MachO.h:268
MachO::dylinker_command getDylinkerCommand(const LoadCommandInfo &L) const
const MachO::mach_header & getHeader() const
bool getScatteredRelocationScattered(const MachO::any_relocation_info &RE) const
basic_symbol_iterator symbol_end() const override
MachO::section_64 getSection64(DataRefImpl DRI) const
MachO::entry_point_command getEntryPointCommand(const LoadCommandInfo &L) const
MachO::routines_command_64 getRoutinesCommand64(const LoadCommandInfo &L) const
void moveSectionNext(DataRefImpl &Sec) const override
#define P(N)
bool isSectionCompressed(DataRefImpl Sec) const override
unsigned getSectionID(SectionRef Sec) const
const MachO::mach_header_64 & getHeader64() const
unsigned getAnyRelocationAddress(const MachO::any_relocation_info &RE) const
ArrayRef< uint8_t > getUuid() const
iterator_range< load_command_iterator > load_commands() const
MachO::any_relocation_info getRelocation(DataRefImpl Rel) const
MachO::section getSection(DataRefImpl DRI) const
static bool is64Bit(const char *name)
MachO::segment_command getSegmentLoadCommand(const LoadCommandInfo &L) const
uint32_t offset
unsigned getAnyRelocationPCRel(const MachO::any_relocation_info &RE) const
ArrayRef< uint8_t > getDyldInfoRebaseOpcodes() const
uint32_t Offset
MachO::source_version_command getSourceVersionCommand(const LoadCommandInfo &L) const
MachO::linkedit_data_command getDataInCodeLoadCommand() const
LoadCommandList::const_iterator load_command_iterator
Definition: Object/MachO.h:194
bool operator==(const DiceRef &Other) const
Definition: Object/MachO.h:479
DiceRef - This is a value type class that represents a single data in code entry in the table in a Ma...
Definition: Object/MachO.h:29
MachORebaseEntry(ArrayRef< uint8_t > opcodes, bool is64Bit)
MachO::sub_framework_command getSubFrameworkCommand(const LoadCommandInfo &L) const
content_iterator< MachOBindEntry > bind_iterator
Definition: Object/MachO.h:185
bool operator==(const MachOBindEntry &) const
uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override
MachO::thread_command getThreadCommand(const LoadCommandInfo &L) const
uint64_t getNValue(DataRefImpl Sym) const
uint16_t kind
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
section_iterator getRelocationSection(DataRefImpl Rel) const
std::error_code getLibraryShortNameByIndex(unsigned Index, StringRef &) const
Triple getArchTriple(const char **McpuDefault=nullptr) const
section_iterator getRelocationRelocatedSection(relocation_iterator Rel) const
Expected< uint64_t > getSymbolAddress(DataRefImpl Symb) const override
void moveSymbolNext(DataRefImpl &Symb) const override
unsigned getAnyRelocationLength(const MachO::any_relocation_info &RE) const
unsigned getSymbolSectionID(SymbolRef Symb) const
bool isSectionData(DataRefImpl Sec) const override
content_iterator< DiceRef > dice_iterator
Definition: Object/MachO.h:50
StringRef getSectionFinalSegmentName(DataRefImpl Sec) const
std::error_code getSectionContents(DataRefImpl Sec, StringRef &Res) const override
bool isMachO() const
Definition: Binary.h:112
MachO::nlist_64 getSymbol64TableEntry(DataRefImpl DRI) const
CPUType
These values correspond to the CV_CPU_TYPE_e enumeration, and are documented here: https://msdn...
Definition: CodeView.h:73
ArrayRef< uint8_t > getDyldInfoExportsTrie() const
static uint32_t getVersionMinMinor(MachO::version_min_command &C, bool SDK)
Definition: Object/MachO.h:436
MachO::nlist getSymbolTableEntry(DataRefImpl DRI) const
std::error_code getLength(uint16_t &Result) const
Definition: Object/MachO.h:505
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
uint32_t getSymbolFlags(DataRefImpl Symb) const override
MachO::sub_library_command getSubLibraryCommand(const LoadCommandInfo &L) const
SectionRef getAnyRelocationSection(const MachO::any_relocation_info &RE) const
A range adaptor for a pair of iterators.
SubtargetFeatures - Manages the enabling and disabling of subtarget specific features.
MachO::encryption_info_command getEncryptionInfoCommand(const LoadCommandInfo &L) const
This is a value type class that represents a single symbol in the list of symbols in the object file...
Definition: ObjectFile.h:116
bool operator<(const DiceRef &Other) const
Definition: Object/MachO.h:483
static Expected< std::unique_ptr< MachOObjectFile > > create(MemoryBufferRef Object, bool IsLittleEndian, bool Is64Bits, uint32_t UniversalCputype=0, uint32_t UniversalIndex=0)
MachO::mach_header_64 Header64
Definition: Object/MachO.h:456
MachOBindEntry(ArrayRef< uint8_t > Opcodes, bool is64Bit, MachOBindEntry::Kind)
MachO::linkedit_data_command getLinkeditDataLoadCommand(const LoadCommandInfo &L) const
MachO::version_min_command getVersionMinLoadCommand(const LoadCommandInfo &L) const
static StringRef guessLibraryShortName(StringRef Name, bool &isFramework, StringRef &Suffix)
bool isSectionBSS(DataRefImpl Sec) const override
MachO::symtab_command getSymtabLoadCommand() const
basic_symbol_iterator getSymbolByIndex(unsigned Index) const
dice_iterator begin_dices() const
section_iterator section_begin() const override
Expected< SymbolRef::Type > getSymbolType(DataRefImpl Symb) const override
static bool isValidArch(StringRef ArchFlag)
relocation_iterator section_rel_end(DataRefImpl Sec) const override
MachO::dysymtab_command getDysymtabLoadCommand() const
MachO::mach_header Header
Definition: Object/MachO.h:457
MachO::rpath_command getRpathCommand(const LoadCommandInfo &L) const
MachO::data_in_code_entry getDice(DataRefImpl Rel) const
MachO::sub_umbrella_command getSubUmbrellaCommand(const LoadCommandInfo &L) const
unsigned getSectionType(SectionRef Sec) const
Lightweight error class with error context and mandatory checking.
section_iterator section_end() const override
const ObjectFile * getObjectFile() const
Definition: Object/MachO.h:525
iterator_range< bind_iterator > lazyBindTable() const
For use iterating over all lazy bind table entries.
static uint32_t getVersionMinMajor(MachO::version_min_command &C, bool SDK)
Definition: Object/MachO.h:430
ArrayRef< uint8_t > getDyldInfoWeakBindOpcodes() const
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
static bool classof(const Binary *v)
Definition: Object/MachO.h:425
int * Ptr
unsigned getPlainRelocationSymbolNum(const MachO::any_relocation_info &RE) const
MachO::dyld_info_command getDyldInfoLoadCommand(const LoadCommandInfo &L) const
bool isRelocationScattered(const MachO::any_relocation_info &RE) const
MachO::sub_client_command getSubClientCommand(const LoadCommandInfo &L) const
content_iterator< MachORebaseEntry > rebase_iterator
Definition: Object/MachO.h:137
SmallVector< LoadCommandInfo, 4 > LoadCommandList
Definition: Object/MachO.h:193
iterator_range< bind_iterator > bindTable() const
For use iterating over all bind table entries.
iterator_range< bind_iterator > weakBindTable() const
For use iterating over all lazy bind table entries.
Expected< section_iterator > getSymbolSection(DataRefImpl Symb) const override
relocation_iterator section_rel_begin(DataRefImpl Sec) const override
This is a value type class that represents a single section in the list of sections in the object fil...
Definition: ObjectFile.h:70
uint64_t getSectionSize(DataRefImpl Sec) const override
ArrayRef< uint8_t > getDyldInfoBindOpcodes() const