llvm/llvm/tools/llvm-objdump/MachODump.cpp

//===-- MachODump.cpp - Object file dumping utility for llvm --------------===//
//
// 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 implements the MachO-specific dumper for llvm-objdump.
//
//===----------------------------------------------------------------------===//

#include "MachODump.h"

#include "ObjdumpOptID.h"
#include "llvm-objdump.h"
#include "llvm-c/Disassembler.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/Config/config.h"
#include "llvm/DebugInfo/DIContext.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/Demangle/Demangle.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDisassembler/MCDisassembler.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstPrinter.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCTargetOptions.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Object/MachO.h"
#include "llvm/Object/MachOUniversal.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/GraphWriter.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/WithColor.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Triple.h"
#include <algorithm>
#include <cstring>
#include <system_error>

usingnamespacellvm;
usingnamespacellvm::object;
usingnamespacellvm::objdump;

bool objdump::FirstPrivateHeader;
bool objdump::ExportsTrie;
bool objdump::Rebase;
bool objdump::Rpaths;
bool objdump::Bind;
bool objdump::LazyBind;
bool objdump::WeakBind;
static bool UseDbg;
static std::string DSYMFile;
bool objdump::FullLeadingAddr;
bool objdump::LeadingHeaders;
bool objdump::UniversalHeaders;
static bool ArchiveMemberOffsets;
bool objdump::IndirectSymbols;
bool objdump::DataInCode;
FunctionStartsMode objdump::FunctionStartsType =;
bool objdump::LinkOptHints;
bool objdump::InfoPlist;
bool objdump::ChainedFixups;
bool objdump::DyldInfo;
bool objdump::DylibsUsed;
bool objdump::DylibId;
bool objdump::Verbose;
bool objdump::ObjcMetaData;
std::string objdump::DisSymName;
bool objdump::SymbolicOperands;
static std::vector<std::string> ArchFlags;

static bool ArchAll =;
static std::string ThumbTripleName;

static StringRef ordinalName(const object::MachOObjectFile *, int);

void objdump::parseMachOOptions(const llvm::opt::InputArgList &InputArgs) {}

static const Target *GetTarget(const MachOObjectFile *MachOObj,
                               const char **McpuDefault,
                               const Target **ThumbTarget) {}

namespace {
struct SymbolSorter {};

class MachODumper : public Dumper {};
} // namespace

std::unique_ptr<Dumper>
objdump::createMachODumper(const object::MachOObjectFile &Obj) {}

// Types for the storted data in code table that is built before disassembly
// and the predicate function to sort them.
DiceTableEntry;
DiceTable;
dice_table_iterator;

// This is used to search for a data in code table entry for the PC being
// disassembled.  The j parameter has the PC in j.first.  A single data in code
// table entry can cover many bytes for each of its Kind's.  So if the offset,
// aka the i.first value, of the data in code table entry plus its Length
// covers the PC being searched for this will return true.  If not it will
// return false.
static bool compareDiceTableEntries(const DiceTableEntry &i,
                                    const DiceTableEntry &j) {}

static uint64_t DumpDataInCode(const uint8_t *bytes, uint64_t Length,
                               unsigned short Kind) {}

static void getSectionsAndSymbols(MachOObjectFile *MachOObj,
                                  std::vector<SectionRef> &Sections,
                                  std::vector<SymbolRef> &Symbols,
                                  SmallVectorImpl<uint64_t> &FoundFns,
                                  uint64_t &BaseSegmentAddress) {}

static bool DumpAndSkipDataInCode(uint64_t PC, const uint8_t *bytes,
                                 DiceTable &Dices, uint64_t &InstSize) {}

static void printRelocationTargetName(const MachOObjectFile *O,
                                      const MachO::any_relocation_info &RE,
                                      raw_string_ostream &Fmt) {}

Error objdump::getMachORelocationValueString(const MachOObjectFile *Obj,
                                             const RelocationRef &RelRef,
                                             SmallVectorImpl<char> &Result) {}

static void PrintIndirectSymbolTable(MachOObjectFile *O, bool verbose,
                                     uint32_t n, uint32_t count,
                                     uint32_t stride, uint64_t addr) {}

static void PrintIndirectSymbols(MachOObjectFile *O, bool verbose) {}

static void PrintRType(const uint64_t cputype, const unsigned r_type) {}

static void PrintRLength(const uint64_t cputype, const unsigned r_type,
                         const unsigned r_length, const bool previous_arm_half){}

static void PrintRelocationEntries(const MachOObjectFile *O,
                                   const relocation_iterator Begin,
                                   const relocation_iterator End,
                                   const uint64_t cputype,
                                   const bool verbose) {}

static void PrintRelocations(const MachOObjectFile *O, const bool verbose) {}

static void PrintFunctionStarts(MachOObjectFile *O) {}

static void PrintDataInCodeTable(MachOObjectFile *O, bool verbose) {}

static void PrintLinkOptHints(MachOObjectFile *O) {}

static SmallVector<std::string> GetSegmentNames(object::MachOObjectFile *O) {}

static void
PrintChainedFixupsHeader(const MachO::dyld_chained_fixups_header &H) {}

static constexpr std::array<StringRef, 13> PointerFormats{};

static void PrintChainedFixupsSegment(const ChainedFixupsSegment &Segment,
                                      StringRef SegName) {}

static void PrintChainedFixupTarget(ChainedFixupTarget &Target, size_t Idx,
                                    int Format, MachOObjectFile *O) {}

static void PrintChainedFixups(MachOObjectFile *O) {}

static void PrintDyldInfo(MachOObjectFile *O) {}

static void PrintDylibs(MachOObjectFile *O, bool JustId) {}

static void printRpaths(MachOObjectFile *O) {}

SymbolAddressMap;

static void CreateSymbolAddressMap(MachOObjectFile *O,
                                   SymbolAddressMap *AddrMap) {}

// GuessSymbolName is passed the address of what might be a symbol and a
// pointer to the SymbolAddressMap.  It returns the name of a symbol
// with that address or nullptr if no symbol is found with that address.
static const char *GuessSymbolName(uint64_t value, SymbolAddressMap *AddrMap) {}

static void DumpCstringChar(const char c) {}

static void DumpCstringSection(MachOObjectFile *O, const char *sect,
                               uint32_t sect_size, uint64_t sect_addr,
                               bool print_addresses) {}

static void DumpLiteral4(uint32_t l, float f) {}

static void DumpLiteral4Section(MachOObjectFile *O, const char *sect,
                                uint32_t sect_size, uint64_t sect_addr,
                                bool print_addresses) {}

static void DumpLiteral8(MachOObjectFile *O, uint32_t l0, uint32_t l1,
                         double d) {}

static void DumpLiteral8Section(MachOObjectFile *O, const char *sect,
                                uint32_t sect_size, uint64_t sect_addr,
                                bool print_addresses) {}

static void DumpLiteral16(uint32_t l0, uint32_t l1, uint32_t l2, uint32_t l3) {}

static void DumpLiteral16Section(MachOObjectFile *O, const char *sect,
                                 uint32_t sect_size, uint64_t sect_addr,
                                 bool print_addresses) {}

static void DumpLiteralPointerSection(MachOObjectFile *O,
                                      const SectionRef &Section,
                                      const char *sect, uint32_t sect_size,
                                      uint64_t sect_addr,
                                      bool print_addresses) {}

static void DumpInitTermPointerSection(MachOObjectFile *O,
                                       const SectionRef &Section,
                                       const char *sect,
                                       uint32_t sect_size, uint64_t sect_addr,
                                       SymbolAddressMap *AddrMap,
                                       bool verbose) {}

static void DumpRawSectionContents(MachOObjectFile *O, const char *sect,
                                   uint32_t size, uint64_t addr) {}

static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
                             StringRef DisSegName, StringRef DisSectName);
static void DumpProtocolSection(MachOObjectFile *O, const char *sect,
                                uint32_t size, uint32_t addr);
static void DumpSectionContents(StringRef Filename, MachOObjectFile *O,
                                bool verbose) {}

static void DumpInfoPlistSectionContents(StringRef Filename,
                                         MachOObjectFile *O) {}

// checkMachOAndArchFlags() checks to see if the ObjectFile is a Mach-O file
// and if it is and there is a list of architecture flags is specified then
// check to make sure this Mach-O file is one of those architectures or all
// architectures were specified.  If not then an error is generated and this
// routine returns false.  Else it returns true.
static bool checkMachOAndArchFlags(ObjectFile *O, StringRef Filename) {}

static void printObjcMetaData(MachOObjectFile *O, bool verbose);

// ProcessMachO() is passed a single opened Mach-O file, which may be an
// archive member and or in a slice of a universal file.  It prints the
// the file name and header info and then processes it according to the
// command line options.
static void ProcessMachO(StringRef Name, MachOObjectFile *MachOOF,
                         StringRef ArchiveMemberName = StringRef(),
                         StringRef ArchitectureName = StringRef()) {}

// printUnknownCPUType() helps print_fat_headers for unknown CPU's.
static void printUnknownCPUType(uint32_t cputype, uint32_t cpusubtype) {}

// printCPUType() helps print_fat_headers by printing the cputype and
// pusubtype (symbolically for the one's it knows about).
static void printCPUType(uint32_t cputype, uint32_t cpusubtype) {}

static void printMachOUniversalHeaders(const object::MachOUniversalBinary *UB,
                                       bool verbose) {}

static void printArchiveChild(StringRef Filename, const Archive::Child &C,
                              size_t ChildIndex, bool verbose,
                              bool print_offset,
                              StringRef ArchitectureName = StringRef()) {}

static void printArchiveHeaders(StringRef Filename, Archive *A, bool verbose,
                                bool print_offset,
                                StringRef ArchitectureName = StringRef()) {}

static bool ValidateArchFlags() {}

// ParseInputMachO() parses the named Mach-O file in Filename and handles the
// -arch flags selecting just those slices as specified by them and also parses
// archive files.  Then for each individual Mach-O file ProcessMachO() is
// called to process the file based on the command line options.
void objdump::parseInputMachO(StringRef Filename) {}

void objdump::parseInputMachO(MachOUniversalBinary *UB) {}

namespace {
// The block of info used by the Symbolizer call backs.
struct DisassembleInfo {};
} // namespace

// SymbolizerGetOpInfo() is the operand information call back function.
// This is called to get the symbolic information for operand(s) of an
// instruction when it is being done.  This routine does this from
// the relocation information, symbol table, etc. That block of information
// is a pointer to the struct DisassembleInfo that was passed when the
// disassembler context was created and passed to back to here when
// called back by the disassembler for instruction operands that could have
// relocation information. The address of the instruction containing operand is
// at the Pc parameter.  The immediate value the operand has is passed in
// op_info->Value and is at Offset past the start of the instruction and has a
// byte Size of 1, 2 or 4. The symbolc information is returned in TagBuf is the
// LLVMOpInfo1 struct defined in the header "llvm-c/Disassembler.h" as symbol
// names and addends of the symbolic expression to add for the operand.  The
// value of TagType is currently 1 (for the LLVMOpInfo1 struct). If symbolic
// information is returned then this function returns 1 else it returns 0.
static int SymbolizerGetOpInfo(void *DisInfo, uint64_t Pc, uint64_t Offset,
                               uint64_t OpSize, uint64_t InstSize, int TagType,
                               void *TagBuf) {}

// GuessCstringPointer is passed the address of what might be a pointer to a
// literal string in a cstring section.  If that address is in a cstring section
// it returns a pointer to that string.  Else it returns nullptr.
static const char *GuessCstringPointer(uint64_t ReferenceValue,
                                       struct DisassembleInfo *info) {}

// GuessIndirectSymbol returns the name of the indirect symbol for the
// ReferenceValue passed in or nullptr.  This is used when ReferenceValue maybe
// an address of a symbol stub or a lazy or non-lazy pointer to associate the
// symbol name being referenced by the stub or pointer.
static const char *GuessIndirectSymbol(uint64_t ReferenceValue,
                                       struct DisassembleInfo *info) {}

// method_reference() is called passing it the ReferenceName that might be
// a reference it to an Objective-C method call.  If so then it allocates and
// assembles a method call string with the values last seen and saved in
// the DisassembleInfo's class_name and selector_name fields.  This is saved
// into the method field of the info and any previous string is free'ed.
// Then the class_name field in the info is set to nullptr.  The method call
// string is set into ReferenceName and ReferenceType is set to
// LLVMDisassembler_ReferenceType_Out_Objc_Message.  If this not a method call
// then both ReferenceType and ReferenceName are left unchanged.
static void method_reference(struct DisassembleInfo *info,
                             uint64_t *ReferenceType,
                             const char **ReferenceName) {}

// GuessPointerPointer() is passed the address of what might be a pointer to
// a reference to an Objective-C class, selector, message ref or cfstring.
// If so the value of the pointer is returned and one of the booleans are set
// to true.  If not zero is returned and all the booleans are set to false.
static uint64_t GuessPointerPointer(uint64_t ReferenceValue,
                                    struct DisassembleInfo *info,
                                    bool &classref, bool &selref, bool &msgref,
                                    bool &cfstring) {}

// get_pointer_64 returns a pointer to the bytes in the object file at the
// Address from a section in the Mach-O file.  And indirectly returns the
// offset into the section, number of bytes left in the section past the offset
// and which section is was being referenced.  If the Address is not in a
// section nullptr is returned.
static const char *get_pointer_64(uint64_t Address, uint32_t &offset,
                                  uint32_t &left, SectionRef &S,
                                  DisassembleInfo *info,
                                  bool objc_only = false) {}

static const char *get_pointer_32(uint32_t Address, uint32_t &offset,
                                  uint32_t &left, SectionRef &S,
                                  DisassembleInfo *info,
                                  bool objc_only = false) {}

// get_symbol_64() returns the name of a symbol (or nullptr) and the address of
// the symbol indirectly through n_value. Based on the relocation information
// for the specified section offset in the specified section reference.
// If no relocation information is found and a non-zero ReferenceValue for the
// symbol is passed, look up that address in the info's AddrMap.
static const char *get_symbol_64(uint32_t sect_offset, SectionRef S,
                                 DisassembleInfo *info, uint64_t &n_value,
                                 uint64_t ReferenceValue = 0) {}

static const char *get_symbol_32(uint32_t sect_offset, SectionRef S,
                                 DisassembleInfo *info,
                                 uint32_t ReferenceValue) {}

namespace {

// These are structs in the Objective-C meta data and read to produce the
// comments for disassembly.  While these are part of the ABI they are no
// public defintions.  So the are here not in include/llvm/BinaryFormat/MachO.h
// .

// The cfstring object in a 64-bit Mach-O file.
struct cfstring64_t {};

// The class object in a 64-bit Mach-O file.
struct class64_t {};

struct class32_t {};

struct class_ro64_t {};

struct class_ro32_t {};

/* Values for class_ro{64,32}_t->flags */
#define RO_META
#define RO_ROOT
#define RO_HAS_CXX_STRUCTORS

/* Values for method_list{64,32}_t->entsize */
#define ML_HAS_RELATIVE_PTRS
#define ML_ENTSIZE_MASK

struct method_list64_t {};

struct method_list32_t {};

struct method64_t {};

struct method32_t {};

struct method_relative_t {};

struct protocol_list64_t {};

struct protocol_list32_t {};

struct protocol64_t {};

struct protocol32_t {};

struct ivar_list64_t {};

struct ivar_list32_t {};

struct ivar64_t {};

struct ivar32_t {};

struct objc_property_list64 {};

struct objc_property_list32 {};

struct objc_property64 {};

struct objc_property32 {};

struct category64_t {};

struct category32_t {};

struct objc_image_info64 {};
struct objc_image_info32 {};
struct imageInfo_t {};
/* masks for objc_image_info.flags */
#define OBJC_IMAGE_IS_REPLACEMENT
#define OBJC_IMAGE_SUPPORTS_GC
#define OBJC_IMAGE_IS_SIMULATED
#define OBJC_IMAGE_HAS_CATEGORY_CLASS_PROPERTIES

struct message_ref64 {};

struct message_ref32 {};

// Objective-C 1 (32-bit only) meta data structs.

struct objc_module_t {};

struct objc_symtab_t {};

struct objc_class_t {};

#define CLS_GETINFO(cls, infomask)
// class is not a metaclass
#define CLS_CLASS
// class is a metaclass
#define CLS_META

struct objc_category_t {};

struct objc_ivar_t {};

struct objc_ivar_list_t {};

struct objc_method_list_t {};

struct objc_method_t {};

struct objc_protocol_list_t {};

struct objc_protocol_t {};

struct objc_method_description_list_t {};

struct objc_method_description_t {};

inline void swapStruct(struct cfstring64_t &cfs) {}

inline void swapStruct(struct class64_t &c) {}

inline void swapStruct(struct class32_t &c) {}

inline void swapStruct(struct class_ro64_t &cro) {}

inline void swapStruct(struct class_ro32_t &cro) {}

inline void swapStruct(struct method_list64_t &ml) {}

inline void swapStruct(struct method_list32_t &ml) {}

inline void swapStruct(struct method64_t &m) {}

inline void swapStruct(struct method32_t &m) {}

inline void swapStruct(struct method_relative_t &m) {}

inline void swapStruct(struct protocol_list64_t &pl) {}

inline void swapStruct(struct protocol_list32_t &pl) {}

inline void swapStruct(struct protocol64_t &p) {}

inline void swapStruct(struct protocol32_t &p) {}

inline void swapStruct(struct ivar_list64_t &il) {}

inline void swapStruct(struct ivar_list32_t &il) {}

inline void swapStruct(struct ivar64_t &i) {}

inline void swapStruct(struct ivar32_t &i) {}

inline void swapStruct(struct objc_property_list64 &pl) {}

inline void swapStruct(struct objc_property_list32 &pl) {}

inline void swapStruct(struct objc_property64 &op) {}

inline void swapStruct(struct objc_property32 &op) {}

inline void swapStruct(struct category64_t &c) {}

inline void swapStruct(struct category32_t &c) {}

inline void swapStruct(struct objc_image_info64 &o) {}

inline void swapStruct(struct objc_image_info32 &o) {}

inline void swapStruct(struct imageInfo_t &o) {}

inline void swapStruct(struct message_ref64 &mr) {}

inline void swapStruct(struct message_ref32 &mr) {}

inline void swapStruct(struct objc_module_t &module) {}

inline void swapStruct(struct objc_symtab_t &symtab) {}

inline void swapStruct(struct objc_class_t &objc_class) {}

inline void swapStruct(struct objc_category_t &objc_category) {}

inline void swapStruct(struct objc_ivar_list_t &objc_ivar_list) {}

inline void swapStruct(struct objc_ivar_t &objc_ivar) {}

inline void swapStruct(struct objc_method_list_t &method_list) {}

inline void swapStruct(struct objc_method_t &method) {}

inline void swapStruct(struct objc_protocol_list_t &protocol_list) {}

inline void swapStruct(struct objc_protocol_t &protocol) {}

inline void swapStruct(struct objc_method_description_list_t &mdl) {}

inline void swapStruct(struct objc_method_description_t &md) {}

} // namespace

static const char *get_dyld_bind_info_symbolname(uint64_t ReferenceValue,
                                                 struct DisassembleInfo *info);

// get_objc2_64bit_class_name() is used for disassembly and is passed a pointer
// to an Objective-C class and returns the class name.  It is also passed the
// address of the pointer, so when the pointer is zero as it can be in an .o
// file, that is used to look for an external relocation entry with a symbol
// name.
static const char *get_objc2_64bit_class_name(uint64_t pointer_value,
                                              uint64_t ReferenceValue,
                                              struct DisassembleInfo *info) {}

// get_objc2_64bit_cfstring_name is used for disassembly and is passed a
// pointer to a cfstring and returns its name or nullptr.
static const char *get_objc2_64bit_cfstring_name(uint64_t ReferenceValue,
                                                 struct DisassembleInfo *info) {}

// get_objc2_64bit_selref() is used for disassembly and is passed a the address
// of a pointer to an Objective-C selector reference when the pointer value is
// zero as in a .o file and is likely to have a external relocation entry with
// who's symbol's n_value is the real pointer to the selector name.  If that is
// the case the real pointer to the selector name is returned else 0 is
// returned
static uint64_t get_objc2_64bit_selref(uint64_t ReferenceValue,
                                       struct DisassembleInfo *info) {}

static const SectionRef get_section(MachOObjectFile *O, const char *segname,
                                    const char *sectname) {}

static void
walk_pointer_list_64(const char *listname, const SectionRef S,
                     MachOObjectFile *O, struct DisassembleInfo *info,
                     void (*func)(uint64_t, struct DisassembleInfo *info)) {}

static void
walk_pointer_list_32(const char *listname, const SectionRef S,
                     MachOObjectFile *O, struct DisassembleInfo *info,
                     void (*func)(uint32_t, struct DisassembleInfo *info)) {}

static void print_layout_map(const char *layout_map, uint32_t left) {}

static void print_layout_map64(uint64_t p, struct DisassembleInfo *info) {}

static void print_layout_map32(uint32_t p, struct DisassembleInfo *info) {}

static void print_relative_method_list(uint32_t structSizeAndFlags,
                                       uint32_t structCount, uint64_t p,
                                       struct DisassembleInfo *info,
                                       const char *indent,
                                       uint32_t pointerBits) {}

static void print_method_list64_t(uint64_t p, struct DisassembleInfo *info,
                                  const char *indent) {}

static void print_method_list32_t(uint64_t p, struct DisassembleInfo *info,
                                  const char *indent) {}

static bool print_method_list(uint32_t p, struct DisassembleInfo *info) {}

static void print_protocol_list64_t(uint64_t p, struct DisassembleInfo *info) {}

static void print_protocol_list32_t(uint32_t p, struct DisassembleInfo *info) {}

static void print_indent(uint32_t indent) {}

static bool print_method_description_list(uint32_t p, uint32_t indent,
                                          struct DisassembleInfo *info) {}

static bool print_protocol_list(uint32_t p, uint32_t indent,
                                struct DisassembleInfo *info);

static bool print_protocol(uint32_t p, uint32_t indent,
                           struct DisassembleInfo *info) {}

static bool print_protocol_list(uint32_t p, uint32_t indent,
                                struct DisassembleInfo *info) {}

static void print_ivar_list64_t(uint64_t p, struct DisassembleInfo *info) {}

static void print_ivar_list32_t(uint32_t p, struct DisassembleInfo *info) {}

static void print_objc_property_list64(uint64_t p,
                                       struct DisassembleInfo *info) {}

static void print_objc_property_list32(uint32_t p,
                                       struct DisassembleInfo *info) {}

static bool print_class_ro64_t(uint64_t p, struct DisassembleInfo *info,
                               bool &is_meta_class) {}

static bool print_class_ro32_t(uint32_t p, struct DisassembleInfo *info,
                               bool &is_meta_class) {}

static void print_class64_t(uint64_t p, struct DisassembleInfo *info) {}

static void print_class32_t(uint32_t p, struct DisassembleInfo *info) {}

static void print_objc_class_t(struct objc_class_t *objc_class,
                               struct DisassembleInfo *info) {}

static void print_objc_objc_category_t(struct objc_category_t *objc_category,
                                       struct DisassembleInfo *info) {}

static void print_category64_t(uint64_t p, struct DisassembleInfo *info) {}

static void print_category32_t(uint32_t p, struct DisassembleInfo *info) {}

static void print_message_refs64(SectionRef S, struct DisassembleInfo *info) {}

static void print_message_refs32(SectionRef S, struct DisassembleInfo *info) {}

static void print_image_info64(SectionRef S, struct DisassembleInfo *info) {}

static void print_image_info32(SectionRef S, struct DisassembleInfo *info) {}

static void print_image_info(SectionRef S, struct DisassembleInfo *info) {}

static void printObjc2_64bit_MetaData(MachOObjectFile *O, bool verbose) {}

static void printObjc2_32bit_MetaData(MachOObjectFile *O, bool verbose) {}

static bool printObjc1_32bit_MetaData(MachOObjectFile *O, bool verbose) {}

static void DumpProtocolSection(MachOObjectFile *O, const char *sect,
                                uint32_t size, uint32_t addr) {}

static void printObjcMetaData(MachOObjectFile *O, bool verbose) {}

// GuessLiteralPointer returns a string which for the item in the Mach-O file
// for the address passed in as ReferenceValue for printing as a comment with
// the instruction and also returns the corresponding type of that item
// indirectly through ReferenceType.
//
// If ReferenceValue is an address of literal cstring then a pointer to the
// cstring is returned and ReferenceType is set to
// LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr .
//
// If ReferenceValue is an address of an Objective-C CFString, Selector ref or
// Class ref that name is returned and the ReferenceType is set accordingly.
//
// Lastly, literals which are Symbol address in a literal pool are looked for
// and if found the symbol name is returned and ReferenceType is set to
// LLVMDisassembler_ReferenceType_Out_LitPool_SymAddr .
//
// If there is no item in the Mach-O file for the address passed in as
// ReferenceValue nullptr is returned and ReferenceType is unchanged.
static const char *GuessLiteralPointer(uint64_t ReferenceValue,
                                       uint64_t ReferencePC,
                                       uint64_t *ReferenceType,
                                       struct DisassembleInfo *info) {}

// SymbolizerSymbolLookUp is the symbol lookup function passed when creating
// the Symbolizer.  It looks up the ReferenceValue using the info passed via the
// pointer to the struct DisassembleInfo that was passed when MCSymbolizer
// is created and returns the symbol name that matches the ReferenceValue or
// nullptr if none.  The ReferenceType is passed in for the IN type of
// reference the instruction is making from the values in defined in the header
// "llvm-c/Disassembler.h".  On return the ReferenceType can set to a specific
// Out type and the ReferenceName will also be set which is added as a comment
// to the disassembled instruction.
//
// If the symbol name is a C++ mangled name then the demangled name is
// returned through ReferenceName and ReferenceType is set to
// LLVMDisassembler_ReferenceType_DeMangled_Name .
//
// When this is called to get a symbol name for a branch target then the
// ReferenceType will be LLVMDisassembler_ReferenceType_In_Branch and then
// SymbolValue will be looked for in the indirect symbol table to determine if
// it is an address for a symbol stub.  If so then the symbol name for that
// stub is returned indirectly through ReferenceName and then ReferenceType is
// set to LLVMDisassembler_ReferenceType_Out_SymbolStub.
//
// When this is called with an value loaded via a PC relative load then
// ReferenceType will be LLVMDisassembler_ReferenceType_In_PCrel_Load then the
// SymbolValue is checked to be an address of literal pointer, symbol pointer,
// or an Objective-C meta data reference.  If so the output ReferenceType is
// set to correspond to that as well as setting the ReferenceName.
static const char *SymbolizerSymbolLookUp(void *DisInfo,
                                          uint64_t ReferenceValue,
                                          uint64_t *ReferenceType,
                                          uint64_t ReferencePC,
                                          const char **ReferenceName) {}

/// Emits the comments that are stored in the CommentStream.
/// Each comment in the CommentStream must end with a newline.
static void emitComments(raw_svector_ostream &CommentStream,
                         SmallString<128> &CommentsToEmit,
                         formatted_raw_ostream &FormattedOS,
                         const MCAsmInfo &MAI) {}

const MachOObjectFile *
objdump::getMachODSymObject(const MachOObjectFile *MachOOF, StringRef Filename,
                            std::unique_ptr<Binary> &DSYMBinary,
                            std::unique_ptr<MemoryBuffer> &DSYMBuf) {}

static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
                             StringRef DisSegName, StringRef DisSectName) {}

//===----------------------------------------------------------------------===//
// __compact_unwind section dumping
//===----------------------------------------------------------------------===//

namespace {

template <typename T>
static uint64_t read(StringRef Contents, ptrdiff_t Offset) {}

template <typename T>
static uint64_t readNext(StringRef Contents, ptrdiff_t &Offset) {}

struct CompactUnwindEntry {};
}

/// Given a relocation from __compact_unwind, consisting of the RelocationRef
/// and data being relocated, determine the best base Name and Addend to use for
/// display purposes.
///
/// 1. An Extern relocation will directly reference a symbol (and the data is
///    then already an addend), so use that.
/// 2. Otherwise the data is an offset in the object file's layout; try to find
//     a symbol before it in the same section, and use the offset from there.
/// 3. Finally, if all that fails, fall back to an offset from the start of the
///    referenced section.
static void findUnwindRelocNameAddend(const MachOObjectFile *Obj,
                                      std::map<uint64_t, SymbolRef> &Symbols,
                                      const RelocationRef &Reloc, uint64_t Addr,
                                      StringRef &Name, uint64_t &Addend) {}

static void printUnwindRelocDest(const MachOObjectFile *Obj,
                                 std::map<uint64_t, SymbolRef> &Symbols,
                                 const RelocationRef &Reloc, uint64_t Addr) {}

static void
printMachOCompactUnwindSection(const MachOObjectFile *Obj,
                               std::map<uint64_t, SymbolRef> &Symbols,
                               const SectionRef &CompactUnwind) {}

//===----------------------------------------------------------------------===//
// __unwind_info section dumping
//===----------------------------------------------------------------------===//

static void printRegularSecondLevelUnwindPage(StringRef PageData) {}

static void printCompressedSecondLevelUnwindPage(
    StringRef PageData, uint32_t FunctionBase,
    const SmallVectorImpl<uint32_t> &CommonEncodings) {}

static void printMachOUnwindInfoSection(const MachOObjectFile *Obj,
                                        std::map<uint64_t, SymbolRef> &Symbols,
                                        const SectionRef &UnwindInfo) {}

void objdump::printMachOUnwindInfo(const MachOObjectFile *Obj) {}

static void PrintMachHeader(uint32_t magic, uint32_t cputype,
                            uint32_t cpusubtype, uint32_t filetype,
                            uint32_t ncmds, uint32_t sizeofcmds, uint32_t flags,
                            bool verbose) {}

static void PrintSegmentCommand(uint32_t cmd, uint32_t cmdsize,
                                StringRef SegName, uint64_t vmaddr,
                                uint64_t vmsize, uint64_t fileoff,
                                uint64_t filesize, uint32_t maxprot,
                                uint32_t initprot, uint32_t nsects,
                                uint32_t flags, uint32_t object_size,
                                bool verbose) {}

static void PrintSection(const char *sectname, const char *segname,
                         uint64_t addr, uint64_t size, uint32_t offset,
                         uint32_t align, uint32_t reloff, uint32_t nreloc,
                         uint32_t flags, uint32_t reserved1, uint32_t reserved2,
                         uint32_t cmd, const char *sg_segname,
                         uint32_t filetype, uint32_t object_size,
                         bool verbose) {}

static void PrintSymtabLoadCommand(MachO::symtab_command st, bool Is64Bit,
                                   uint32_t object_size) {}

static void PrintDysymtabLoadCommand(MachO::dysymtab_command dyst,
                                     uint32_t nsyms, uint32_t object_size,
                                     bool Is64Bit) {}

static void PrintDyldInfoLoadCommand(MachO::dyld_info_command dc,
                                     uint32_t object_size) {}

static void PrintDyldLoadCommand(MachO::dylinker_command dyld,
                                 const char *Ptr) {}

static void PrintUuidLoadCommand(MachO::uuid_command uuid) {}

static void PrintRpathLoadCommand(MachO::rpath_command rpath, const char *Ptr) {}

static void PrintVersionMinLoadCommand(MachO::version_min_command vd) {}

static void PrintNoteLoadCommand(MachO::note_command Nt) {}

static void PrintBuildToolVersion(MachO::build_tool_version bv, bool verbose) {}

static void PrintBuildVersionLoadCommand(const MachOObjectFile *obj,
                                         MachO::build_version_command bd,
                                         bool verbose) {}

static void PrintSourceVersionCommand(MachO::source_version_command sd) {}

static void PrintEntryPointCommand(MachO::entry_point_command ep) {}

static void PrintEncryptionInfoCommand(MachO::encryption_info_command ec,
                                       uint32_t object_size) {}

static void PrintEncryptionInfoCommand64(MachO::encryption_info_command_64 ec,
                                         uint32_t object_size) {}

static void PrintLinkerOptionCommand(MachO::linker_option_command lo,
                                     const char *Ptr) {}

static void PrintSubFrameworkCommand(MachO::sub_framework_command sub,
                                     const char *Ptr) {}

static void PrintSubUmbrellaCommand(MachO::sub_umbrella_command sub,
                                    const char *Ptr) {}

static void PrintSubLibraryCommand(MachO::sub_library_command sub,
                                   const char *Ptr) {}

static void PrintSubClientCommand(MachO::sub_client_command sub,
                                  const char *Ptr) {}

static void PrintRoutinesCommand(MachO::routines_command r) {}

static void PrintRoutinesCommand64(MachO::routines_command_64 r) {}

static void Print_x86_thread_state32_t(MachO::x86_thread_state32_t &cpu32) {}

static void Print_x86_thread_state64_t(MachO::x86_thread_state64_t &cpu64) {}

static void Print_mmst_reg(MachO::mmst_reg_t &r) {}

static void Print_xmm_reg(MachO::xmm_reg_t &r) {}

static void Print_x86_float_state_t(MachO::x86_float_state64_t &fpu) {}

static void Print_x86_exception_state_t(MachO::x86_exception_state64_t &exc64) {}

static void Print_arm_thread_state32_t(MachO::arm_thread_state32_t &cpu32) {}

static void Print_arm_thread_state64_t(MachO::arm_thread_state64_t &cpu64) {}

static void PrintThreadCommand(MachO::thread_command t, const char *Ptr,
                               bool isLittleEndian, uint32_t cputype) {}

static void PrintDylibCommand(MachO::dylib_command dl, const char *Ptr) {}

static void PrintLinkEditDataCommand(MachO::linkedit_data_command ld,
                                     uint32_t object_size) {}

static void PrintLoadCommands(const MachOObjectFile *Obj, uint32_t filetype,
                              uint32_t cputype, bool verbose) {}

static void PrintMachHeader(const MachOObjectFile *Obj, bool verbose) {}

void objdump::printMachOFileHeader(const object::ObjectFile *Obj) {}

void MachODumper::printPrivateHeaders() {}

void objdump::printMachOLoadCommands(const object::ObjectFile *Obj) {}

//===----------------------------------------------------------------------===//
// export trie dumping
//===----------------------------------------------------------------------===//

static void printMachOExportsTrie(const object::MachOObjectFile *Obj) {}

//===----------------------------------------------------------------------===//
// rebase table dumping
//===----------------------------------------------------------------------===//

static void printMachORebaseTable(object::MachOObjectFile *Obj) {}

static StringRef ordinalName(const object::MachOObjectFile *Obj, int Ordinal) {}

//===----------------------------------------------------------------------===//
// bind table dumping
//===----------------------------------------------------------------------===//

static void printMachOBindTable(object::MachOObjectFile *Obj) {}

//===----------------------------------------------------------------------===//
// lazy bind table dumping
//===----------------------------------------------------------------------===//

static void printMachOLazyBindTable(object::MachOObjectFile *Obj) {}

//===----------------------------------------------------------------------===//
// weak bind table dumping
//===----------------------------------------------------------------------===//

static void printMachOWeakBindTable(object::MachOObjectFile *Obj) {}

// get_dyld_bind_info_symbolname() is used for disassembly and passed an
// address, ReferenceValue, in the Mach-O file and looks in the dyld bind
// information for that address. If the address is found its binding symbol
// name is returned.  If not nullptr is returned.
static const char *get_dyld_bind_info_symbolname(uint64_t ReferenceValue,
                                                 struct DisassembleInfo *info) {}

void objdump::printLazyBindTable(ObjectFile *o) {}

void objdump::printWeakBindTable(ObjectFile *o) {}

void objdump::printExportsTrie(const ObjectFile *o) {}

void objdump::printRebaseTable(ObjectFile *o) {}

void objdump::printBindTable(ObjectFile *o) {}