From 8b5906ea7fc47e5d10f6688d24c10e27ffb1442e Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Fri, 13 May 2016 17:41:41 +0000 Subject: [obj2yaml] [yaml2obj] Basic support for MachO::load_command This patch adds basic support for MachO::load_command. Load command types and sizes are encoded in the YAML and expanded back into MachO. The YAML doesn't yet support load command structs, that is coming next. In the meantime as a temporary measure when writing MachO files the load commands are padded with zeros so that the generated binary is valid. llvm-svn: 269442 --- llvm/lib/ObjectYAML/MachOYAML.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'llvm/lib/ObjectYAML/MachOYAML.cpp') diff --git a/llvm/lib/ObjectYAML/MachOYAML.cpp b/llvm/lib/ObjectYAML/MachOYAML.cpp index d54140b6794..af80c1645a6 100644 --- a/llvm/lib/ObjectYAML/MachOYAML.cpp +++ b/llvm/lib/ObjectYAML/MachOYAML.cpp @@ -16,6 +16,8 @@ namespace llvm { +MachOYAML::LoadCommand::~LoadCommand() {} + namespace yaml { void MappingTraits::mapping( @@ -40,9 +42,18 @@ void MappingTraits::mapping(IO &IO, IO.mapTag("!mach-o", true); } IO.mapRequired("FileHeader", Object.Header); + IO.mapOptional("LoadCommands", Object.LoadCommands); IO.setContext(nullptr); } +void MappingTraits>::mapping( + IO &IO, std::unique_ptr &LoadCommand) { + if (!IO.outputting()) + LoadCommand.reset(new MachOYAML::LoadCommand()); + IO.mapRequired("cmd", LoadCommand->cmd); + IO.mapRequired("cmdsize", LoadCommand->cmdsize); +} + } // namespace llvm::yaml } // namespace llvm -- cgit v1.2.3