14#ifndef LLVM_OBJECT_MACHO_H 
   15#define LLVM_OBJECT_MACHO_H 
   38#include <system_error> 
   96  void pushDownUntilBottom();
 
  108    const char *ImportName = 
nullptr;
 
  109    unsigned ChildCount = 0;
 
  110    unsigned NextChildIndex = 0;
 
  111    unsigned ParentStringLength = 0;
 
  112    bool IsExportNode = 
false;
 
 
  154    int32_t SegmentIndex;
 
  156  const SectionInfo &findSection(int32_t SegIndex, 
uint64_t SegOffset);
 
 
  197  int32_t SegmentIndex = -1;
 
 
  243  int64_t readSLEB128(
const char **
error);
 
  250  int32_t  SegmentIndex = -1;
 
  252  bool     LibraryOrdinalSet = 
false;
 
 
  281      : LibOrdinal(LibOrdinal), NameOffset(NameOffset), SymbolName(Symbol),
 
  282        Addend(Addend), WeakImport(WeakImport) {}
 
 
 
  397  void findNextPageWithFixups();
 
  399  std::vector<ChainedFixupTarget> FixupTargets;
 
  400  std::vector<ChainedFixupsSegment> Segments;
 
 
  421         size_t MachOFilesetEntryOffset = 0);
 
  489  void moveRelocationNext(
DataRefImpl &Rel) 
const override;
 
  499  std::error_code getLibraryShortNameByIndex(
unsigned Index, 
StringRef &) 
const;
 
  519  uint8_t getBytesInAddress() 
const override;
 
  521  StringRef getFileFormatName() 
const override;
 
  526  Triple getArchTriple(
const char **McpuDefault = 
nullptr) 
const;
 
  534  load_command_iterator begin_load_commands() 
const;
 
  535  load_command_iterator end_load_commands() 
const;
 
  585    return BindRebaseSectionTable->checkSegAndOffsets(SegIndex, SegOffset,
 
  586                                                     PointerSize, 
Count, Skip);
 
 
  600    return BindRebaseSectionTable->checkSegAndOffsets(SegIndex, SegOffset,
 
  601                                                      PointerSize, 
Count, Skip);
 
 
  607    return BindRebaseSectionTable->segmentName(SegIndex);
 
 
  613    return BindRebaseSectionTable->sectionName(SegIndex, SegOffset);
 
 
  619    return BindRebaseSectionTable->address(SegIndex, SegOffset);
 
 
  634  unsigned getPlainRelocationSymbolNum(
 
  637  bool getScatteredRelocationScattered(
 
  639  uint32_t getScatteredRelocationValue(
 
  641  uint32_t getScatteredRelocationType(
 
  658  getLinkeditDataLoadCommand(
const LoadCommandInfo &L) 
const;
 
  660  getSegmentLoadCommand(
const LoadCommandInfo &L) 
const;
 
  662  getSegment64LoadCommand(
const LoadCommandInfo &L) 
const;
 
  664  getLinkerOptionLoadCommand(
const LoadCommandInfo &L) 
const;
 
  666  getVersionMinLoadCommand(
const LoadCommandInfo &L) 
const;
 
  668  getNoteLoadCommand(
const LoadCommandInfo &L) 
const;
 
  670  getBuildVersionLoadCommand(
const LoadCommandInfo &L) 
const;
 
  672  getBuildToolVersion(
unsigned index) 
const;
 
  674  getDylibIDLoadCommand(
const LoadCommandInfo &L) 
const;
 
  676  getDyldInfoLoadCommand(
const LoadCommandInfo &L) 
const;
 
  678  getDylinkerCommand(
const LoadCommandInfo &L) 
const;
 
  680  getUuidCommand(
const LoadCommandInfo &L) 
const;
 
  682  getRpathCommand(
const LoadCommandInfo &L) 
const;
 
  684  getSourceVersionCommand(
const LoadCommandInfo &L) 
const;
 
  686  getEntryPointCommand(
const LoadCommandInfo &L) 
const;
 
  688  getEncryptionInfoCommand(
const LoadCommandInfo &L) 
const;
 
  690  getEncryptionInfoCommand64(
const LoadCommandInfo &L) 
const;
 
  692  getSubFrameworkCommand(
const LoadCommandInfo &L) 
const;
 
  694  getSubUmbrellaCommand(
const LoadCommandInfo &L) 
const;
 
  696  getSubLibraryCommand(
const LoadCommandInfo &L) 
const;
 
  698  getSubClientCommand(
const LoadCommandInfo &L) 
const;
 
  700  getRoutinesCommand(
const LoadCommandInfo &L) 
const;
 
  702  getRoutinesCommand64(
const LoadCommandInfo &L) 
const;
 
  704  getThreadCommand(
const LoadCommandInfo &L) 
const;
 
  706  getFilesetEntryLoadCommand(
const LoadCommandInfo &L) 
const;
 
  714                              unsigned Index) 
const;
 
  716                                                    unsigned Index) 
const;
 
  730  getChainedFixupsHeader() 
const;
 
  736  getChainedFixupsLoadCommand() 
const;
 
  740  getChainedFixupsSegments() 
const;
 
  755                              const char **McpuDefault = 
nullptr,
 
  756                              const char **ArchFlag = 
nullptr);
 
  757  static bool isValidArch(
StringRef ArchFlag);
 
  759  static Triple getHostArch();
 
  761  bool isRelocatableObject() 
const override;
 
  778    uint32_t VersionOrSDK = (SDK) ? 
C.sdk : 
C.version;
 
  779    return (VersionOrSDK >> 16) & 0xffff;
 
 
  784    uint32_t VersionOrSDK = (SDK) ? 
C.sdk : 
C.version;
 
  785    return (VersionOrSDK >> 8) & 0xff;
 
 
  790    uint32_t VersionOrSDK = (SDK) ? 
C.sdk : 
C.version;
 
  791    return VersionOrSDK & 0xff;
 
 
  796#define PLATFORM(platform, id, name, build_name, target, tapi_target,          \ 
  798  case MachO::PLATFORM_##platform:                                             \ 
  800#include "llvm/BinaryFormat/MachO.def" 
 
  825    uint32_t major = (version >> 16) & 0xffff;
 
  826    uint32_t minor = (version >> 8) & 0xff;
 
  833    return std::string(std::string(
Version));
 
 
  847                  size_t MachOFilesetEntryOffset = 0);
 
  856  SectionList Sections;
 
  858  LibraryList Libraries;
 
  859  LoadCommandList LoadCommands;
 
  862  BuildToolList BuildTools;
 
  863  mutable LibraryShortName LibrariesShortNames;
 
  864  std::unique_ptr<BindRebaseSegInfo> BindRebaseSectionTable;
 
  865  const char *SymtabLoadCmd = 
nullptr;
 
  866  const char *DysymtabLoadCmd = 
nullptr;
 
  867  const char *DataInCodeLoadCmd = 
nullptr;
 
  868  const char *LinkOptHintsLoadCmd = 
nullptr;
 
  869  const char *DyldInfoLoadCmd = 
nullptr;
 
  870  const char *FuncStartsLoadCmd = 
nullptr;
 
  871  const char *DyldChainedFixupsLoadCmd = 
nullptr;
 
  872  const char *DyldExportsTrieLoadCmd = 
nullptr;
 
  873  const char *UuidLoadCmd = 
nullptr;
 
  874  bool HasPageZeroSegment = 
false;
 
  875  size_t MachOFilesetEntryOffset = 0;
 
 
  880  : DicePimpl(DiceP) , OwningObject(Owner) {}
 
 
  883  return DicePimpl == 
Other.DicePimpl;
 
 
  887  return DicePimpl < 
Other.DicePimpl;
 
 
  893  DicePimpl.p = 
reinterpret_cast<uintptr_t
>(
P + 1);
 
 
  905  return std::error_code();
 
 
  913  return std::error_code();
 
 
  921  return std::error_code();
 
 
Unify divergent function exit nodes
 
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
 
static StringRef getSymbolName(SymbolKind SymKind)
 
static bool isDebugSection(const SectionBase &Sec)
 
This file defines the SmallString class.
 
This file defines the SmallVector class.
 
static unsigned getSymbolSectionID(const ObjectFile &O, SymbolRef Sym)
 
static unsigned getSectionID(const ObjectFile &O, SectionRef Sec)
 
static std::unique_ptr< PDBSymbol > getSymbolType(const PDBSymbol &Symbol)
 
static uint64_t readULEB128(WasmObjectFile::ReadContext &Ctx)
 
static bool is64Bit(const char *name)
 
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
 
Lightweight error class with error context and mandatory checking.
 
Tagged union holding either a T or a Error.
 
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
 
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
 
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
 
StringRef - Represent a constant reference to a string, i.e.
 
Manages the enabling and disabling of subtarget specific features.
 
Triple - Helper class for working with autoconf configuration names.
 
A range adaptor for a pair of iterators.
 
LLVM_ABI StringRef segmentName(int32_t SegIndex)
 
LLVM_ABI StringRef sectionName(int32_t SegIndex, uint64_t SegOffset)
 
LLVM_ABI BindRebaseSegInfo(const MachOObjectFile *Obj)
 
LLVM_ABI const char * checkSegAndOffsets(int32_t SegIndex, uint64_t SegOffset, uint8_t PointerSize, uint64_t Count=1, uint64_t Skip=0)
 
LLVM_ABI uint64_t address(uint32_t SegIndex, uint64_t SegOffset)
 
bool operator==(const DiceRef &Other) const
 
std::error_code getOffset(uint32_t &Result) const
 
std::error_code getLength(uint16_t &Result) const
 
bool operator<(const DiceRef &Other) const
 
DataRefImpl getRawDataRefImpl() const
 
std::error_code getKind(uint16_t &Result) const
 
const ObjectFile * getObjectFile() const
 
LLVM_ABI StringRef name() const
 
LLVM_ABI ExportEntry(Error *Err, const MachOObjectFile *O, ArrayRef< uint8_t > Trie)
 
LLVM_ABI bool operator==(const ExportEntry &) const
 
LLVM_ABI StringRef otherName() const
 
LLVM_ABI uint64_t address() const
 
LLVM_ABI uint64_t flags() const
 
LLVM_ABI uint32_t nodeOffset() const
 
friend class MachOObjectFile
 
LLVM_ABI uint64_t other() const
 
LLVM_ABI StringRef sectionName() const
 
LLVM_ABI uint64_t segmentAddress() const
 
LLVM_ABI int32_t segmentIndex() const
 
LLVM_ABI uint64_t address() const
 
LLVM_ABI StringRef typeName() const
 
LLVM_ABI int64_t addend() const
 
LLVM_ABI MachOAbstractFixupEntry(Error *Err, const MachOObjectFile *O)
 
uint64_t textAddress() const
 
LLVM_ABI uint32_t flags() const
 
uint64_t pointerValue() const
 
uint64_t rawValue() const
 
LLVM_ABI StringRef symbolName() const
 
LLVM_ABI void moveToFirst()
 
LLVM_ABI int ordinal() const
 
LLVM_ABI StringRef segmentName() const
 
LLVM_ABI void moveToEnd()
 
const MachOObjectFile * O
 
LLVM_ABI uint64_t segmentOffset() const
 
MachOBindEntry encapsulates the current state in the decompression of binding opcodes.
 
LLVM_ABI uint32_t flags() const
 
LLVM_ABI bool operator==(const MachOBindEntry &) const
 
LLVM_ABI StringRef symbolName() const
 
LLVM_ABI int ordinal() const
 
LLVM_ABI StringRef sectionName() const
 
LLVM_ABI MachOBindEntry(Error *Err, const MachOObjectFile *O, ArrayRef< uint8_t > Opcodes, bool is64Bit, MachOBindEntry::Kind)
 
LLVM_ABI StringRef segmentName() const
 
LLVM_ABI uint64_t segmentOffset() const
 
LLVM_ABI int64_t addend() const
 
LLVM_ABI uint64_t address() const
 
friend class MachOObjectFile
 
LLVM_ABI int32_t segmentIndex() const
 
LLVM_ABI StringRef typeName() const
 
LLVM_ABI bool operator==(const MachOChainedFixupEntry &) const
 
LLVM_ABI MachOChainedFixupEntry(Error *Err, const MachOObjectFile *O, bool Parse)
 
LLVM_ABI void moveToEnd()
 
LLVM_ABI void moveToFirst()
 
void moveSectionNext(DataRefImpl &Sec) const override
 
static std::string getVersionString(uint32_t version)
 
MachO::mach_header_64 Header64
 
bool isSectionData(DataRefImpl Sec) const override
 
uint64_t getSectionAlignment(DataRefImpl Sec) const override
 
Expected< SectionRef > getSection(unsigned SectionIndex) const
 
std::error_code getIndirectName(DataRefImpl Symb, StringRef &Res) const
 
Expected< section_iterator > getSymbolSection(DataRefImpl Symb) const override
 
const char * RebaseEntryCheckSegAndOffsets(int32_t SegIndex, uint64_t SegOffset, uint8_t PointerSize, uint64_t Count=1, uint64_t Skip=0) const
 
void moveSymbolNext(DataRefImpl &Symb) const override
 
MachO::mach_header Header
 
uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override
 
relocation_iterator section_rel_begin(DataRefImpl Sec) const override
 
static std::string getBuildTool(uint32_t tools)
 
ArrayRef< uint8_t > getSectionContents(uint32_t Offset, uint64_t Size) const
 
const char * BindEntryCheckSegAndOffsets(int32_t SegIndex, uint64_t SegOffset, uint8_t PointerSize, uint64_t Count=1, uint64_t Skip=0) const
 
Error checkSymbolTable() const
 
static std::string getBuildPlatform(uint32_t platform)
 
relocation_iterator section_rel_end(DataRefImpl Sec) const override
 
static bool classof(const Binary *v)
 
unsigned getSectionType(SectionRef Sec) const
 
static Expected< std::unique_ptr< MachOObjectFile > > create(MemoryBufferRef Object, bool IsLittleEndian, bool Is64Bits, uint32_t UniversalCputype=0, uint32_t UniversalIndex=0, size_t MachOFilesetEntryOffset=0)
 
Expected< uint32_t > getSymbolFlags(DataRefImpl Symb) const override
 
bool isSectionBSS(DataRefImpl Sec) const override
 
bool isSectionVirtual(DataRefImpl Sec) const override
 
LoadCommandList::const_iterator load_command_iterator
 
iterator_range< relocation_iterator > external_relocations() const
 
static bool isMachOPairedReloc(uint64_t RelocType, uint64_t Arch)
 
static uint32_t getVersionMinUpdate(MachO::version_min_command &C, bool SDK)
 
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.
 
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.
 
relocation_iterator extrel_begin() const
 
SmallVector< LoadCommandInfo, 4 > LoadCommandList
 
MachO::data_in_code_entry getDice(DataRefImpl Rel) const
 
bool isSectionStripped(DataRefImpl Sec) const override
When dsymutil generates the companion file, it strips all unnecessary sections (e....
 
uint64_t getSectionIndex(DataRefImpl Sec) const override
 
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 ...
 
static uint32_t getVersionMinMajor(MachO::version_min_command &C, bool SDK)
 
uint64_t getSectionAddress(DataRefImpl Sec) const override
 
bool hasPageZeroSegment() const
 
Expected< StringRef > getSectionName(DataRefImpl Sec) const override
 
bool isSectionText(DataRefImpl Sec) const override
 
bool isSectionCompressed(DataRefImpl Sec) const override
 
bool isSectionBitcode(DataRefImpl Sec) const override
 
Expected< SubtargetFeatures > getFeatures() const override
 
uint32_t getSymbolAlignment(DataRefImpl Symb) const override
 
uint64_t getNValue(DataRefImpl Sym) const
 
ArrayRef< uint8_t > getSegmentContents(StringRef SegmentName) const
Return the raw contents of an entire segment.
 
static uint32_t getVersionMinMinor(MachO::version_min_command &C, bool SDK)
 
Expected< uint64_t > getSymbolAddress(DataRefImpl Symb) const override
 
size_t getMachOFilesetEntryOffset() const
 
uint64_t getSectionSize(DataRefImpl Sec) const override
 
relocation_iterator extrel_end() const
 
LLVM_ABI int32_t segmentIndex() const
 
LLVM_ABI StringRef segmentName() const
 
LLVM_ABI MachORebaseEntry(Error *Err, const MachOObjectFile *O, ArrayRef< uint8_t > opcodes, bool is64Bit)
 
LLVM_ABI bool operator==(const MachORebaseEntry &) const
 
LLVM_ABI uint64_t address() const
 
LLVM_ABI StringRef sectionName() const
 
friend class MachOObjectFile
 
LLVM_ABI uint64_t segmentOffset() const
 
LLVM_ABI StringRef typeName() const
 
This class is the base class for all object file types.
 
ObjectFile(unsigned int Type, MemoryBufferRef Source)
 
This is a value type class that represents a single section in the list of sections in the object fil...
 
A raw_ostream that writes to an std::string.
 
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
 
@ C
The default llvm calling convention, compatible with C.
 
@ BIND_SPECIAL_DYLIB_WEAK_LOOKUP
 
Expected< const typename ELFT::Shdr * > getSection(typename ELFT::ShdrRange Sections, uint32_t Index)
 
content_iterator< SectionRef > section_iterator
 
content_iterator< MachOBindEntry > bind_iterator
 
content_iterator< MachOChainedFixupEntry > fixup_iterator
 
content_iterator< MachORebaseEntry > rebase_iterator
 
content_iterator< BasicSymbolRef > basic_symbol_iterator
 
content_iterator< ExportEntry > export_iterator
 
content_iterator< RelocationRef > relocation_iterator
 
content_iterator< DiceRef > dice_iterator
 
This is an optimization pass for GlobalISel generic memory operations.
 
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
 
std::string utostr(uint64_t X, bool isNeg=false)
 
FunctionAddr VTableAddr uintptr_t uintptr_t Version
 
static Lanai::Fixups FixupKind(const MCExpr *Expr)
 
FunctionAddr VTableAddr Count
 
FormattedNumber format_hex(uint64_t N, unsigned Width, bool Upper=false)
format_hex - Output N as a fixed width hexadecimal.
 
ChainedFixupTarget(int LibOrdinal, uint32_t NameOffset, StringRef Symbol, uint64_t Addend, bool WeakImport)
 
MachO::dyld_chained_starts_in_segment Header
 
std::vector< uint16_t > PageStarts
 
ChainedFixupsSegment(uint8_t SegIdx, uint32_t Offset, const MachO::dyld_chained_starts_in_segment &Header, std::vector< uint16_t > &&PageStarts)