#include "obj2yaml.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/Object/MachOUniversal.h"
#include "llvm/ObjectYAML/DWARFYAML.h"
#include "llvm/ObjectYAML/ObjectYAML.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/SystemZ/zOSSupport.h"
#include <string.h>
usingnamespacellvm;
class MachODumper { … };
#define HANDLE_LOAD_COMMAND …
template <typename SectionType>
Expected<MachOYAML::Section>
MachODumper::constructSectionCommon(SectionType Sec, size_t SecIndex) { … }
template <>
Expected<MachOYAML::Section> MachODumper::constructSection(MachO::section Sec,
size_t SecIndex) { … }
template <>
Expected<MachOYAML::Section>
MachODumper::constructSection(MachO::section_64 Sec, size_t SecIndex) { … }
static Error dumpDebugSection(StringRef SecName, DWARFContext &DCtx,
DWARFYAML::Data &DWARF) { … }
template <typename SectionType, typename SegmentType>
Expected<const char *> MachODumper::extractSections(
const llvm::object::MachOObjectFile::LoadCommandInfo &LoadCmd,
std::vector<MachOYAML::Section> &Sections, MachOYAML::Object &Y) { … }
template <typename StructType>
Expected<const char *> MachODumper::processLoadCommandData(
MachOYAML::LoadCommand &LC,
const llvm::object::MachOObjectFile::LoadCommandInfo &LoadCmd,
MachOYAML::Object &Y) { … }
template <>
Expected<const char *>
MachODumper::processLoadCommandData<MachO::segment_command>(
MachOYAML::LoadCommand &LC,
const llvm::object::MachOObjectFile::LoadCommandInfo &LoadCmd,
MachOYAML::Object &Y) { … }
template <>
Expected<const char *>
MachODumper::processLoadCommandData<MachO::segment_command_64>(
MachOYAML::LoadCommand &LC,
const llvm::object::MachOObjectFile::LoadCommandInfo &LoadCmd,
MachOYAML::Object &Y) { … }
template <typename StructType>
const char *
readString(MachOYAML::LoadCommand &LC,
const llvm::object::MachOObjectFile::LoadCommandInfo &LoadCmd) { … }
template <>
Expected<const char *>
MachODumper::processLoadCommandData<MachO::dylib_command>(
MachOYAML::LoadCommand &LC,
const llvm::object::MachOObjectFile::LoadCommandInfo &LoadCmd,
MachOYAML::Object &Y) { … }
template <>
Expected<const char *>
MachODumper::processLoadCommandData<MachO::dylinker_command>(
MachOYAML::LoadCommand &LC,
const llvm::object::MachOObjectFile::LoadCommandInfo &LoadCmd,
MachOYAML::Object &Y) { … }
template <>
Expected<const char *>
MachODumper::processLoadCommandData<MachO::rpath_command>(
MachOYAML::LoadCommand &LC,
const llvm::object::MachOObjectFile::LoadCommandInfo &LoadCmd,
MachOYAML::Object &Y) { … }
template <>
Expected<const char *>
MachODumper::processLoadCommandData<MachO::build_version_command>(
MachOYAML::LoadCommand &LC,
const llvm::object::MachOObjectFile::LoadCommandInfo &LoadCmd,
MachOYAML::Object &Y) { … }
Expected<std::unique_ptr<MachOYAML::Object>> MachODumper::dump() { … }
void MachODumper::dumpHeader(std::unique_ptr<MachOYAML::Object> &Y) { … }
Error MachODumper::dumpLoadCommands(std::unique_ptr<MachOYAML::Object> &Y) { … }
void MachODumper::dumpLinkEdit(std::unique_ptr<MachOYAML::Object> &Y) { … }
void MachODumper::dumpFunctionStarts(std::unique_ptr<MachOYAML::Object> &Y) { … }
void MachODumper::dumpRebaseOpcodes(std::unique_ptr<MachOYAML::Object> &Y) { … }
StringRef ReadStringRef(const uint8_t *Start) { … }
void MachODumper::dumpBindOpcodes(
std::vector<MachOYAML::BindOpcode> &BindOpcodes,
ArrayRef<uint8_t> OpcodeBuffer, bool Lazy) { … }
const uint8_t *processExportNode(const uint8_t *Start, const uint8_t *CurrPtr,
const uint8_t *const End,
MachOYAML::ExportEntry &Entry) { … }
void MachODumper::dumpExportTrie(std::unique_ptr<MachOYAML::Object> &Y) { … }
template <typename nlist_t>
MachOYAML::NListEntry constructNameList(const nlist_t &nlist) { … }
void MachODumper::dumpSymbols(std::unique_ptr<MachOYAML::Object> &Y) { … }
void MachODumper::dumpIndirectSymbols(std::unique_ptr<MachOYAML::Object> &Y) { … }
void MachODumper::dumpChainedFixups(std::unique_ptr<MachOYAML::Object> &Y) { … }
void MachODumper::dumpDataInCode(std::unique_ptr<MachOYAML::Object> &Y) { … }
Error macho2yaml(raw_ostream &Out, const object::MachOObjectFile &Obj,
unsigned RawSegments) { … }
Error macho2yaml(raw_ostream &Out, const object::MachOUniversalBinary &Obj,
unsigned RawSegments) { … }
Error macho2yaml(raw_ostream &Out, const object::Binary &Binary,
unsigned RawSegments) { … }