diff options
author | Chris Bieneman <beanz@apple.com> | 2016-05-12 16:04:16 +0000 |
---|---|---|
committer | Chris Bieneman <beanz@apple.com> | 2016-05-12 16:04:16 +0000 |
commit | 9062ab943fe55fddb5af389421f3293f20dd3ba5 (patch) | |
tree | 34514de27fcd99f4be54f8ebc7cd9db4ee228f71 /llvm/lib/ObjectYAML/MachOYAML.cpp | |
parent | 11d3926cf64a7ed6cd90750685b3bd40030afe1f (diff) | |
download | bcm5719-llvm-9062ab943fe55fddb5af389421f3293f20dd3ba5.tar.gz bcm5719-llvm-9062ab943fe55fddb5af389421f3293f20dd3ba5.zip |
[ObjectYAML] Support Thin MachO headers to YAML
This patch adds support to ObjectYAML for serializing mach_header structs.
llvm-svn: 269303
Diffstat (limited to 'llvm/lib/ObjectYAML/MachOYAML.cpp')
-rw-r--r-- | llvm/lib/ObjectYAML/MachOYAML.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/llvm/lib/ObjectYAML/MachOYAML.cpp b/llvm/lib/ObjectYAML/MachOYAML.cpp new file mode 100644 index 00000000000..91d9583c98e --- /dev/null +++ b/llvm/lib/ObjectYAML/MachOYAML.cpp @@ -0,0 +1,44 @@ +//===- 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) { + IO.mapRequired("cputype", FileHdr.cputype); + IO.mapRequired("cpusubtype", FileHdr.cpusubtype); + IO.mapOptional("filetype", FileHdr.filetype); + IO.mapRequired("ncmds", FileHdr.ncmds); + 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. + if(!IO.getContext()) { + IO.setContext(&Object); + IO.mapTag("!mach-o", true); + } + IO.mapRequired("FileHeader", Object.Header); + IO.setContext(nullptr); +} + +} // namespace llvm::yaml + +} // namespace llvm |