Chris Bieneman | 9062ab9 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 1 | //===- MachOYAML.cpp - MachO YAMLIO implementation ------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines classes for handling the YAML representation of MachO. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "llvm/ObjectYAML/MachOYAML.h" |
Eugene Zelenko | 28082ab | 2017-07-01 01:35:55 +0000 | [diff] [blame] | 15 | #include "llvm/ADT/StringRef.h" |
Zachary Turner | 264b5d9 | 2017-06-07 03:48:56 +0000 | [diff] [blame] | 16 | #include "llvm/BinaryFormat/MachO.h" |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 17 | #include "llvm/Support/Format.h" |
Chris Bieneman | 55de3a2 | 2016-12-22 21:58:03 +0000 | [diff] [blame] | 18 | #include "llvm/Support/Host.h" |
Eugene Zelenko | 28082ab | 2017-07-01 01:35:55 +0000 | [diff] [blame] | 19 | #include "llvm/Support/YAMLTraits.h" |
| 20 | #include "llvm/Support/raw_ostream.h" |
| 21 | #include <cinttypes> |
| 22 | #include <cstdint> |
| 23 | #include <cstring> |
Chris Bieneman | 9062ab9 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 24 | |
| 25 | namespace llvm { |
| 26 | |
Eugene Zelenko | 28082ab | 2017-07-01 01:35:55 +0000 | [diff] [blame] | 27 | MachOYAML::LoadCommand::~LoadCommand() = default; |
Chris Bieneman | 8b5906e | 2016-05-13 17:41:41 +0000 | [diff] [blame] | 28 | |
Chris Bieneman | 432ba9d | 2016-08-17 21:46:04 +0000 | [diff] [blame] | 29 | bool MachOYAML::LinkEditData::isEmpty() const { |
Chris Bieneman | 8b058ae | 2016-12-06 06:00:49 +0000 | [diff] [blame] | 30 | return 0 == |
| 31 | RebaseOpcodes.size() + BindOpcodes.size() + WeakBindOpcodes.size() + |
| 32 | LazyBindOpcodes.size() + ExportTrie.Children.size() + |
| 33 | NameList.size() + StringTable.size(); |
| 34 | } |
| 35 | |
Chris Bieneman | 9062ab9 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 36 | namespace yaml { |
| 37 | |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 38 | void ScalarTraits<char_16>::output(const char_16 &Val, void *, |
Eugene Zelenko | 28082ab | 2017-07-01 01:35:55 +0000 | [diff] [blame] | 39 | raw_ostream &Out) { |
Chris Bieneman | 2de17d4 | 2016-05-18 16:17:23 +0000 | [diff] [blame] | 40 | auto Len = strnlen(&Val[0], 16); |
| 41 | Out << StringRef(&Val[0], Len); |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | StringRef ScalarTraits<char_16>::input(StringRef Scalar, void *, char_16 &Val) { |
| 45 | size_t CopySize = 16 >= Scalar.size() ? 16 : Scalar.size(); |
| 46 | memcpy((void *)Val, Scalar.data(), CopySize); |
| 47 | |
| 48 | if (Scalar.size() < 16) { |
| 49 | memset((void *)&Val[Scalar.size()], 0, 16 - Scalar.size()); |
| 50 | } |
| 51 | |
| 52 | return StringRef(); |
| 53 | } |
| 54 | |
| 55 | bool ScalarTraits<char_16>::mustQuote(StringRef S) { return needsQuotes(S); } |
| 56 | |
Eugene Zelenko | 28082ab | 2017-07-01 01:35:55 +0000 | [diff] [blame] | 57 | void ScalarTraits<uuid_t>::output(const uuid_t &Val, void *, raw_ostream &Out) { |
Adrian Prantl | 3dcd122 | 2017-09-13 18:22:59 +0000 | [diff] [blame] | 58 | Out.write_uuid(Val); |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | StringRef ScalarTraits<uuid_t>::input(StringRef Scalar, void *, uuid_t &Val) { |
| 62 | size_t OutIdx = 0; |
| 63 | for (size_t Idx = 0; Idx < Scalar.size(); ++Idx) { |
| 64 | if (Scalar[Idx] == '-' || OutIdx >= 16) |
| 65 | continue; |
| 66 | unsigned long long TempInt; |
| 67 | if (getAsUnsignedInteger(Scalar.slice(Idx, Idx + 2), 16, TempInt)) |
| 68 | return "invalid number"; |
| 69 | if (TempInt > 0xFF) |
| 70 | return "out of range number"; |
| 71 | Val[OutIdx] = static_cast<uint8_t>(TempInt); |
| 72 | ++Idx; // increment idx an extra time because we're consuming 2 chars |
| 73 | ++OutIdx; |
| 74 | } |
| 75 | return StringRef(); |
| 76 | } |
| 77 | |
| 78 | bool ScalarTraits<uuid_t>::mustQuote(StringRef S) { return needsQuotes(S); } |
| 79 | |
Chris Bieneman | 9062ab9 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 80 | void MappingTraits<MachOYAML::FileHeader>::mapping( |
| 81 | IO &IO, MachOYAML::FileHeader &FileHdr) { |
Chris Bieneman | 24f0747 | 2016-05-12 17:44:43 +0000 | [diff] [blame] | 82 | IO.mapRequired("magic", FileHdr.magic); |
Chris Bieneman | 9062ab9 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 83 | IO.mapRequired("cputype", FileHdr.cputype); |
| 84 | IO.mapRequired("cpusubtype", FileHdr.cpusubtype); |
Chris Bieneman | 668beb2 | 2016-05-12 17:53:01 +0000 | [diff] [blame] | 85 | IO.mapRequired("filetype", FileHdr.filetype); |
Chris Bieneman | 9062ab9 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 86 | IO.mapRequired("ncmds", FileHdr.ncmds); |
Chris Bieneman | 24f0747 | 2016-05-12 17:44:43 +0000 | [diff] [blame] | 87 | IO.mapRequired("sizeofcmds", FileHdr.sizeofcmds); |
Chris Bieneman | 9062ab9 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 88 | IO.mapRequired("flags", FileHdr.flags); |
Chris Bieneman | 10dcd3b | 2016-06-23 22:36:31 +0000 | [diff] [blame] | 89 | if (FileHdr.magic == MachO::MH_MAGIC_64 || |
| 90 | FileHdr.magic == MachO::MH_CIGAM_64) |
| 91 | IO.mapRequired("reserved", FileHdr.reserved); |
Chris Bieneman | 9062ab9 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | void MappingTraits<MachOYAML::Object>::mapping(IO &IO, |
| 95 | MachOYAML::Object &Object) { |
| 96 | // If the context isn't already set, tag the document as !mach-o. |
| 97 | // For Fat files there will be a different tag so they can be differentiated. |
Chris Bieneman | 24f0747 | 2016-05-12 17:44:43 +0000 | [diff] [blame] | 98 | if (!IO.getContext()) { |
Chris Bieneman | 9062ab9 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 99 | IO.setContext(&Object); |
Chris Bieneman | 9062ab9 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 100 | } |
Chris Bieneman | 92b2e8a | 2016-06-28 21:10:26 +0000 | [diff] [blame] | 101 | IO.mapTag("!mach-o", true); |
Chris Bieneman | 55de3a2 | 2016-12-22 21:58:03 +0000 | [diff] [blame] | 102 | IO.mapOptional("IsLittleEndian", Object.IsLittleEndian, |
| 103 | sys::IsLittleEndianHost); |
| 104 | Object.DWARF.IsLittleEndian = Object.IsLittleEndian; |
| 105 | |
Chris Bieneman | 9062ab9 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 106 | IO.mapRequired("FileHeader", Object.Header); |
Chris Bieneman | 8b5906e | 2016-05-13 17:41:41 +0000 | [diff] [blame] | 107 | IO.mapOptional("LoadCommands", Object.LoadCommands); |
Chris Bieneman | 432ba9d | 2016-08-17 21:46:04 +0000 | [diff] [blame] | 108 | if(!Object.LinkEdit.isEmpty() || !IO.outputting()) |
| 109 | IO.mapOptional("LinkEditData", Object.LinkEdit); |
Chris Bieneman | 93e7119 | 2016-06-24 20:42:28 +0000 | [diff] [blame] | 110 | |
Chris Bieneman | 8b058ae | 2016-12-06 06:00:49 +0000 | [diff] [blame] | 111 | if(!Object.DWARF.isEmpty() || !IO.outputting()) |
| 112 | IO.mapOptional("DWARF", Object.DWARF); |
| 113 | |
Chris Bieneman | 93e7119 | 2016-06-24 20:42:28 +0000 | [diff] [blame] | 114 | if (IO.getContext() == &Object) |
| 115 | IO.setContext(nullptr); |
| 116 | } |
| 117 | |
| 118 | void MappingTraits<MachOYAML::FatHeader>::mapping( |
| 119 | IO &IO, MachOYAML::FatHeader &FatHeader) { |
| 120 | IO.mapRequired("magic", FatHeader.magic); |
| 121 | IO.mapRequired("nfat_arch", FatHeader.nfat_arch); |
| 122 | } |
| 123 | |
| 124 | void MappingTraits<MachOYAML::FatArch>::mapping(IO &IO, |
| 125 | MachOYAML::FatArch &FatArch) { |
| 126 | IO.mapRequired("cputype", FatArch.cputype); |
| 127 | IO.mapRequired("cpusubtype", FatArch.cpusubtype); |
| 128 | IO.mapRequired("offset", FatArch.offset); |
| 129 | IO.mapRequired("size", FatArch.size); |
| 130 | IO.mapRequired("align", FatArch.align); |
| 131 | IO.mapOptional("reserved", FatArch.reserved, |
| 132 | static_cast<llvm::yaml::Hex32>(0)); |
| 133 | } |
| 134 | |
| 135 | void MappingTraits<MachOYAML::UniversalBinary>::mapping( |
| 136 | IO &IO, MachOYAML::UniversalBinary &UniversalBinary) { |
| 137 | if (!IO.getContext()) { |
| 138 | IO.setContext(&UniversalBinary); |
| 139 | IO.mapTag("!fat-mach-o", true); |
| 140 | } |
| 141 | IO.mapRequired("FatHeader", UniversalBinary.Header); |
| 142 | IO.mapRequired("FatArchs", UniversalBinary.FatArchs); |
| 143 | IO.mapRequired("Slices", UniversalBinary.Slices); |
| 144 | |
| 145 | if (IO.getContext() == &UniversalBinary) |
| 146 | IO.setContext(nullptr); |
| 147 | } |
| 148 | |
Chris Bieneman | 524243d | 2016-05-26 20:06:14 +0000 | [diff] [blame] | 149 | void MappingTraits<MachOYAML::LinkEditData>::mapping( |
| 150 | IO &IO, MachOYAML::LinkEditData &LinkEditData) { |
Chris Bieneman | e8e7555 | 2016-05-25 17:09:07 +0000 | [diff] [blame] | 151 | IO.mapOptional("RebaseOpcodes", LinkEditData.RebaseOpcodes); |
Chris Bieneman | 524243d | 2016-05-26 20:06:14 +0000 | [diff] [blame] | 152 | IO.mapOptional("BindOpcodes", LinkEditData.BindOpcodes); |
Chris Bieneman | 659b35a | 2016-05-26 20:50:05 +0000 | [diff] [blame] | 153 | IO.mapOptional("WeakBindOpcodes", LinkEditData.WeakBindOpcodes); |
Chris Bieneman | 44474c4 | 2016-05-26 21:29:39 +0000 | [diff] [blame] | 154 | IO.mapOptional("LazyBindOpcodes", LinkEditData.LazyBindOpcodes); |
Eugene Zelenko | 28082ab | 2017-07-01 01:35:55 +0000 | [diff] [blame] | 155 | if (!LinkEditData.ExportTrie.Children.empty() || !IO.outputting()) |
Chris Bieneman | ca5de9d | 2016-08-11 00:20:03 +0000 | [diff] [blame] | 156 | IO.mapOptional("ExportTrie", LinkEditData.ExportTrie); |
Chris Bieneman | 07bb3c8 | 2016-06-02 22:54:06 +0000 | [diff] [blame] | 157 | IO.mapOptional("NameList", LinkEditData.NameList); |
| 158 | IO.mapOptional("StringTable", LinkEditData.StringTable); |
Chris Bieneman | e8e7555 | 2016-05-25 17:09:07 +0000 | [diff] [blame] | 159 | } |
| 160 | |
Chris Bieneman | 524243d | 2016-05-26 20:06:14 +0000 | [diff] [blame] | 161 | void MappingTraits<MachOYAML::RebaseOpcode>::mapping( |
| 162 | IO &IO, MachOYAML::RebaseOpcode &RebaseOpcode) { |
Chris Bieneman | e8e7555 | 2016-05-25 17:09:07 +0000 | [diff] [blame] | 163 | IO.mapRequired("Opcode", RebaseOpcode.Opcode); |
| 164 | IO.mapRequired("Imm", RebaseOpcode.Imm); |
| 165 | IO.mapOptional("ExtraData", RebaseOpcode.ExtraData); |
| 166 | } |
| 167 | |
Chris Bieneman | 524243d | 2016-05-26 20:06:14 +0000 | [diff] [blame] | 168 | void MappingTraits<MachOYAML::BindOpcode>::mapping( |
| 169 | IO &IO, MachOYAML::BindOpcode &BindOpcode) { |
| 170 | IO.mapRequired("Opcode", BindOpcode.Opcode); |
| 171 | IO.mapRequired("Imm", BindOpcode.Imm); |
| 172 | IO.mapOptional("ULEBExtraData", BindOpcode.ULEBExtraData); |
| 173 | IO.mapOptional("SLEBExtraData", BindOpcode.SLEBExtraData); |
| 174 | IO.mapOptional("Symbol", BindOpcode.Symbol); |
| 175 | } |
| 176 | |
Chris Bieneman | 6852775 | 2016-05-31 17:26:36 +0000 | [diff] [blame] | 177 | void MappingTraits<MachOYAML::ExportEntry>::mapping( |
| 178 | IO &IO, MachOYAML::ExportEntry &ExportEntry) { |
| 179 | IO.mapRequired("TerminalSize", ExportEntry.TerminalSize); |
| 180 | IO.mapOptional("NodeOffset", ExportEntry.NodeOffset); |
| 181 | IO.mapOptional("Name", ExportEntry.Name); |
| 182 | IO.mapOptional("Flags", ExportEntry.Flags); |
| 183 | IO.mapOptional("Address", ExportEntry.Address); |
| 184 | IO.mapOptional("Other", ExportEntry.Other); |
| 185 | IO.mapOptional("ImportName", ExportEntry.ImportName); |
| 186 | IO.mapOptional("Children", ExportEntry.Children); |
| 187 | } |
| 188 | |
Chris Bieneman | 07bb3c8 | 2016-06-02 22:54:06 +0000 | [diff] [blame] | 189 | void MappingTraits<MachOYAML::NListEntry>::mapping( |
| 190 | IO &IO, MachOYAML::NListEntry &NListEntry) { |
| 191 | IO.mapRequired("n_strx", NListEntry.n_strx); |
| 192 | IO.mapRequired("n_type", NListEntry.n_type); |
| 193 | IO.mapRequired("n_sect", NListEntry.n_sect); |
| 194 | IO.mapRequired("n_desc", NListEntry.n_desc); |
| 195 | IO.mapRequired("n_value", NListEntry.n_value); |
| 196 | } |
| 197 | |
Chris Bieneman | 9f243e9 | 2016-05-19 20:54:43 +0000 | [diff] [blame] | 198 | template <typename StructType> |
| 199 | void mapLoadCommandData(IO &IO, MachOYAML::LoadCommand &LoadCommand) {} |
| 200 | |
| 201 | template <> |
| 202 | void mapLoadCommandData<MachO::segment_command>( |
| 203 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 204 | IO.mapOptional("Sections", LoadCommand.Sections); |
| 205 | } |
| 206 | |
| 207 | template <> |
| 208 | void mapLoadCommandData<MachO::segment_command_64>( |
| 209 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 210 | IO.mapOptional("Sections", LoadCommand.Sections); |
| 211 | } |
| 212 | |
| 213 | template <> |
| 214 | void mapLoadCommandData<MachO::dylib_command>( |
| 215 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 216 | IO.mapOptional("PayloadString", LoadCommand.PayloadString); |
| 217 | } |
| 218 | |
| 219 | template <> |
Chris Bieneman | 6852775 | 2016-05-31 17:26:36 +0000 | [diff] [blame] | 220 | void mapLoadCommandData<MachO::rpath_command>( |
| 221 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 222 | IO.mapOptional("PayloadString", LoadCommand.PayloadString); |
| 223 | } |
| 224 | |
| 225 | template <> |
Chris Bieneman | 9f243e9 | 2016-05-19 20:54:43 +0000 | [diff] [blame] | 226 | void mapLoadCommandData<MachO::dylinker_command>( |
| 227 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 228 | IO.mapOptional("PayloadString", LoadCommand.PayloadString); |
| 229 | } |
| 230 | |
Steven Wu | 5b54a42 | 2017-01-23 20:07:55 +0000 | [diff] [blame] | 231 | template <> |
| 232 | void mapLoadCommandData<MachO::build_version_command>( |
| 233 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 234 | IO.mapOptional("Tools", LoadCommand.Tools); |
| 235 | } |
| 236 | |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 237 | void MappingTraits<MachOYAML::LoadCommand>::mapping( |
| 238 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
Chris Bieneman | 606f178 | 2016-06-23 23:01:47 +0000 | [diff] [blame] | 239 | MachO::LoadCommandType TempCmd = static_cast<MachO::LoadCommandType>( |
| 240 | LoadCommand.Data.load_command_data.cmd); |
| 241 | IO.mapRequired("cmd", TempCmd); |
| 242 | LoadCommand.Data.load_command_data.cmd = TempCmd; |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 243 | IO.mapRequired("cmdsize", LoadCommand.Data.load_command_data.cmdsize); |
| 244 | |
| 245 | #define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \ |
| 246 | case MachO::LCName: \ |
| 247 | MappingTraits<MachO::LCStruct>::mapping(IO, \ |
| 248 | LoadCommand.Data.LCStruct##_data); \ |
Chris Bieneman | 9f243e9 | 2016-05-19 20:54:43 +0000 | [diff] [blame] | 249 | mapLoadCommandData<MachO::LCStruct>(IO, LoadCommand); \ |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 250 | break; |
| 251 | |
| 252 | switch (LoadCommand.Data.load_command_data.cmd) { |
Zachary Turner | 264b5d9 | 2017-06-07 03:48:56 +0000 | [diff] [blame] | 253 | #include "llvm/BinaryFormat/MachO.def" |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 254 | } |
Chris Bieneman | 9f243e9 | 2016-05-19 20:54:43 +0000 | [diff] [blame] | 255 | IO.mapOptional("PayloadBytes", LoadCommand.PayloadBytes); |
| 256 | IO.mapOptional("ZeroPadBytes", LoadCommand.ZeroPadBytes, (uint64_t)0ull); |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | void MappingTraits<MachO::dyld_info_command>::mapping( |
| 260 | IO &IO, MachO::dyld_info_command &LoadCommand) { |
| 261 | IO.mapRequired("rebase_off", LoadCommand.rebase_off); |
| 262 | IO.mapRequired("rebase_size", LoadCommand.rebase_size); |
Chris Bieneman | 2de17d4 | 2016-05-18 16:17:23 +0000 | [diff] [blame] | 263 | IO.mapRequired("bind_off", LoadCommand.bind_off); |
| 264 | IO.mapRequired("bind_size", LoadCommand.bind_size); |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 265 | IO.mapRequired("weak_bind_off", LoadCommand.weak_bind_off); |
| 266 | IO.mapRequired("weak_bind_size", LoadCommand.weak_bind_size); |
Chris Bieneman | 2de17d4 | 2016-05-18 16:17:23 +0000 | [diff] [blame] | 267 | IO.mapRequired("lazy_bind_off", LoadCommand.lazy_bind_off); |
| 268 | IO.mapRequired("lazy_bind_size", LoadCommand.lazy_bind_size); |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 269 | IO.mapRequired("export_off", LoadCommand.export_off); |
| 270 | IO.mapRequired("export_size", LoadCommand.export_size); |
| 271 | } |
| 272 | |
Chris Bieneman | 2de17d4 | 2016-05-18 16:17:23 +0000 | [diff] [blame] | 273 | void MappingTraits<MachOYAML::Section>::mapping(IO &IO, |
| 274 | MachOYAML::Section &Section) { |
| 275 | IO.mapRequired("sectname", Section.sectname); |
| 276 | IO.mapRequired("segname", Section.segname); |
| 277 | IO.mapRequired("addr", Section.addr); |
| 278 | IO.mapRequired("size", Section.size); |
| 279 | IO.mapRequired("offset", Section.offset); |
| 280 | IO.mapRequired("align", Section.align); |
| 281 | IO.mapRequired("reloff", Section.reloff); |
| 282 | IO.mapRequired("nreloc", Section.nreloc); |
| 283 | IO.mapRequired("flags", Section.flags); |
| 284 | IO.mapRequired("reserved1", Section.reserved1); |
| 285 | IO.mapRequired("reserved2", Section.reserved2); |
| 286 | IO.mapOptional("reserved3", Section.reserved3); |
| 287 | } |
| 288 | |
Steven Wu | 5b54a42 | 2017-01-23 20:07:55 +0000 | [diff] [blame] | 289 | void MappingTraits<MachO::build_tool_version>::mapping( |
| 290 | IO &IO, MachO::build_tool_version &tool) { |
| 291 | IO.mapRequired("tool", tool.tool); |
| 292 | IO.mapRequired("version", tool.version); |
| 293 | } |
| 294 | |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 295 | void MappingTraits<MachO::dylib>::mapping(IO &IO, MachO::dylib &DylibStruct) { |
| 296 | IO.mapRequired("name", DylibStruct.name); |
| 297 | IO.mapRequired("timestamp", DylibStruct.timestamp); |
| 298 | IO.mapRequired("current_version", DylibStruct.current_version); |
| 299 | IO.mapRequired("compatibility_version", DylibStruct.compatibility_version); |
| 300 | } |
| 301 | |
| 302 | void MappingTraits<MachO::dylib_command>::mapping( |
| 303 | IO &IO, MachO::dylib_command &LoadCommand) { |
| 304 | IO.mapRequired("dylib", LoadCommand.dylib); |
| 305 | } |
| 306 | |
| 307 | void MappingTraits<MachO::dylinker_command>::mapping( |
| 308 | IO &IO, MachO::dylinker_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 309 | IO.mapRequired("name", LoadCommand.name); |
| 310 | } |
| 311 | |
| 312 | void MappingTraits<MachO::dysymtab_command>::mapping( |
| 313 | IO &IO, MachO::dysymtab_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 314 | IO.mapRequired("ilocalsym", LoadCommand.ilocalsym); |
| 315 | IO.mapRequired("nlocalsym", LoadCommand.nlocalsym); |
| 316 | IO.mapRequired("iextdefsym", LoadCommand.iextdefsym); |
| 317 | IO.mapRequired("nextdefsym", LoadCommand.nextdefsym); |
| 318 | IO.mapRequired("iundefsym", LoadCommand.iundefsym); |
| 319 | IO.mapRequired("nundefsym", LoadCommand.nundefsym); |
| 320 | IO.mapRequired("tocoff", LoadCommand.tocoff); |
| 321 | IO.mapRequired("ntoc", LoadCommand.ntoc); |
| 322 | IO.mapRequired("modtaboff", LoadCommand.modtaboff); |
| 323 | IO.mapRequired("nmodtab", LoadCommand.nmodtab); |
| 324 | IO.mapRequired("extrefsymoff", LoadCommand.extrefsymoff); |
| 325 | IO.mapRequired("nextrefsyms", LoadCommand.nextrefsyms); |
| 326 | IO.mapRequired("indirectsymoff", LoadCommand.indirectsymoff); |
| 327 | IO.mapRequired("nindirectsyms", LoadCommand.nindirectsyms); |
| 328 | IO.mapRequired("extreloff", LoadCommand.extreloff); |
| 329 | IO.mapRequired("nextrel", LoadCommand.nextrel); |
| 330 | IO.mapRequired("locreloff", LoadCommand.locreloff); |
| 331 | IO.mapRequired("nlocrel", LoadCommand.nlocrel); |
| 332 | } |
| 333 | |
| 334 | void MappingTraits<MachO::encryption_info_command>::mapping( |
| 335 | IO &IO, MachO::encryption_info_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 336 | IO.mapRequired("cryptoff", LoadCommand.cryptoff); |
| 337 | IO.mapRequired("cryptsize", LoadCommand.cryptsize); |
| 338 | IO.mapRequired("cryptid", LoadCommand.cryptid); |
| 339 | } |
| 340 | |
| 341 | void MappingTraits<MachO::encryption_info_command_64>::mapping( |
| 342 | IO &IO, MachO::encryption_info_command_64 &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 343 | IO.mapRequired("cryptoff", LoadCommand.cryptoff); |
| 344 | IO.mapRequired("cryptsize", LoadCommand.cryptsize); |
| 345 | IO.mapRequired("cryptid", LoadCommand.cryptid); |
| 346 | IO.mapRequired("pad", LoadCommand.pad); |
| 347 | } |
| 348 | |
| 349 | void MappingTraits<MachO::entry_point_command>::mapping( |
| 350 | IO &IO, MachO::entry_point_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 351 | IO.mapRequired("entryoff", LoadCommand.entryoff); |
| 352 | IO.mapRequired("stacksize", LoadCommand.stacksize); |
| 353 | } |
| 354 | |
| 355 | void MappingTraits<MachO::fvmfile_command>::mapping( |
| 356 | IO &IO, MachO::fvmfile_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 357 | IO.mapRequired("name", LoadCommand.name); |
| 358 | IO.mapRequired("header_addr", LoadCommand.header_addr); |
| 359 | } |
| 360 | |
| 361 | void MappingTraits<MachO::fvmlib>::mapping(IO &IO, MachO::fvmlib &FVMLib) { |
| 362 | IO.mapRequired("name", FVMLib.name); |
| 363 | IO.mapRequired("minor_version", FVMLib.minor_version); |
| 364 | IO.mapRequired("header_addr", FVMLib.header_addr); |
| 365 | } |
| 366 | |
| 367 | void MappingTraits<MachO::fvmlib_command>::mapping( |
| 368 | IO &IO, MachO::fvmlib_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 369 | IO.mapRequired("fvmlib", LoadCommand.fvmlib); |
| 370 | } |
| 371 | |
| 372 | void MappingTraits<MachO::ident_command>::mapping( |
| 373 | IO &IO, MachO::ident_command &LoadCommand) {} |
| 374 | |
| 375 | void MappingTraits<MachO::linkedit_data_command>::mapping( |
| 376 | IO &IO, MachO::linkedit_data_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 377 | IO.mapRequired("dataoff", LoadCommand.dataoff); |
| 378 | IO.mapRequired("datasize", LoadCommand.datasize); |
| 379 | } |
| 380 | |
| 381 | void MappingTraits<MachO::linker_option_command>::mapping( |
| 382 | IO &IO, MachO::linker_option_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 383 | IO.mapRequired("count", LoadCommand.count); |
| 384 | } |
| 385 | |
| 386 | void MappingTraits<MachO::prebind_cksum_command>::mapping( |
| 387 | IO &IO, MachO::prebind_cksum_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 388 | IO.mapRequired("cksum", LoadCommand.cksum); |
| 389 | } |
| 390 | |
| 391 | void MappingTraits<MachO::load_command>::mapping( |
| 392 | IO &IO, MachO::load_command &LoadCommand) {} |
| 393 | |
| 394 | void MappingTraits<MachO::prebound_dylib_command>::mapping( |
| 395 | IO &IO, MachO::prebound_dylib_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 396 | IO.mapRequired("name", LoadCommand.name); |
| 397 | IO.mapRequired("nmodules", LoadCommand.nmodules); |
| 398 | IO.mapRequired("linked_modules", LoadCommand.linked_modules); |
| 399 | } |
| 400 | |
| 401 | void MappingTraits<MachO::routines_command>::mapping( |
| 402 | IO &IO, MachO::routines_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 403 | IO.mapRequired("init_address", LoadCommand.init_address); |
| 404 | IO.mapRequired("init_module", LoadCommand.init_module); |
| 405 | IO.mapRequired("reserved1", LoadCommand.reserved1); |
| 406 | IO.mapRequired("reserved2", LoadCommand.reserved2); |
| 407 | IO.mapRequired("reserved3", LoadCommand.reserved3); |
| 408 | IO.mapRequired("reserved4", LoadCommand.reserved4); |
| 409 | IO.mapRequired("reserved5", LoadCommand.reserved5); |
| 410 | IO.mapRequired("reserved6", LoadCommand.reserved6); |
| 411 | } |
| 412 | |
| 413 | void MappingTraits<MachO::routines_command_64>::mapping( |
| 414 | IO &IO, MachO::routines_command_64 &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 415 | IO.mapRequired("init_address", LoadCommand.init_address); |
| 416 | IO.mapRequired("init_module", LoadCommand.init_module); |
| 417 | IO.mapRequired("reserved1", LoadCommand.reserved1); |
| 418 | IO.mapRequired("reserved2", LoadCommand.reserved2); |
| 419 | IO.mapRequired("reserved3", LoadCommand.reserved3); |
| 420 | IO.mapRequired("reserved4", LoadCommand.reserved4); |
| 421 | IO.mapRequired("reserved5", LoadCommand.reserved5); |
| 422 | IO.mapRequired("reserved6", LoadCommand.reserved6); |
| 423 | } |
| 424 | |
| 425 | void MappingTraits<MachO::rpath_command>::mapping( |
| 426 | IO &IO, MachO::rpath_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 427 | IO.mapRequired("path", LoadCommand.path); |
| 428 | } |
| 429 | |
| 430 | void MappingTraits<MachO::section>::mapping(IO &IO, MachO::section &Section) { |
| 431 | IO.mapRequired("sectname", Section.sectname); |
| 432 | IO.mapRequired("segname", Section.segname); |
| 433 | IO.mapRequired("addr", Section.addr); |
| 434 | IO.mapRequired("size", Section.size); |
| 435 | IO.mapRequired("offset", Section.offset); |
| 436 | IO.mapRequired("align", Section.align); |
| 437 | IO.mapRequired("reloff", Section.reloff); |
| 438 | IO.mapRequired("nreloc", Section.nreloc); |
| 439 | IO.mapRequired("flags", Section.flags); |
| 440 | IO.mapRequired("reserved1", Section.reserved1); |
| 441 | IO.mapRequired("reserved2", Section.reserved2); |
| 442 | } |
| 443 | |
| 444 | void MappingTraits<MachO::section_64>::mapping(IO &IO, |
| 445 | MachO::section_64 &Section) { |
| 446 | IO.mapRequired("sectname", Section.sectname); |
| 447 | IO.mapRequired("segname", Section.segname); |
| 448 | IO.mapRequired("addr", Section.addr); |
| 449 | IO.mapRequired("size", Section.size); |
| 450 | IO.mapRequired("offset", Section.offset); |
| 451 | IO.mapRequired("align", Section.align); |
| 452 | IO.mapRequired("reloff", Section.reloff); |
| 453 | IO.mapRequired("nreloc", Section.nreloc); |
| 454 | IO.mapRequired("flags", Section.flags); |
| 455 | IO.mapRequired("reserved1", Section.reserved1); |
| 456 | IO.mapRequired("reserved2", Section.reserved2); |
| 457 | IO.mapRequired("reserved3", Section.reserved3); |
| 458 | } |
| 459 | |
| 460 | void MappingTraits<MachO::segment_command>::mapping( |
| 461 | IO &IO, MachO::segment_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 462 | IO.mapRequired("segname", LoadCommand.segname); |
| 463 | IO.mapRequired("vmaddr", LoadCommand.vmaddr); |
| 464 | IO.mapRequired("vmsize", LoadCommand.vmsize); |
| 465 | IO.mapRequired("fileoff", LoadCommand.fileoff); |
| 466 | IO.mapRequired("filesize", LoadCommand.filesize); |
| 467 | IO.mapRequired("maxprot", LoadCommand.maxprot); |
| 468 | IO.mapRequired("initprot", LoadCommand.initprot); |
| 469 | IO.mapRequired("nsects", LoadCommand.nsects); |
| 470 | IO.mapRequired("flags", LoadCommand.flags); |
| 471 | } |
| 472 | |
| 473 | void MappingTraits<MachO::segment_command_64>::mapping( |
| 474 | IO &IO, MachO::segment_command_64 &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 475 | IO.mapRequired("segname", LoadCommand.segname); |
| 476 | IO.mapRequired("vmaddr", LoadCommand.vmaddr); |
| 477 | IO.mapRequired("vmsize", LoadCommand.vmsize); |
| 478 | IO.mapRequired("fileoff", LoadCommand.fileoff); |
| 479 | IO.mapRequired("filesize", LoadCommand.filesize); |
| 480 | IO.mapRequired("maxprot", LoadCommand.maxprot); |
| 481 | IO.mapRequired("initprot", LoadCommand.initprot); |
| 482 | IO.mapRequired("nsects", LoadCommand.nsects); |
| 483 | IO.mapRequired("flags", LoadCommand.flags); |
| 484 | } |
| 485 | |
| 486 | void MappingTraits<MachO::source_version_command>::mapping( |
| 487 | IO &IO, MachO::source_version_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 488 | IO.mapRequired("version", LoadCommand.version); |
| 489 | } |
| 490 | |
| 491 | void MappingTraits<MachO::sub_client_command>::mapping( |
| 492 | IO &IO, MachO::sub_client_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 493 | IO.mapRequired("client", LoadCommand.client); |
| 494 | } |
| 495 | |
| 496 | void MappingTraits<MachO::sub_framework_command>::mapping( |
| 497 | IO &IO, MachO::sub_framework_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 498 | IO.mapRequired("umbrella", LoadCommand.umbrella); |
| 499 | } |
| 500 | |
| 501 | void MappingTraits<MachO::sub_library_command>::mapping( |
| 502 | IO &IO, MachO::sub_library_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 503 | IO.mapRequired("sub_library", LoadCommand.sub_library); |
| 504 | } |
| 505 | |
| 506 | void MappingTraits<MachO::sub_umbrella_command>::mapping( |
| 507 | IO &IO, MachO::sub_umbrella_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 508 | IO.mapRequired("sub_umbrella", LoadCommand.sub_umbrella); |
| 509 | } |
| 510 | |
| 511 | void MappingTraits<MachO::symseg_command>::mapping( |
| 512 | IO &IO, MachO::symseg_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 513 | IO.mapRequired("offset", LoadCommand.offset); |
| 514 | IO.mapRequired("size", LoadCommand.size); |
| 515 | } |
| 516 | |
| 517 | void MappingTraits<MachO::symtab_command>::mapping( |
| 518 | IO &IO, MachO::symtab_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 519 | IO.mapRequired("symoff", LoadCommand.symoff); |
| 520 | IO.mapRequired("nsyms", LoadCommand.nsyms); |
| 521 | IO.mapRequired("stroff", LoadCommand.stroff); |
| 522 | IO.mapRequired("strsize", LoadCommand.strsize); |
| 523 | } |
| 524 | |
| 525 | void MappingTraits<MachO::thread_command>::mapping( |
| 526 | IO &IO, MachO::thread_command &LoadCommand) {} |
| 527 | |
| 528 | void MappingTraits<MachO::twolevel_hints_command>::mapping( |
| 529 | IO &IO, MachO::twolevel_hints_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 530 | IO.mapRequired("offset", LoadCommand.offset); |
| 531 | IO.mapRequired("nhints", LoadCommand.nhints); |
| 532 | } |
| 533 | |
| 534 | void MappingTraits<MachO::uuid_command>::mapping( |
| 535 | IO &IO, MachO::uuid_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 536 | IO.mapRequired("uuid", LoadCommand.uuid); |
| 537 | } |
| 538 | |
| 539 | void MappingTraits<MachO::version_min_command>::mapping( |
| 540 | IO &IO, MachO::version_min_command &LoadCommand) { |
Chris Bieneman | 3f2eb83 | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 541 | IO.mapRequired("version", LoadCommand.version); |
| 542 | IO.mapRequired("sdk", LoadCommand.sdk); |
Chris Bieneman | 8b5906e | 2016-05-13 17:41:41 +0000 | [diff] [blame] | 543 | } |
| 544 | |
Kevin Enderby | a4579c4 | 2017-01-19 17:36:31 +0000 | [diff] [blame] | 545 | void MappingTraits<MachO::note_command>::mapping( |
| 546 | IO &IO, MachO::note_command &LoadCommand) { |
Kevin Enderby | a4579c4 | 2017-01-19 17:36:31 +0000 | [diff] [blame] | 547 | IO.mapRequired("data_owner", LoadCommand.data_owner); |
| 548 | IO.mapRequired("offset", LoadCommand.offset); |
| 549 | IO.mapRequired("size", LoadCommand.size); |
| 550 | } |
| 551 | |
Steven Wu | 5b54a42 | 2017-01-23 20:07:55 +0000 | [diff] [blame] | 552 | void MappingTraits<MachO::build_version_command>::mapping( |
| 553 | IO &IO, MachO::build_version_command &LoadCommand) { |
Steven Wu | 5b54a42 | 2017-01-23 20:07:55 +0000 | [diff] [blame] | 554 | IO.mapRequired("platform", LoadCommand.platform); |
| 555 | IO.mapRequired("minos", LoadCommand.minos); |
| 556 | IO.mapRequired("sdk", LoadCommand.sdk); |
| 557 | IO.mapRequired("ntools", LoadCommand.ntools); |
| 558 | } |
| 559 | |
Eugene Zelenko | 28082ab | 2017-07-01 01:35:55 +0000 | [diff] [blame] | 560 | } // end namespace yaml |
Chris Bieneman | 9062ab9 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 561 | |
Eugene Zelenko | 28082ab | 2017-07-01 01:35:55 +0000 | [diff] [blame] | 562 | } // end namespace llvm |