llvm/llvm/lib/Object/MachOObjectFile.cpp

//===- MachOObjectFile.cpp - Mach-O object file binding -------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines the MachOObjectFile class, which binds the MachOObject
// class to the generic ObjectFile wrapper.
//
//===----------------------------------------------------------------------===//

#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Twine.h"
#include "llvm/ADT/bit.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/BinaryFormat/Swift.h"
#include "llvm/Object/Error.h"
#include "llvm/Object/MachO.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Object/SymbolicFile.h"
#include "llvm/Support/DataExtractor.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/MemoryBufferRef.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/SwapByteOrder.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/TargetParser/Triple.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <limits>
#include <list>
#include <memory>
#include <system_error>

usingnamespacellvm;
usingnamespaceobject;

namespace {

  struct section_base {};

} // end anonymous namespace

static Error malformedError(const Twine &Msg) {}

// FIXME: Replace all uses of this function with getStructOrErr.
template <typename T>
static T getStruct(const MachOObjectFile &O, const char *P) {}

template <typename T>
static Expected<T> getStructOrErr(const MachOObjectFile &O, const char *P) {}

static const char *
getSectionPtr(const MachOObjectFile &O, MachOObjectFile::LoadCommandInfo L,
              unsigned Sec) {}

static const char *getPtr(const MachOObjectFile &O, size_t Offset,
                          size_t MachOFilesetEntryOffset = 0) {}

static MachO::nlist_base
getSymbolTableEntryBase(const MachOObjectFile &O, DataRefImpl DRI) {}

static StringRef parseSegmentOrSectionName(const char *P) {}

static unsigned getCPUType(const MachOObjectFile &O) {}

static unsigned getCPUSubType(const MachOObjectFile &O) {}

static uint32_t
getPlainRelocationAddress(const MachO::any_relocation_info &RE) {}

static unsigned
getScatteredRelocationAddress(const MachO::any_relocation_info &RE) {}

static bool getPlainRelocationPCRel(const MachOObjectFile &O,
                                    const MachO::any_relocation_info &RE) {}

static bool
getScatteredRelocationPCRel(const MachO::any_relocation_info &RE) {}

static unsigned getPlainRelocationLength(const MachOObjectFile &O,
                                         const MachO::any_relocation_info &RE) {}

static unsigned
getScatteredRelocationLength(const MachO::any_relocation_info &RE) {}

static unsigned getPlainRelocationType(const MachOObjectFile &O,
                                       const MachO::any_relocation_info &RE) {}

static uint32_t getSectionFlags(const MachOObjectFile &O,
                                DataRefImpl Sec) {}

static Expected<MachOObjectFile::LoadCommandInfo>
getLoadCommandInfo(const MachOObjectFile &Obj, const char *Ptr,
                   uint32_t LoadCommandIndex) {}

static Expected<MachOObjectFile::LoadCommandInfo>
getFirstLoadCommandInfo(const MachOObjectFile &Obj) {}

static Expected<MachOObjectFile::LoadCommandInfo>
getNextLoadCommandInfo(const MachOObjectFile &Obj, uint32_t LoadCommandIndex,
                       const MachOObjectFile::LoadCommandInfo &L) {}

template <typename T>
static void parseHeader(const MachOObjectFile &Obj, T &Header,
                        Error &Err) {}

// This is used to check for overlapping of Mach-O elements.
struct MachOElement {};

static Error checkOverlappingElement(std::list<MachOElement> &Elements,
                                     uint64_t Offset, uint64_t Size,
                                     const char *Name) {}

// Parses LC_SEGMENT or LC_SEGMENT_64 load command, adds addresses of all
// sections to \param Sections, and optionally sets
// \param IsPageZeroSegment to true.
template <typename Segment, typename Section>
static Error parseSegmentLoadCommand(
    const MachOObjectFile &Obj, const MachOObjectFile::LoadCommandInfo &Load,
    SmallVectorImpl<const char *> &Sections, bool &IsPageZeroSegment,
    uint32_t LoadCommandIndex, const char *CmdName, uint64_t SizeOfHeaders,
    std::list<MachOElement> &Elements) {}

static Error checkSymtabCommand(const MachOObjectFile &Obj,
                                const MachOObjectFile::LoadCommandInfo &Load,
                                uint32_t LoadCommandIndex,
                                const char **SymtabLoadCmd,
                                std::list<MachOElement> &Elements) {}

static Error checkDysymtabCommand(const MachOObjectFile &Obj,
                                  const MachOObjectFile::LoadCommandInfo &Load,
                                  uint32_t LoadCommandIndex,
                                  const char **DysymtabLoadCmd,
                                  std::list<MachOElement> &Elements) {}

static Error checkLinkeditDataCommand(const MachOObjectFile &Obj,
                                 const MachOObjectFile::LoadCommandInfo &Load,
                                 uint32_t LoadCommandIndex,
                                 const char **LoadCmd, const char *CmdName,
                                 std::list<MachOElement> &Elements,
                                 const char *ElementName) {}

static Error checkDyldInfoCommand(const MachOObjectFile &Obj,
                                  const MachOObjectFile::LoadCommandInfo &Load,
                                  uint32_t LoadCommandIndex,
                                  const char **LoadCmd, const char *CmdName,
                                  std::list<MachOElement> &Elements) {}

static Error checkDylibCommand(const MachOObjectFile &Obj,
                               const MachOObjectFile::LoadCommandInfo &Load,
                               uint32_t LoadCommandIndex, const char *CmdName) {}

static Error checkDylibIdCommand(const MachOObjectFile &Obj,
                                 const MachOObjectFile::LoadCommandInfo &Load,
                                 uint32_t LoadCommandIndex,
                                 const char **LoadCmd) {}

static Error checkDyldCommand(const MachOObjectFile &Obj,
                              const MachOObjectFile::LoadCommandInfo &Load,
                              uint32_t LoadCommandIndex, const char *CmdName) {}

static Error checkVersCommand(const MachOObjectFile &Obj,
                              const MachOObjectFile::LoadCommandInfo &Load,
                              uint32_t LoadCommandIndex,
                              const char **LoadCmd, const char *CmdName) {}

static Error checkNoteCommand(const MachOObjectFile &Obj,
                              const MachOObjectFile::LoadCommandInfo &Load,
                              uint32_t LoadCommandIndex,
                              std::list<MachOElement> &Elements) {}

static Error
parseBuildVersionCommand(const MachOObjectFile &Obj,
                         const MachOObjectFile::LoadCommandInfo &Load,
                         SmallVectorImpl<const char*> &BuildTools,
                         uint32_t LoadCommandIndex) {}

static Error checkRpathCommand(const MachOObjectFile &Obj,
                               const MachOObjectFile::LoadCommandInfo &Load,
                               uint32_t LoadCommandIndex) {}

static Error checkEncryptCommand(const MachOObjectFile &Obj,
                                 const MachOObjectFile::LoadCommandInfo &Load,
                                 uint32_t LoadCommandIndex,
                                 uint64_t cryptoff, uint64_t cryptsize,
                                 const char **LoadCmd, const char *CmdName) {}

static Error checkLinkerOptCommand(const MachOObjectFile &Obj,
                                   const MachOObjectFile::LoadCommandInfo &Load,
                                   uint32_t LoadCommandIndex) {}

static Error checkSubCommand(const MachOObjectFile &Obj,
                             const MachOObjectFile::LoadCommandInfo &Load,
                             uint32_t LoadCommandIndex, const char *CmdName,
                             size_t SizeOfCmd, const char *CmdStructName,
                             uint32_t PathOffset, const char *PathFieldName) {}

static Error checkThreadCommand(const MachOObjectFile &Obj,
                                const MachOObjectFile::LoadCommandInfo &Load,
                                uint32_t LoadCommandIndex,
                                const char *CmdName) {}

static Error checkTwoLevelHintsCommand(const MachOObjectFile &Obj,
                                       const MachOObjectFile::LoadCommandInfo
                                         &Load,
                                       uint32_t LoadCommandIndex,
                                       const char **LoadCmd,
                                       std::list<MachOElement> &Elements) {}

// Returns true if the libObject code does not support the load command and its
// contents.  The cmd value it is treated as an unknown load command but with
// an error message that says the cmd value is obsolete.
static bool isLoadCommandObsolete(uint32_t cmd) {}

Expected<std::unique_ptr<MachOObjectFile>>
MachOObjectFile::create(MemoryBufferRef Object, bool IsLittleEndian,
                        bool Is64Bits, uint32_t UniversalCputype,
                        uint32_t UniversalIndex,
                        size_t MachOFilesetEntryOffset) {}

MachOObjectFile::MachOObjectFile(MemoryBufferRef Object, bool IsLittleEndian,
                                 bool Is64bits, Error &Err,
                                 uint32_t UniversalCputype,
                                 uint32_t UniversalIndex,
                                 size_t MachOFilesetEntryOffset)
    :{}

Error MachOObjectFile::checkSymbolTable() const {}

void MachOObjectFile::moveSymbolNext(DataRefImpl &Symb) const {}

Expected<StringRef> MachOObjectFile::getSymbolName(DataRefImpl Symb) const {}

unsigned MachOObjectFile::getSectionType(SectionRef Sec) const {}

uint64_t MachOObjectFile::getNValue(DataRefImpl Sym) const {}

// getIndirectName() returns the name of the alias'ed symbol who's string table
// index is in the n_value field.
std::error_code MachOObjectFile::getIndirectName(DataRefImpl Symb,
                                                 StringRef &Res) const {}

uint64_t MachOObjectFile::getSymbolValueImpl(DataRefImpl Sym) const {}

Expected<uint64_t> MachOObjectFile::getSymbolAddress(DataRefImpl Sym) const {}

uint32_t MachOObjectFile::getSymbolAlignment(DataRefImpl DRI) const {}

uint64_t MachOObjectFile::getCommonSymbolSizeImpl(DataRefImpl DRI) const {}

Expected<SymbolRef::Type>
MachOObjectFile::getSymbolType(DataRefImpl Symb) const {}

Expected<uint32_t> MachOObjectFile::getSymbolFlags(DataRefImpl DRI) const {}

Expected<section_iterator>
MachOObjectFile::getSymbolSection(DataRefImpl Symb) const {}

unsigned MachOObjectFile::getSymbolSectionID(SymbolRef Sym) const {}

void MachOObjectFile::moveSectionNext(DataRefImpl &Sec) const {}

Expected<StringRef> MachOObjectFile::getSectionName(DataRefImpl Sec) const {}

uint64_t MachOObjectFile::getSectionAddress(DataRefImpl Sec) const {}

uint64_t MachOObjectFile::getSectionIndex(DataRefImpl Sec) const {}

uint64_t MachOObjectFile::getSectionSize(DataRefImpl Sec) const {}

ArrayRef<uint8_t> MachOObjectFile::getSectionContents(uint32_t Offset,
                                                      uint64_t Size) const {}

Expected<ArrayRef<uint8_t>>
MachOObjectFile::getSectionContents(DataRefImpl Sec) const {}

uint64_t MachOObjectFile::getSectionAlignment(DataRefImpl Sec) const {}

Expected<SectionRef> MachOObjectFile::getSection(unsigned SectionIndex) const {}

Expected<SectionRef> MachOObjectFile::getSection(StringRef SectionName) const {}

bool MachOObjectFile::isSectionCompressed(DataRefImpl Sec) const {}

bool MachOObjectFile::isSectionText(DataRefImpl Sec) const {}

bool MachOObjectFile::isSectionData(DataRefImpl Sec) const {}

bool MachOObjectFile::isSectionBSS(DataRefImpl Sec) const {}

bool MachOObjectFile::isDebugSection(DataRefImpl Sec) const {}

namespace {
template <typename LoadCommandType>
ArrayRef<uint8_t> getSegmentContents(const MachOObjectFile &Obj,
                                     MachOObjectFile::LoadCommandInfo LoadCmd,
                                     StringRef SegmentName) {}

template <typename LoadCommandType>
ArrayRef<uint8_t> getSegmentContents(const MachOObjectFile &Obj,
                                     MachOObjectFile::LoadCommandInfo LoadCmd) {}
} // namespace

ArrayRef<uint8_t>
MachOObjectFile::getSegmentContents(StringRef SegmentName) const {}

ArrayRef<uint8_t>
MachOObjectFile::getSegmentContents(size_t SegmentIndex) const {}

unsigned MachOObjectFile::getSectionID(SectionRef Sec) const {}

bool MachOObjectFile::isSectionVirtual(DataRefImpl Sec) const {}

bool MachOObjectFile::isSectionBitcode(DataRefImpl Sec) const {}

bool MachOObjectFile::isSectionStripped(DataRefImpl Sec) const {}

relocation_iterator MachOObjectFile::section_rel_begin(DataRefImpl Sec) const {}

relocation_iterator
MachOObjectFile::section_rel_end(DataRefImpl Sec) const {}

relocation_iterator MachOObjectFile::extrel_begin() const {}

relocation_iterator MachOObjectFile::extrel_end() const {}

relocation_iterator MachOObjectFile::locrel_begin() const {}

relocation_iterator MachOObjectFile::locrel_end() const {}

void MachOObjectFile::moveRelocationNext(DataRefImpl &Rel) const {}

uint64_t MachOObjectFile::getRelocationOffset(DataRefImpl Rel) const {}

symbol_iterator
MachOObjectFile::getRelocationSymbol(DataRefImpl Rel) const {}

section_iterator
MachOObjectFile::getRelocationSection(DataRefImpl Rel) const {}

uint64_t MachOObjectFile::getRelocationType(DataRefImpl Rel) const {}

void MachOObjectFile::getRelocationTypeName(
    DataRefImpl Rel, SmallVectorImpl<char> &Result) const {}

uint8_t MachOObjectFile::getRelocationLength(DataRefImpl Rel) const {}

//
// guessLibraryShortName() is passed a name of a dynamic library and returns a
// guess on what the short name is.  Then name is returned as a substring of the
// StringRef Name passed in.  The name of the dynamic library is recognized as
// a framework if it has one of the two following forms:
//      Foo.framework/Versions/A/Foo
//      Foo.framework/Foo
// Where A and Foo can be any string.  And may contain a trailing suffix
// starting with an underbar.  If the Name is recognized as a framework then
// isFramework is set to true else it is set to false.  If the Name has a
// suffix then Suffix is set to the substring in Name that contains the suffix
// else it is set to a NULL StringRef.
//
// The Name of the dynamic library is recognized as a library name if it has
// one of the two following forms:
//      libFoo.A.dylib
//      libFoo.dylib
//
// The library may have a suffix trailing the name Foo of the form:
//      libFoo_profile.A.dylib
//      libFoo_profile.dylib
// These dyld image suffixes are separated from the short name by a '_'
// character. Because the '_' character is commonly used to separate words in
// filenames guessLibraryShortName() cannot reliably separate a dylib's short
// name from an arbitrary image suffix; imagine if both the short name and the
// suffix contains an '_' character! To better deal with this ambiguity,
// guessLibraryShortName() will recognize only "_debug" and "_profile" as valid
// Suffix values. Calling code needs to be tolerant of guessLibraryShortName()
// guessing incorrectly.
//
// The Name of the dynamic library is also recognized as a library name if it
// has the following form:
//      Foo.qtx
//
// If the Name of the dynamic library is none of the forms above then a NULL
// StringRef is returned.
StringRef MachOObjectFile::guessLibraryShortName(StringRef Name,
                                                 bool &isFramework,
                                                 StringRef &Suffix) {}

// getLibraryShortNameByIndex() is used to get the short name of the library
// for an undefined symbol in a linked Mach-O binary that was linked with the
// normal two-level namespace default (that is MH_TWOLEVEL in the header).
// It is passed the index (0 - based) of the library as translated from
// GET_LIBRARY_ORDINAL (1 - based).
std::error_code MachOObjectFile::getLibraryShortNameByIndex(unsigned Index,
                                                         StringRef &Res) const {}

uint32_t MachOObjectFile::getLibraryCount() const {}

section_iterator
MachOObjectFile::getRelocationRelocatedSection(relocation_iterator Rel) const {}

basic_symbol_iterator MachOObjectFile::symbol_begin() const {}

basic_symbol_iterator MachOObjectFile::symbol_end() const {}

symbol_iterator MachOObjectFile::getSymbolByIndex(unsigned Index) const {}

uint64_t MachOObjectFile::getSymbolIndex(DataRefImpl Symb) const {}

section_iterator MachOObjectFile::section_begin() const {}

section_iterator MachOObjectFile::section_end() const {}

uint8_t MachOObjectFile::getBytesInAddress() const {}

StringRef MachOObjectFile::getFileFormatName() const {}

Triple::ArchType MachOObjectFile::getArch(uint32_t CPUType, uint32_t CPUSubType) {}

Triple MachOObjectFile::getArchTriple(uint32_t CPUType, uint32_t CPUSubType,
                                      const char **McpuDefault,
                                      const char **ArchFlag) {}

Triple MachOObjectFile::getHostArch() {}

bool MachOObjectFile::isValidArch(StringRef ArchFlag) {}

ArrayRef<StringRef> MachOObjectFile::getValidArchs() {}

Triple::ArchType MachOObjectFile::getArch() const {}

Triple MachOObjectFile::getArchTriple(const char **McpuDefault) const {}

relocation_iterator MachOObjectFile::section_rel_begin(unsigned Index) const {}

relocation_iterator MachOObjectFile::section_rel_end(unsigned Index) const {}

dice_iterator MachOObjectFile::begin_dices() const {}

dice_iterator MachOObjectFile::end_dices() const {}

ExportEntry::ExportEntry(Error *E, const MachOObjectFile *O,
                         ArrayRef<uint8_t> T) :{}

void ExportEntry::moveToFirst() {}

void ExportEntry::moveToEnd() {}

bool ExportEntry::operator==(const ExportEntry &Other) const {}

uint64_t ExportEntry::readULEB128(const uint8_t *&Ptr, const char **error) {}

StringRef ExportEntry::name() const {}

uint64_t ExportEntry::flags() const {}

uint64_t ExportEntry::address() const {}

uint64_t ExportEntry::other() const {}

StringRef ExportEntry::otherName() const {}

uint32_t ExportEntry::nodeOffset() const {}

ExportEntry::NodeState::NodeState(const uint8_t *Ptr)
    :{}

void ExportEntry::pushNode(uint64_t offset) {}

void ExportEntry::pushDownUntilBottom() {}

// We have a trie data structure and need a way to walk it that is compatible
// with the C++ iterator model. The solution is a non-recursive depth first
// traversal where the iterator contains a stack of parent nodes along with a
// string that is the accumulation of all edge strings along the parent chain
// to this point.
//
// There is one "export" node for each exported symbol.  But because some
// symbols may be a prefix of another symbol (e.g. _dup and _dup2), an export
// node may have child nodes too.
//
// The algorithm for moveNext() is to keep moving down the leftmost unvisited
// child until hitting a node with no children (which is an export node or
// else the trie is malformed). On the way down, each node is pushed on the
// stack ivar.  If there is no more ways down, it pops up one and tries to go
// down a sibling path until a childless node is reached.
void ExportEntry::moveNext() {}

iterator_range<export_iterator>
MachOObjectFile::exports(Error &E, ArrayRef<uint8_t> Trie,
                         const MachOObjectFile *O) {}

iterator_range<export_iterator> MachOObjectFile::exports(Error &Err) const {}

MachOAbstractFixupEntry::MachOAbstractFixupEntry(Error *E,
                                                 const MachOObjectFile *O)
    :{}

int32_t MachOAbstractFixupEntry::segmentIndex() const {}

uint64_t MachOAbstractFixupEntry::segmentOffset() const {}

uint64_t MachOAbstractFixupEntry::segmentAddress() const {}

StringRef MachOAbstractFixupEntry::segmentName() const {}

StringRef MachOAbstractFixupEntry::sectionName() const {}

uint64_t MachOAbstractFixupEntry::address() const {}

StringRef MachOAbstractFixupEntry::symbolName() const {}

int64_t MachOAbstractFixupEntry::addend() const {}

uint32_t MachOAbstractFixupEntry::flags() const {}

int MachOAbstractFixupEntry::ordinal() const {}

StringRef MachOAbstractFixupEntry::typeName() const {}

void MachOAbstractFixupEntry::moveToFirst() {}

void MachOAbstractFixupEntry::moveToEnd() {}

void MachOAbstractFixupEntry::moveNext() {}

MachOChainedFixupEntry::MachOChainedFixupEntry(Error *E,
                                               const MachOObjectFile *O,
                                               bool Parse)
    :{}

void MachOChainedFixupEntry::findNextPageWithFixups() {}

void MachOChainedFixupEntry::moveToFirst() {}

void MachOChainedFixupEntry::moveToEnd() {}

void MachOChainedFixupEntry::moveNext() {}

bool MachOChainedFixupEntry::operator==(
    const MachOChainedFixupEntry &Other) const {}

MachORebaseEntry::MachORebaseEntry(Error *E, const MachOObjectFile *O,
                                   ArrayRef<uint8_t> Bytes, bool is64Bit)
    :{}

void MachORebaseEntry::moveToFirst() {}

void MachORebaseEntry::moveToEnd() {}

void MachORebaseEntry::moveNext() {}

uint64_t MachORebaseEntry::readULEB128(const char **error) {}

int32_t MachORebaseEntry::segmentIndex() const {}

uint64_t MachORebaseEntry::segmentOffset() const {}

StringRef MachORebaseEntry::typeName() const {}

// For use with the SegIndex of a checked Mach-O Rebase entry
// to get the segment name.
StringRef MachORebaseEntry::segmentName() const {}

// For use with a SegIndex,SegOffset pair from a checked Mach-O Rebase entry
// to get the section name.
StringRef MachORebaseEntry::sectionName() const {}

// For use with a SegIndex,SegOffset pair from a checked Mach-O Rebase entry
// to get the address.
uint64_t MachORebaseEntry::address() const {}

bool MachORebaseEntry::operator==(const MachORebaseEntry &Other) const {}

iterator_range<rebase_iterator>
MachOObjectFile::rebaseTable(Error &Err, MachOObjectFile *O,
                             ArrayRef<uint8_t> Opcodes, bool is64) {}

iterator_range<rebase_iterator> MachOObjectFile::rebaseTable(Error &Err) {}

MachOBindEntry::MachOBindEntry(Error *E, const MachOObjectFile *O,
                               ArrayRef<uint8_t> Bytes, bool is64Bit, Kind BK)
    :{}

void MachOBindEntry::moveToFirst() {}

void MachOBindEntry::moveToEnd() {}

void MachOBindEntry::moveNext() {}

uint64_t MachOBindEntry::readULEB128(const char **error) {}

int64_t MachOBindEntry::readSLEB128(const char **error) {}

int32_t MachOBindEntry::segmentIndex() const {}

uint64_t MachOBindEntry::segmentOffset() const {}

StringRef MachOBindEntry::typeName() const {}

StringRef MachOBindEntry::symbolName() const {}

int64_t MachOBindEntry::addend() const {}

uint32_t MachOBindEntry::flags() const {}

int MachOBindEntry::ordinal() const {}

// For use with the SegIndex of a checked Mach-O Bind entry
// to get the segment name.
StringRef MachOBindEntry::segmentName() const {}

// For use with a SegIndex,SegOffset pair from a checked Mach-O Bind entry
// to get the section name.
StringRef MachOBindEntry::sectionName() const {}

// For use with a SegIndex,SegOffset pair from a checked Mach-O Bind entry
// to get the address.
uint64_t MachOBindEntry::address() const {}

bool MachOBindEntry::operator==(const MachOBindEntry &Other) const {}

// Build table of sections so SegIndex/SegOffset pairs can be translated.
BindRebaseSegInfo::BindRebaseSegInfo(const object::MachOObjectFile *Obj) {}

// For use with a SegIndex, SegOffset, and PointerSize triple in
// MachOBindEntry::moveNext() to validate a MachOBindEntry or MachORebaseEntry.
//
// Given a SegIndex, SegOffset, and PointerSize, verify a valid section exists
// that fully contains a pointer at that location. Multiple fixups in a bind
// (such as with the BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB opcode) can
// be tested via the Count and Skip parameters.
const char *BindRebaseSegInfo::checkSegAndOffsets(int32_t SegIndex,
                                                  uint64_t SegOffset,
                                                  uint8_t PointerSize,
                                                  uint64_t Count,
                                                  uint64_t Skip) {}

// For use with the SegIndex of a checked Mach-O Bind or Rebase entry
// to get the segment name.
StringRef BindRebaseSegInfo::segmentName(int32_t SegIndex) {}

// For use with a SegIndex,SegOffset pair from a checked Mach-O Bind or Rebase
// to get the SectionInfo.
const BindRebaseSegInfo::SectionInfo &BindRebaseSegInfo::findSection(
                                     int32_t SegIndex, uint64_t SegOffset) {}

// For use with a SegIndex,SegOffset pair from a checked Mach-O Bind or Rebase
// entry to get the section name.
StringRef BindRebaseSegInfo::sectionName(int32_t SegIndex,
                                         uint64_t SegOffset) {}

// For use with a SegIndex,SegOffset pair from a checked Mach-O Bind or Rebase
// entry to get the address.
uint64_t BindRebaseSegInfo::address(uint32_t SegIndex, uint64_t OffsetInSeg) {}

iterator_range<bind_iterator>
MachOObjectFile::bindTable(Error &Err, MachOObjectFile *O,
                           ArrayRef<uint8_t> Opcodes, bool is64,
                           MachOBindEntry::Kind BKind) {}

iterator_range<bind_iterator> MachOObjectFile::bindTable(Error &Err) {}

iterator_range<bind_iterator> MachOObjectFile::lazyBindTable(Error &Err) {}

iterator_range<bind_iterator> MachOObjectFile::weakBindTable(Error &Err) {}

iterator_range<fixup_iterator> MachOObjectFile::fixupTable(Error &Err) {}

MachOObjectFile::load_command_iterator
MachOObjectFile::begin_load_commands() const {}

MachOObjectFile::load_command_iterator
MachOObjectFile::end_load_commands() const {}

iterator_range<MachOObjectFile::load_command_iterator>
MachOObjectFile::load_commands() const {}

StringRef
MachOObjectFile::getSectionFinalSegmentName(DataRefImpl Sec) const {}

ArrayRef<char>
MachOObjectFile::getSectionRawName(DataRefImpl Sec) const {}

ArrayRef<char>
MachOObjectFile::getSectionRawFinalSegmentName(DataRefImpl Sec) const {}

bool
MachOObjectFile::isRelocationScattered(const MachO::any_relocation_info &RE)
  const {}

unsigned MachOObjectFile::getPlainRelocationSymbolNum(
    const MachO::any_relocation_info &RE) const {}

bool MachOObjectFile::getPlainRelocationExternal(
    const MachO::any_relocation_info &RE) const {}

bool MachOObjectFile::getScatteredRelocationScattered(
    const MachO::any_relocation_info &RE) const {}

uint32_t MachOObjectFile::getScatteredRelocationValue(
    const MachO::any_relocation_info &RE) const {}

uint32_t MachOObjectFile::getScatteredRelocationType(
    const MachO::any_relocation_info &RE) const {}

unsigned MachOObjectFile::getAnyRelocationAddress(
    const MachO::any_relocation_info &RE) const {}

unsigned MachOObjectFile::getAnyRelocationPCRel(
    const MachO::any_relocation_info &RE) const {}

unsigned MachOObjectFile::getAnyRelocationLength(
    const MachO::any_relocation_info &RE) const {}

unsigned
MachOObjectFile::getAnyRelocationType(
                                   const MachO::any_relocation_info &RE) const {}

SectionRef
MachOObjectFile::getAnyRelocationSection(
                                   const MachO::any_relocation_info &RE) const {}

MachO::section MachOObjectFile::getSection(DataRefImpl DRI) const {}

MachO::section_64 MachOObjectFile::getSection64(DataRefImpl DRI) const {}

MachO::section MachOObjectFile::getSection(const LoadCommandInfo &L,
                                           unsigned Index) const {}

MachO::section_64 MachOObjectFile::getSection64(const LoadCommandInfo &L,
                                                unsigned Index) const {}

MachO::nlist
MachOObjectFile::getSymbolTableEntry(DataRefImpl DRI) const {}

MachO::nlist_64
MachOObjectFile::getSymbol64TableEntry(DataRefImpl DRI) const {}

MachO::linkedit_data_command
MachOObjectFile::getLinkeditDataLoadCommand(const LoadCommandInfo &L) const {}

MachO::segment_command
MachOObjectFile::getSegmentLoadCommand(const LoadCommandInfo &L) const {}

MachO::segment_command_64
MachOObjectFile::getSegment64LoadCommand(const LoadCommandInfo &L) const {}

MachO::linker_option_command
MachOObjectFile::getLinkerOptionLoadCommand(const LoadCommandInfo &L) const {}

MachO::version_min_command
MachOObjectFile::getVersionMinLoadCommand(const LoadCommandInfo &L) const {}

MachO::note_command
MachOObjectFile::getNoteLoadCommand(const LoadCommandInfo &L) const {}

MachO::build_version_command
MachOObjectFile::getBuildVersionLoadCommand(const LoadCommandInfo &L) const {}

MachO::build_tool_version
MachOObjectFile::getBuildToolVersion(unsigned index) const {}

MachO::dylib_command
MachOObjectFile::getDylibIDLoadCommand(const LoadCommandInfo &L) const {}

MachO::dyld_info_command
MachOObjectFile::getDyldInfoLoadCommand(const LoadCommandInfo &L) const {}

MachO::dylinker_command
MachOObjectFile::getDylinkerCommand(const LoadCommandInfo &L) const {}

MachO::uuid_command
MachOObjectFile::getUuidCommand(const LoadCommandInfo &L) const {}

MachO::rpath_command
MachOObjectFile::getRpathCommand(const LoadCommandInfo &L) const {}

MachO::source_version_command
MachOObjectFile::getSourceVersionCommand(const LoadCommandInfo &L) const {}

MachO::entry_point_command
MachOObjectFile::getEntryPointCommand(const LoadCommandInfo &L) const {}

MachO::encryption_info_command
MachOObjectFile::getEncryptionInfoCommand(const LoadCommandInfo &L) const {}

MachO::encryption_info_command_64
MachOObjectFile::getEncryptionInfoCommand64(const LoadCommandInfo &L) const {}

MachO::sub_framework_command
MachOObjectFile::getSubFrameworkCommand(const LoadCommandInfo &L) const {}

MachO::sub_umbrella_command
MachOObjectFile::getSubUmbrellaCommand(const LoadCommandInfo &L) const {}

MachO::sub_library_command
MachOObjectFile::getSubLibraryCommand(const LoadCommandInfo &L) const {}

MachO::sub_client_command
MachOObjectFile::getSubClientCommand(const LoadCommandInfo &L) const {}

MachO::routines_command
MachOObjectFile::getRoutinesCommand(const LoadCommandInfo &L) const {}

MachO::routines_command_64
MachOObjectFile::getRoutinesCommand64(const LoadCommandInfo &L) const {}

MachO::thread_command
MachOObjectFile::getThreadCommand(const LoadCommandInfo &L) const {}

MachO::fileset_entry_command
MachOObjectFile::getFilesetEntryLoadCommand(const LoadCommandInfo &L) const {}

MachO::any_relocation_info
MachOObjectFile::getRelocation(DataRefImpl Rel) const {}

MachO::data_in_code_entry
MachOObjectFile::getDice(DataRefImpl Rel) const {}

const MachO::mach_header &MachOObjectFile::getHeader() const {}

const MachO::mach_header_64 &MachOObjectFile::getHeader64() const {}

uint32_t MachOObjectFile::getIndirectSymbolTableEntry(
                                             const MachO::dysymtab_command &DLC,
                                             unsigned Index) const {}

MachO::data_in_code_entry
MachOObjectFile::getDataInCodeTableEntry(uint32_t DataOffset,
                                         unsigned Index) const {}

MachO::symtab_command MachOObjectFile::getSymtabLoadCommand() const {}

MachO::dysymtab_command MachOObjectFile::getDysymtabLoadCommand() const {}

MachO::linkedit_data_command
MachOObjectFile::getDataInCodeLoadCommand() const {}

MachO::linkedit_data_command
MachOObjectFile::getLinkOptHintsLoadCommand() const {}

ArrayRef<uint8_t> MachOObjectFile::getDyldInfoRebaseOpcodes() const {}

ArrayRef<uint8_t> MachOObjectFile::getDyldInfoBindOpcodes() const {}

ArrayRef<uint8_t> MachOObjectFile::getDyldInfoWeakBindOpcodes() const {}

ArrayRef<uint8_t> MachOObjectFile::getDyldInfoLazyBindOpcodes() const {}

ArrayRef<uint8_t> MachOObjectFile::getDyldInfoExportsTrie() const {}

Expected<std::optional<MachO::linkedit_data_command>>
MachOObjectFile::getChainedFixupsLoadCommand() const {}

Expected<std::optional<MachO::dyld_chained_fixups_header>>
MachOObjectFile::getChainedFixupsHeader() const {}

Expected<std::pair<size_t, std::vector<ChainedFixupsSegment>>>
MachOObjectFile::getChainedFixupsSegments() const {}

// The special library ordinals have a negative value, but they are encoded in
// an unsigned bitfield, so we need to sign extend the value.
template <typename T> static int getEncodedOrdinal(T Value) {}

template <typename T, unsigned N>
static std::array<T, N> getArray(const MachOObjectFile &O, const void *Ptr) {}

Expected<std::vector<ChainedFixupTarget>>
MachOObjectFile::getDyldChainedFixupTargets() const {}

ArrayRef<uint8_t> MachOObjectFile::getDyldExportsTrie() const {}

SmallVector<uint64_t> MachOObjectFile::getFunctionStarts() const {}

ArrayRef<uint8_t> MachOObjectFile::getUuid() const {}

StringRef MachOObjectFile::getStringTableData() const {}

bool MachOObjectFile::is64Bit() const {}

void MachOObjectFile::ReadULEB128s(uint64_t Index,
                                   SmallVectorImpl<uint64_t> &Out) const {}

bool MachOObjectFile::isRelocatableObject() const {}

/// Create a MachOObjectFile instance from a given buffer.
///
/// \param Buffer Memory buffer containing the MachO binary data.
/// \param UniversalCputype CPU type when the MachO part of a universal binary.
/// \param UniversalIndex Index of the MachO within a universal binary.
/// \param MachOFilesetEntryOffset Offset of the MachO entry in a fileset MachO.
/// \returns A std::unique_ptr to a MachOObjectFile instance on success.
Expected<std::unique_ptr<MachOObjectFile>> ObjectFile::createMachOObjectFile(
    MemoryBufferRef Buffer, uint32_t UniversalCputype, uint32_t UniversalIndex,
    size_t MachOFilesetEntryOffset) {}

StringRef MachOObjectFile::mapDebugSectionName(StringRef Name) const {}

Expected<std::vector<std::string>>
MachOObjectFile::findDsymObjectMembers(StringRef Path) {}

llvm::binaryformat::Swift5ReflectionSectionKind
MachOObjectFile::mapReflectionSectionNameToEnumValue(
    StringRef SectionName) const {}

bool MachOObjectFile::isMachOPairedReloc(uint64_t RelocType, uint64_t Arch) {}