Chris Bieneman | 7455ed8 | 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 | cd90344 | 2017-07-01 01:35:55 +0000 | [diff] [blame] | 15 | #include "llvm/ADT/StringRef.h" |
Zachary Turner | 19ca2b0 | 2017-06-07 03:48:56 +0000 | [diff] [blame] | 16 | #include "llvm/BinaryFormat/MachO.h" |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 17 | #include "llvm/Support/Format.h" |
Chris Bieneman | 5e76a3f | 2016-12-22 21:58:03 +0000 | [diff] [blame] | 18 | #include "llvm/Support/Host.h" |
Eugene Zelenko | cd90344 | 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 | 7455ed8 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 24 | |
| 25 | namespace llvm { |
| 26 | |
Eugene Zelenko | cd90344 | 2017-07-01 01:35:55 +0000 | [diff] [blame] | 27 | MachOYAML::LoadCommand::~LoadCommand() = default; |
Chris Bieneman | 062cef5 | 2016-05-13 17:41:41 +0000 | [diff] [blame] | 28 | |
Chris Bieneman | 506857f | 2016-08-17 21:46:04 +0000 | [diff] [blame] | 29 | bool MachOYAML::LinkEditData::isEmpty() const { |
Chris Bieneman | 4a6766e | 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 | 7455ed8 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 36 | namespace yaml { |
| 37 | |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 38 | void ScalarTraits<char_16>::output(const char_16 &Val, void *, |
Eugene Zelenko | cd90344 | 2017-07-01 01:35:55 +0000 | [diff] [blame] | 39 | raw_ostream &Out) { |
Chris Bieneman | 7ec0ea1 | 2016-05-18 16:17:23 +0000 | [diff] [blame] | 40 | auto Len = strnlen(&Val[0], 16); |
| 41 | Out << StringRef(&Val[0], Len); |
Chris Bieneman | 0865cea | 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 | |
Francis Visoiu Mistrih | 65ad22d | 2017-12-18 17:38:03 +0000 | [diff] [blame] | 55 | QuotingType ScalarTraits<char_16>::mustQuote(StringRef S) { |
| 56 | return needsQuotes(S); |
| 57 | } |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 58 | |
Eugene Zelenko | cd90344 | 2017-07-01 01:35:55 +0000 | [diff] [blame] | 59 | void ScalarTraits<uuid_t>::output(const uuid_t &Val, void *, raw_ostream &Out) { |
Adrian Prantl | 7ff141c | 2017-09-13 18:22:59 +0000 | [diff] [blame] | 60 | Out.write_uuid(Val); |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 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 | |
Francis Visoiu Mistrih | 65ad22d | 2017-12-18 17:38:03 +0000 | [diff] [blame] | 80 | QuotingType ScalarTraits<uuid_t>::mustQuote(StringRef S) { |
| 81 | return needsQuotes(S); |
| 82 | } |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 83 | |
Chris Bieneman | 7455ed8 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 84 | void MappingTraits<MachOYAML::FileHeader>::mapping( |
| 85 | IO &IO, MachOYAML::FileHeader &FileHdr) { |
Chris Bieneman | dfa9a6b | 2016-05-12 17:44:43 +0000 | [diff] [blame] | 86 | IO.mapRequired("magic", FileHdr.magic); |
Chris Bieneman | 7455ed8 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 87 | IO.mapRequired("cputype", FileHdr.cputype); |
| 88 | IO.mapRequired("cpusubtype", FileHdr.cpusubtype); |
Chris Bieneman | 8413a15 | 2016-05-12 17:53:01 +0000 | [diff] [blame] | 89 | IO.mapRequired("filetype", FileHdr.filetype); |
Chris Bieneman | 7455ed8 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 90 | IO.mapRequired("ncmds", FileHdr.ncmds); |
Chris Bieneman | dfa9a6b | 2016-05-12 17:44:43 +0000 | [diff] [blame] | 91 | IO.mapRequired("sizeofcmds", FileHdr.sizeofcmds); |
Chris Bieneman | 7455ed8 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 92 | IO.mapRequired("flags", FileHdr.flags); |
Chris Bieneman | 46c1e8f | 2016-06-23 22:36:31 +0000 | [diff] [blame] | 93 | if (FileHdr.magic == MachO::MH_MAGIC_64 || |
| 94 | FileHdr.magic == MachO::MH_CIGAM_64) |
| 95 | IO.mapRequired("reserved", FileHdr.reserved); |
Chris Bieneman | 7455ed8 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | void MappingTraits<MachOYAML::Object>::mapping(IO &IO, |
| 99 | MachOYAML::Object &Object) { |
| 100 | // If the context isn't already set, tag the document as !mach-o. |
| 101 | // For Fat files there will be a different tag so they can be differentiated. |
Chris Bieneman | dfa9a6b | 2016-05-12 17:44:43 +0000 | [diff] [blame] | 102 | if (!IO.getContext()) { |
Chris Bieneman | 7455ed8 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 103 | IO.setContext(&Object); |
Chris Bieneman | 7455ed8 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 104 | } |
Chris Bieneman | efed5fb | 2016-06-28 21:10:26 +0000 | [diff] [blame] | 105 | IO.mapTag("!mach-o", true); |
Chris Bieneman | 5e76a3f | 2016-12-22 21:58:03 +0000 | [diff] [blame] | 106 | IO.mapOptional("IsLittleEndian", Object.IsLittleEndian, |
| 107 | sys::IsLittleEndianHost); |
| 108 | Object.DWARF.IsLittleEndian = Object.IsLittleEndian; |
| 109 | |
Chris Bieneman | 7455ed8 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 110 | IO.mapRequired("FileHeader", Object.Header); |
Chris Bieneman | 062cef5 | 2016-05-13 17:41:41 +0000 | [diff] [blame] | 111 | IO.mapOptional("LoadCommands", Object.LoadCommands); |
Chris Bieneman | 506857f | 2016-08-17 21:46:04 +0000 | [diff] [blame] | 112 | if(!Object.LinkEdit.isEmpty() || !IO.outputting()) |
| 113 | IO.mapOptional("LinkEditData", Object.LinkEdit); |
Chris Bieneman | e92acf1 | 2016-06-24 20:42:28 +0000 | [diff] [blame] | 114 | |
Chris Bieneman | 4a6766e | 2016-12-06 06:00:49 +0000 | [diff] [blame] | 115 | if(!Object.DWARF.isEmpty() || !IO.outputting()) |
| 116 | IO.mapOptional("DWARF", Object.DWARF); |
| 117 | |
Chris Bieneman | e92acf1 | 2016-06-24 20:42:28 +0000 | [diff] [blame] | 118 | if (IO.getContext() == &Object) |
| 119 | IO.setContext(nullptr); |
| 120 | } |
| 121 | |
| 122 | void MappingTraits<MachOYAML::FatHeader>::mapping( |
| 123 | IO &IO, MachOYAML::FatHeader &FatHeader) { |
| 124 | IO.mapRequired("magic", FatHeader.magic); |
| 125 | IO.mapRequired("nfat_arch", FatHeader.nfat_arch); |
| 126 | } |
| 127 | |
| 128 | void MappingTraits<MachOYAML::FatArch>::mapping(IO &IO, |
| 129 | MachOYAML::FatArch &FatArch) { |
| 130 | IO.mapRequired("cputype", FatArch.cputype); |
| 131 | IO.mapRequired("cpusubtype", FatArch.cpusubtype); |
| 132 | IO.mapRequired("offset", FatArch.offset); |
| 133 | IO.mapRequired("size", FatArch.size); |
| 134 | IO.mapRequired("align", FatArch.align); |
| 135 | IO.mapOptional("reserved", FatArch.reserved, |
| 136 | static_cast<llvm::yaml::Hex32>(0)); |
| 137 | } |
| 138 | |
| 139 | void MappingTraits<MachOYAML::UniversalBinary>::mapping( |
| 140 | IO &IO, MachOYAML::UniversalBinary &UniversalBinary) { |
| 141 | if (!IO.getContext()) { |
| 142 | IO.setContext(&UniversalBinary); |
| 143 | IO.mapTag("!fat-mach-o", true); |
| 144 | } |
| 145 | IO.mapRequired("FatHeader", UniversalBinary.Header); |
| 146 | IO.mapRequired("FatArchs", UniversalBinary.FatArchs); |
| 147 | IO.mapRequired("Slices", UniversalBinary.Slices); |
| 148 | |
| 149 | if (IO.getContext() == &UniversalBinary) |
| 150 | IO.setContext(nullptr); |
| 151 | } |
| 152 | |
Chris Bieneman | 7ad3d3b | 2016-05-26 20:06:14 +0000 | [diff] [blame] | 153 | void MappingTraits<MachOYAML::LinkEditData>::mapping( |
| 154 | IO &IO, MachOYAML::LinkEditData &LinkEditData) { |
Chris Bieneman | 4877ca7 | 2016-05-25 17:09:07 +0000 | [diff] [blame] | 155 | IO.mapOptional("RebaseOpcodes", LinkEditData.RebaseOpcodes); |
Chris Bieneman | 7ad3d3b | 2016-05-26 20:06:14 +0000 | [diff] [blame] | 156 | IO.mapOptional("BindOpcodes", LinkEditData.BindOpcodes); |
Chris Bieneman | 429d7a4 | 2016-05-26 20:50:05 +0000 | [diff] [blame] | 157 | IO.mapOptional("WeakBindOpcodes", LinkEditData.WeakBindOpcodes); |
Chris Bieneman | 7593509 | 2016-05-26 21:29:39 +0000 | [diff] [blame] | 158 | IO.mapOptional("LazyBindOpcodes", LinkEditData.LazyBindOpcodes); |
Eugene Zelenko | cd90344 | 2017-07-01 01:35:55 +0000 | [diff] [blame] | 159 | if (!LinkEditData.ExportTrie.Children.empty() || !IO.outputting()) |
Chris Bieneman | 50b70a6 | 2016-08-11 00:20:03 +0000 | [diff] [blame] | 160 | IO.mapOptional("ExportTrie", LinkEditData.ExportTrie); |
Chris Bieneman | 4aa4497 | 2016-06-02 22:54:06 +0000 | [diff] [blame] | 161 | IO.mapOptional("NameList", LinkEditData.NameList); |
| 162 | IO.mapOptional("StringTable", LinkEditData.StringTable); |
Chris Bieneman | 4877ca7 | 2016-05-25 17:09:07 +0000 | [diff] [blame] | 163 | } |
| 164 | |
Chris Bieneman | 7ad3d3b | 2016-05-26 20:06:14 +0000 | [diff] [blame] | 165 | void MappingTraits<MachOYAML::RebaseOpcode>::mapping( |
| 166 | IO &IO, MachOYAML::RebaseOpcode &RebaseOpcode) { |
Chris Bieneman | 4877ca7 | 2016-05-25 17:09:07 +0000 | [diff] [blame] | 167 | IO.mapRequired("Opcode", RebaseOpcode.Opcode); |
| 168 | IO.mapRequired("Imm", RebaseOpcode.Imm); |
| 169 | IO.mapOptional("ExtraData", RebaseOpcode.ExtraData); |
| 170 | } |
| 171 | |
Chris Bieneman | 7ad3d3b | 2016-05-26 20:06:14 +0000 | [diff] [blame] | 172 | void MappingTraits<MachOYAML::BindOpcode>::mapping( |
| 173 | IO &IO, MachOYAML::BindOpcode &BindOpcode) { |
| 174 | IO.mapRequired("Opcode", BindOpcode.Opcode); |
| 175 | IO.mapRequired("Imm", BindOpcode.Imm); |
| 176 | IO.mapOptional("ULEBExtraData", BindOpcode.ULEBExtraData); |
| 177 | IO.mapOptional("SLEBExtraData", BindOpcode.SLEBExtraData); |
| 178 | IO.mapOptional("Symbol", BindOpcode.Symbol); |
| 179 | } |
| 180 | |
Chris Bieneman | 7e74f7a | 2016-05-31 17:26:36 +0000 | [diff] [blame] | 181 | void MappingTraits<MachOYAML::ExportEntry>::mapping( |
| 182 | IO &IO, MachOYAML::ExportEntry &ExportEntry) { |
| 183 | IO.mapRequired("TerminalSize", ExportEntry.TerminalSize); |
| 184 | IO.mapOptional("NodeOffset", ExportEntry.NodeOffset); |
| 185 | IO.mapOptional("Name", ExportEntry.Name); |
| 186 | IO.mapOptional("Flags", ExportEntry.Flags); |
| 187 | IO.mapOptional("Address", ExportEntry.Address); |
| 188 | IO.mapOptional("Other", ExportEntry.Other); |
| 189 | IO.mapOptional("ImportName", ExportEntry.ImportName); |
| 190 | IO.mapOptional("Children", ExportEntry.Children); |
| 191 | } |
| 192 | |
Chris Bieneman | 4aa4497 | 2016-06-02 22:54:06 +0000 | [diff] [blame] | 193 | void MappingTraits<MachOYAML::NListEntry>::mapping( |
| 194 | IO &IO, MachOYAML::NListEntry &NListEntry) { |
| 195 | IO.mapRequired("n_strx", NListEntry.n_strx); |
| 196 | IO.mapRequired("n_type", NListEntry.n_type); |
| 197 | IO.mapRequired("n_sect", NListEntry.n_sect); |
| 198 | IO.mapRequired("n_desc", NListEntry.n_desc); |
| 199 | IO.mapRequired("n_value", NListEntry.n_value); |
| 200 | } |
| 201 | |
Chris Bieneman | 09166ea | 2016-05-19 20:54:43 +0000 | [diff] [blame] | 202 | template <typename StructType> |
| 203 | void mapLoadCommandData(IO &IO, MachOYAML::LoadCommand &LoadCommand) {} |
| 204 | |
| 205 | template <> |
| 206 | void mapLoadCommandData<MachO::segment_command>( |
| 207 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 208 | IO.mapOptional("Sections", LoadCommand.Sections); |
| 209 | } |
| 210 | |
| 211 | template <> |
| 212 | void mapLoadCommandData<MachO::segment_command_64>( |
| 213 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 214 | IO.mapOptional("Sections", LoadCommand.Sections); |
| 215 | } |
| 216 | |
| 217 | template <> |
| 218 | void mapLoadCommandData<MachO::dylib_command>( |
| 219 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 220 | IO.mapOptional("PayloadString", LoadCommand.PayloadString); |
| 221 | } |
| 222 | |
| 223 | template <> |
Chris Bieneman | 7e74f7a | 2016-05-31 17:26:36 +0000 | [diff] [blame] | 224 | void mapLoadCommandData<MachO::rpath_command>( |
| 225 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 226 | IO.mapOptional("PayloadString", LoadCommand.PayloadString); |
| 227 | } |
| 228 | |
| 229 | template <> |
Chris Bieneman | 09166ea | 2016-05-19 20:54:43 +0000 | [diff] [blame] | 230 | void mapLoadCommandData<MachO::dylinker_command>( |
| 231 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 232 | IO.mapOptional("PayloadString", LoadCommand.PayloadString); |
| 233 | } |
| 234 | |
Steven Wu | 6d5a027 | 2017-01-23 20:07:55 +0000 | [diff] [blame] | 235 | template <> |
| 236 | void mapLoadCommandData<MachO::build_version_command>( |
| 237 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 238 | IO.mapOptional("Tools", LoadCommand.Tools); |
| 239 | } |
| 240 | |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 241 | void MappingTraits<MachOYAML::LoadCommand>::mapping( |
| 242 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
Chris Bieneman | 072362b | 2016-06-23 23:01:47 +0000 | [diff] [blame] | 243 | MachO::LoadCommandType TempCmd = static_cast<MachO::LoadCommandType>( |
| 244 | LoadCommand.Data.load_command_data.cmd); |
| 245 | IO.mapRequired("cmd", TempCmd); |
| 246 | LoadCommand.Data.load_command_data.cmd = TempCmd; |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 247 | IO.mapRequired("cmdsize", LoadCommand.Data.load_command_data.cmdsize); |
| 248 | |
| 249 | #define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \ |
| 250 | case MachO::LCName: \ |
| 251 | MappingTraits<MachO::LCStruct>::mapping(IO, \ |
| 252 | LoadCommand.Data.LCStruct##_data); \ |
Chris Bieneman | 09166ea | 2016-05-19 20:54:43 +0000 | [diff] [blame] | 253 | mapLoadCommandData<MachO::LCStruct>(IO, LoadCommand); \ |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 254 | break; |
| 255 | |
| 256 | switch (LoadCommand.Data.load_command_data.cmd) { |
Zachary Turner | 19ca2b0 | 2017-06-07 03:48:56 +0000 | [diff] [blame] | 257 | #include "llvm/BinaryFormat/MachO.def" |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 258 | } |
Chris Bieneman | 09166ea | 2016-05-19 20:54:43 +0000 | [diff] [blame] | 259 | IO.mapOptional("PayloadBytes", LoadCommand.PayloadBytes); |
| 260 | IO.mapOptional("ZeroPadBytes", LoadCommand.ZeroPadBytes, (uint64_t)0ull); |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | void MappingTraits<MachO::dyld_info_command>::mapping( |
| 264 | IO &IO, MachO::dyld_info_command &LoadCommand) { |
| 265 | IO.mapRequired("rebase_off", LoadCommand.rebase_off); |
| 266 | IO.mapRequired("rebase_size", LoadCommand.rebase_size); |
Chris Bieneman | 7ec0ea1 | 2016-05-18 16:17:23 +0000 | [diff] [blame] | 267 | IO.mapRequired("bind_off", LoadCommand.bind_off); |
| 268 | IO.mapRequired("bind_size", LoadCommand.bind_size); |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 269 | IO.mapRequired("weak_bind_off", LoadCommand.weak_bind_off); |
| 270 | IO.mapRequired("weak_bind_size", LoadCommand.weak_bind_size); |
Chris Bieneman | 7ec0ea1 | 2016-05-18 16:17:23 +0000 | [diff] [blame] | 271 | IO.mapRequired("lazy_bind_off", LoadCommand.lazy_bind_off); |
| 272 | IO.mapRequired("lazy_bind_size", LoadCommand.lazy_bind_size); |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 273 | IO.mapRequired("export_off", LoadCommand.export_off); |
| 274 | IO.mapRequired("export_size", LoadCommand.export_size); |
| 275 | } |
| 276 | |
Chris Bieneman | 7ec0ea1 | 2016-05-18 16:17:23 +0000 | [diff] [blame] | 277 | void MappingTraits<MachOYAML::Section>::mapping(IO &IO, |
| 278 | MachOYAML::Section &Section) { |
| 279 | IO.mapRequired("sectname", Section.sectname); |
| 280 | IO.mapRequired("segname", Section.segname); |
| 281 | IO.mapRequired("addr", Section.addr); |
| 282 | IO.mapRequired("size", Section.size); |
| 283 | IO.mapRequired("offset", Section.offset); |
| 284 | IO.mapRequired("align", Section.align); |
| 285 | IO.mapRequired("reloff", Section.reloff); |
| 286 | IO.mapRequired("nreloc", Section.nreloc); |
| 287 | IO.mapRequired("flags", Section.flags); |
| 288 | IO.mapRequired("reserved1", Section.reserved1); |
| 289 | IO.mapRequired("reserved2", Section.reserved2); |
| 290 | IO.mapOptional("reserved3", Section.reserved3); |
| 291 | } |
| 292 | |
Steven Wu | 6d5a027 | 2017-01-23 20:07:55 +0000 | [diff] [blame] | 293 | void MappingTraits<MachO::build_tool_version>::mapping( |
| 294 | IO &IO, MachO::build_tool_version &tool) { |
| 295 | IO.mapRequired("tool", tool.tool); |
| 296 | IO.mapRequired("version", tool.version); |
| 297 | } |
| 298 | |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 299 | void MappingTraits<MachO::dylib>::mapping(IO &IO, MachO::dylib &DylibStruct) { |
| 300 | IO.mapRequired("name", DylibStruct.name); |
| 301 | IO.mapRequired("timestamp", DylibStruct.timestamp); |
| 302 | IO.mapRequired("current_version", DylibStruct.current_version); |
| 303 | IO.mapRequired("compatibility_version", DylibStruct.compatibility_version); |
| 304 | } |
| 305 | |
| 306 | void MappingTraits<MachO::dylib_command>::mapping( |
| 307 | IO &IO, MachO::dylib_command &LoadCommand) { |
| 308 | IO.mapRequired("dylib", LoadCommand.dylib); |
| 309 | } |
| 310 | |
| 311 | void MappingTraits<MachO::dylinker_command>::mapping( |
| 312 | IO &IO, MachO::dylinker_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 313 | IO.mapRequired("name", LoadCommand.name); |
| 314 | } |
| 315 | |
| 316 | void MappingTraits<MachO::dysymtab_command>::mapping( |
| 317 | IO &IO, MachO::dysymtab_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 318 | IO.mapRequired("ilocalsym", LoadCommand.ilocalsym); |
| 319 | IO.mapRequired("nlocalsym", LoadCommand.nlocalsym); |
| 320 | IO.mapRequired("iextdefsym", LoadCommand.iextdefsym); |
| 321 | IO.mapRequired("nextdefsym", LoadCommand.nextdefsym); |
| 322 | IO.mapRequired("iundefsym", LoadCommand.iundefsym); |
| 323 | IO.mapRequired("nundefsym", LoadCommand.nundefsym); |
| 324 | IO.mapRequired("tocoff", LoadCommand.tocoff); |
| 325 | IO.mapRequired("ntoc", LoadCommand.ntoc); |
| 326 | IO.mapRequired("modtaboff", LoadCommand.modtaboff); |
| 327 | IO.mapRequired("nmodtab", LoadCommand.nmodtab); |
| 328 | IO.mapRequired("extrefsymoff", LoadCommand.extrefsymoff); |
| 329 | IO.mapRequired("nextrefsyms", LoadCommand.nextrefsyms); |
| 330 | IO.mapRequired("indirectsymoff", LoadCommand.indirectsymoff); |
| 331 | IO.mapRequired("nindirectsyms", LoadCommand.nindirectsyms); |
| 332 | IO.mapRequired("extreloff", LoadCommand.extreloff); |
| 333 | IO.mapRequired("nextrel", LoadCommand.nextrel); |
| 334 | IO.mapRequired("locreloff", LoadCommand.locreloff); |
| 335 | IO.mapRequired("nlocrel", LoadCommand.nlocrel); |
| 336 | } |
| 337 | |
| 338 | void MappingTraits<MachO::encryption_info_command>::mapping( |
| 339 | IO &IO, MachO::encryption_info_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 340 | IO.mapRequired("cryptoff", LoadCommand.cryptoff); |
| 341 | IO.mapRequired("cryptsize", LoadCommand.cryptsize); |
| 342 | IO.mapRequired("cryptid", LoadCommand.cryptid); |
| 343 | } |
| 344 | |
| 345 | void MappingTraits<MachO::encryption_info_command_64>::mapping( |
| 346 | IO &IO, MachO::encryption_info_command_64 &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 347 | IO.mapRequired("cryptoff", LoadCommand.cryptoff); |
| 348 | IO.mapRequired("cryptsize", LoadCommand.cryptsize); |
| 349 | IO.mapRequired("cryptid", LoadCommand.cryptid); |
| 350 | IO.mapRequired("pad", LoadCommand.pad); |
| 351 | } |
| 352 | |
| 353 | void MappingTraits<MachO::entry_point_command>::mapping( |
| 354 | IO &IO, MachO::entry_point_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 355 | IO.mapRequired("entryoff", LoadCommand.entryoff); |
| 356 | IO.mapRequired("stacksize", LoadCommand.stacksize); |
| 357 | } |
| 358 | |
| 359 | void MappingTraits<MachO::fvmfile_command>::mapping( |
| 360 | IO &IO, MachO::fvmfile_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 361 | IO.mapRequired("name", LoadCommand.name); |
| 362 | IO.mapRequired("header_addr", LoadCommand.header_addr); |
| 363 | } |
| 364 | |
| 365 | void MappingTraits<MachO::fvmlib>::mapping(IO &IO, MachO::fvmlib &FVMLib) { |
| 366 | IO.mapRequired("name", FVMLib.name); |
| 367 | IO.mapRequired("minor_version", FVMLib.minor_version); |
| 368 | IO.mapRequired("header_addr", FVMLib.header_addr); |
| 369 | } |
| 370 | |
| 371 | void MappingTraits<MachO::fvmlib_command>::mapping( |
| 372 | IO &IO, MachO::fvmlib_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 373 | IO.mapRequired("fvmlib", LoadCommand.fvmlib); |
| 374 | } |
| 375 | |
| 376 | void MappingTraits<MachO::ident_command>::mapping( |
| 377 | IO &IO, MachO::ident_command &LoadCommand) {} |
| 378 | |
| 379 | void MappingTraits<MachO::linkedit_data_command>::mapping( |
| 380 | IO &IO, MachO::linkedit_data_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 381 | IO.mapRequired("dataoff", LoadCommand.dataoff); |
| 382 | IO.mapRequired("datasize", LoadCommand.datasize); |
| 383 | } |
| 384 | |
| 385 | void MappingTraits<MachO::linker_option_command>::mapping( |
| 386 | IO &IO, MachO::linker_option_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 387 | IO.mapRequired("count", LoadCommand.count); |
| 388 | } |
| 389 | |
| 390 | void MappingTraits<MachO::prebind_cksum_command>::mapping( |
| 391 | IO &IO, MachO::prebind_cksum_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 392 | IO.mapRequired("cksum", LoadCommand.cksum); |
| 393 | } |
| 394 | |
| 395 | void MappingTraits<MachO::load_command>::mapping( |
| 396 | IO &IO, MachO::load_command &LoadCommand) {} |
| 397 | |
| 398 | void MappingTraits<MachO::prebound_dylib_command>::mapping( |
| 399 | IO &IO, MachO::prebound_dylib_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 400 | IO.mapRequired("name", LoadCommand.name); |
| 401 | IO.mapRequired("nmodules", LoadCommand.nmodules); |
| 402 | IO.mapRequired("linked_modules", LoadCommand.linked_modules); |
| 403 | } |
| 404 | |
| 405 | void MappingTraits<MachO::routines_command>::mapping( |
| 406 | IO &IO, MachO::routines_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 407 | IO.mapRequired("init_address", LoadCommand.init_address); |
| 408 | IO.mapRequired("init_module", LoadCommand.init_module); |
| 409 | IO.mapRequired("reserved1", LoadCommand.reserved1); |
| 410 | IO.mapRequired("reserved2", LoadCommand.reserved2); |
| 411 | IO.mapRequired("reserved3", LoadCommand.reserved3); |
| 412 | IO.mapRequired("reserved4", LoadCommand.reserved4); |
| 413 | IO.mapRequired("reserved5", LoadCommand.reserved5); |
| 414 | IO.mapRequired("reserved6", LoadCommand.reserved6); |
| 415 | } |
| 416 | |
| 417 | void MappingTraits<MachO::routines_command_64>::mapping( |
| 418 | IO &IO, MachO::routines_command_64 &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 419 | IO.mapRequired("init_address", LoadCommand.init_address); |
| 420 | IO.mapRequired("init_module", LoadCommand.init_module); |
| 421 | IO.mapRequired("reserved1", LoadCommand.reserved1); |
| 422 | IO.mapRequired("reserved2", LoadCommand.reserved2); |
| 423 | IO.mapRequired("reserved3", LoadCommand.reserved3); |
| 424 | IO.mapRequired("reserved4", LoadCommand.reserved4); |
| 425 | IO.mapRequired("reserved5", LoadCommand.reserved5); |
| 426 | IO.mapRequired("reserved6", LoadCommand.reserved6); |
| 427 | } |
| 428 | |
| 429 | void MappingTraits<MachO::rpath_command>::mapping( |
| 430 | IO &IO, MachO::rpath_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 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) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 466 | IO.mapRequired("segname", LoadCommand.segname); |
| 467 | IO.mapRequired("vmaddr", LoadCommand.vmaddr); |
| 468 | IO.mapRequired("vmsize", LoadCommand.vmsize); |
| 469 | IO.mapRequired("fileoff", LoadCommand.fileoff); |
| 470 | IO.mapRequired("filesize", LoadCommand.filesize); |
| 471 | IO.mapRequired("maxprot", LoadCommand.maxprot); |
| 472 | IO.mapRequired("initprot", LoadCommand.initprot); |
| 473 | IO.mapRequired("nsects", LoadCommand.nsects); |
| 474 | IO.mapRequired("flags", LoadCommand.flags); |
| 475 | } |
| 476 | |
| 477 | void MappingTraits<MachO::segment_command_64>::mapping( |
| 478 | IO &IO, MachO::segment_command_64 &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 479 | IO.mapRequired("segname", LoadCommand.segname); |
| 480 | IO.mapRequired("vmaddr", LoadCommand.vmaddr); |
| 481 | IO.mapRequired("vmsize", LoadCommand.vmsize); |
| 482 | IO.mapRequired("fileoff", LoadCommand.fileoff); |
| 483 | IO.mapRequired("filesize", LoadCommand.filesize); |
| 484 | IO.mapRequired("maxprot", LoadCommand.maxprot); |
| 485 | IO.mapRequired("initprot", LoadCommand.initprot); |
| 486 | IO.mapRequired("nsects", LoadCommand.nsects); |
| 487 | IO.mapRequired("flags", LoadCommand.flags); |
| 488 | } |
| 489 | |
| 490 | void MappingTraits<MachO::source_version_command>::mapping( |
| 491 | IO &IO, MachO::source_version_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 492 | IO.mapRequired("version", LoadCommand.version); |
| 493 | } |
| 494 | |
| 495 | void MappingTraits<MachO::sub_client_command>::mapping( |
| 496 | IO &IO, MachO::sub_client_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 497 | IO.mapRequired("client", LoadCommand.client); |
| 498 | } |
| 499 | |
| 500 | void MappingTraits<MachO::sub_framework_command>::mapping( |
| 501 | IO &IO, MachO::sub_framework_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 502 | IO.mapRequired("umbrella", LoadCommand.umbrella); |
| 503 | } |
| 504 | |
| 505 | void MappingTraits<MachO::sub_library_command>::mapping( |
| 506 | IO &IO, MachO::sub_library_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 507 | IO.mapRequired("sub_library", LoadCommand.sub_library); |
| 508 | } |
| 509 | |
| 510 | void MappingTraits<MachO::sub_umbrella_command>::mapping( |
| 511 | IO &IO, MachO::sub_umbrella_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 512 | IO.mapRequired("sub_umbrella", LoadCommand.sub_umbrella); |
| 513 | } |
| 514 | |
| 515 | void MappingTraits<MachO::symseg_command>::mapping( |
| 516 | IO &IO, MachO::symseg_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 517 | IO.mapRequired("offset", LoadCommand.offset); |
| 518 | IO.mapRequired("size", LoadCommand.size); |
| 519 | } |
| 520 | |
| 521 | void MappingTraits<MachO::symtab_command>::mapping( |
| 522 | IO &IO, MachO::symtab_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 523 | IO.mapRequired("symoff", LoadCommand.symoff); |
| 524 | IO.mapRequired("nsyms", LoadCommand.nsyms); |
| 525 | IO.mapRequired("stroff", LoadCommand.stroff); |
| 526 | IO.mapRequired("strsize", LoadCommand.strsize); |
| 527 | } |
| 528 | |
| 529 | void MappingTraits<MachO::thread_command>::mapping( |
| 530 | IO &IO, MachO::thread_command &LoadCommand) {} |
| 531 | |
| 532 | void MappingTraits<MachO::twolevel_hints_command>::mapping( |
| 533 | IO &IO, MachO::twolevel_hints_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 534 | IO.mapRequired("offset", LoadCommand.offset); |
| 535 | IO.mapRequired("nhints", LoadCommand.nhints); |
| 536 | } |
| 537 | |
| 538 | void MappingTraits<MachO::uuid_command>::mapping( |
| 539 | IO &IO, MachO::uuid_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 540 | IO.mapRequired("uuid", LoadCommand.uuid); |
| 541 | } |
| 542 | |
| 543 | void MappingTraits<MachO::version_min_command>::mapping( |
| 544 | IO &IO, MachO::version_min_command &LoadCommand) { |
Chris Bieneman | 0865cea | 2016-05-17 19:44:06 +0000 | [diff] [blame] | 545 | IO.mapRequired("version", LoadCommand.version); |
| 546 | IO.mapRequired("sdk", LoadCommand.sdk); |
Chris Bieneman | 062cef5 | 2016-05-13 17:41:41 +0000 | [diff] [blame] | 547 | } |
| 548 | |
Kevin Enderby | 045015e | 2017-01-19 17:36:31 +0000 | [diff] [blame] | 549 | void MappingTraits<MachO::note_command>::mapping( |
| 550 | IO &IO, MachO::note_command &LoadCommand) { |
Kevin Enderby | 045015e | 2017-01-19 17:36:31 +0000 | [diff] [blame] | 551 | IO.mapRequired("data_owner", LoadCommand.data_owner); |
| 552 | IO.mapRequired("offset", LoadCommand.offset); |
| 553 | IO.mapRequired("size", LoadCommand.size); |
| 554 | } |
| 555 | |
Steven Wu | 6d5a027 | 2017-01-23 20:07:55 +0000 | [diff] [blame] | 556 | void MappingTraits<MachO::build_version_command>::mapping( |
| 557 | IO &IO, MachO::build_version_command &LoadCommand) { |
Steven Wu | 6d5a027 | 2017-01-23 20:07:55 +0000 | [diff] [blame] | 558 | IO.mapRequired("platform", LoadCommand.platform); |
| 559 | IO.mapRequired("minos", LoadCommand.minos); |
| 560 | IO.mapRequired("sdk", LoadCommand.sdk); |
| 561 | IO.mapRequired("ntools", LoadCommand.ntools); |
| 562 | } |
| 563 | |
Eugene Zelenko | cd90344 | 2017-07-01 01:35:55 +0000 | [diff] [blame] | 564 | } // end namespace yaml |
Chris Bieneman | 7455ed8 | 2016-05-12 16:04:16 +0000 | [diff] [blame] | 565 | |
Eugene Zelenko | cd90344 | 2017-07-01 01:35:55 +0000 | [diff] [blame] | 566 | } // end namespace llvm |