2016-05-13 00:04:16 +08:00
|
|
|
//===- MachOYAML.cpp - MachO YAMLIO implementation ------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines classes for handling the YAML representation of MachO.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/ObjectYAML/MachOYAML.h"
|
|
|
|
#include "llvm/Support/Casting.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
namespace yaml {
|
|
|
|
|
|
|
|
void MappingTraits<MachOYAML::FileHeader>::mapping(
|
|
|
|
IO &IO, MachOYAML::FileHeader &FileHdr) {
|
2016-05-13 01:44:43 +08:00
|
|
|
IO.mapRequired("magic", FileHdr.magic);
|
2016-05-13 00:04:16 +08:00
|
|
|
IO.mapRequired("cputype", FileHdr.cputype);
|
|
|
|
IO.mapRequired("cpusubtype", FileHdr.cpusubtype);
|
2016-05-13 01:53:01 +08:00
|
|
|
IO.mapRequired("filetype", FileHdr.filetype);
|
2016-05-13 00:04:16 +08:00
|
|
|
IO.mapRequired("ncmds", FileHdr.ncmds);
|
2016-05-13 01:44:43 +08:00
|
|
|
IO.mapRequired("sizeofcmds", FileHdr.sizeofcmds);
|
2016-05-13 00:04:16 +08:00
|
|
|
IO.mapRequired("flags", FileHdr.flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MappingTraits<MachOYAML::Object>::mapping(IO &IO,
|
|
|
|
MachOYAML::Object &Object) {
|
|
|
|
// If the context isn't already set, tag the document as !mach-o.
|
|
|
|
// For Fat files there will be a different tag so they can be differentiated.
|
2016-05-13 01:44:43 +08:00
|
|
|
if (!IO.getContext()) {
|
2016-05-13 00:04:16 +08:00
|
|
|
IO.setContext(&Object);
|
|
|
|
IO.mapTag("!mach-o", true);
|
|
|
|
}
|
|
|
|
IO.mapRequired("FileHeader", Object.Header);
|
|
|
|
IO.setContext(nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace llvm::yaml
|
|
|
|
|
|
|
|
} // namespace llvm
|