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