diff options
author | Chris Bieneman <beanz@apple.com> | 2016-05-13 17:41:41 +0000 |
---|---|---|
committer | Chris Bieneman <beanz@apple.com> | 2016-05-13 17:41:41 +0000 |
commit | 8b5906ea7fc47e5d10f6688d24c10e27ffb1442e (patch) | |
tree | e4902179e6b04bf7c5a0a50d0d38d58b85998477 /llvm/lib/ObjectYAML/MachOYAML.cpp | |
parent | 8db5174395a3b145c14c8bb5bf01382281a6a10c (diff) | |
download | bcm5719-llvm-8b5906ea7fc47e5d10f6688d24c10e27ffb1442e.tar.gz bcm5719-llvm-8b5906ea7fc47e5d10f6688d24c10e27ffb1442e.zip |
[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
Diffstat (limited to 'llvm/lib/ObjectYAML/MachOYAML.cpp')
-rw-r--r-- | llvm/lib/ObjectYAML/MachOYAML.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
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<MachOYAML::FileHeader>::mapping( @@ -40,9 +42,18 @@ void MappingTraits<MachOYAML::Object>::mapping(IO &IO, IO.mapTag("!mach-o", true); } IO.mapRequired("FileHeader", Object.Header); + IO.mapOptional("LoadCommands", Object.LoadCommands); IO.setContext(nullptr); } +void MappingTraits<std::unique_ptr<MachOYAML::LoadCommand>>::mapping( + IO &IO, std::unique_ptr<MachOYAML::LoadCommand> &LoadCommand) { + if (!IO.outputting()) + LoadCommand.reset(new MachOYAML::LoadCommand()); + IO.mapRequired("cmd", LoadCommand->cmd); + IO.mapRequired("cmdsize", LoadCommand->cmdsize); +} + } // namespace llvm::yaml } // namespace llvm |