LLVM  16.0.0git
MachOYAML.cpp
Go to the documentation of this file.
1 //===- MachOYAML.cpp - MachO YAMLIO implementation ------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines classes for handling the YAML representation of MachO.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 #include "llvm/ADT/StringRef.h"
16 #include "llvm/Support/Format.h"
17 #include "llvm/Support/Host.h"
20 #include <cinttypes>
21 #include <cstdint>
22 #include <cstring>
23 
24 namespace llvm {
25 
27 
29  return 0 == RebaseOpcodes.size() + BindOpcodes.size() +
30  WeakBindOpcodes.size() + LazyBindOpcodes.size() +
31  ExportTrie.Children.size() + NameList.size() +
32  StringTable.size() + FunctionStarts.size();
33 }
34 
35 namespace yaml {
36 
37 void ScalarTraits<char_16>::output(const char_16 &Val, void *,
38  raw_ostream &Out) {
39  auto Len = strnlen(&Val[0], 16);
40  Out << StringRef(&Val[0], Len);
41 }
42 
44  size_t CopySize = 16 >= Scalar.size() ? 16 : Scalar.size();
45  memcpy((void *)Val, Scalar.data(), CopySize);
46 
47  if (Scalar.size() < 16) {
48  memset((void *)&Val[Scalar.size()], 0, 16 - Scalar.size());
49  }
50 
51  return StringRef();
52 }
53 
54 QuotingType ScalarTraits<char_16>::mustQuote(StringRef S) {
55  return needsQuotes(S);
56 }
57 
58 void ScalarTraits<uuid_t>::output(const uuid_t &Val, void *, raw_ostream &Out) {
59  Out.write_uuid(Val);
60 }
61 
63  size_t OutIdx = 0;
64  for (size_t Idx = 0; Idx < Scalar.size(); ++Idx) {
65  if (Scalar[Idx] == '-' || OutIdx >= 16)
66  continue;
67  unsigned long long TempInt;
68  if (getAsUnsignedInteger(Scalar.slice(Idx, Idx + 2), 16, TempInt))
69  return "invalid number";
70  if (TempInt > 0xFF)
71  return "out of range number";
72  Val[OutIdx] = static_cast<uint8_t>(TempInt);
73  ++Idx; // increment idx an extra time because we're consuming 2 chars
74  ++OutIdx;
75  }
76  return StringRef();
77 }
78 
79 QuotingType ScalarTraits<uuid_t>::mustQuote(StringRef S) {
80  return needsQuotes(S);
81 }
82 
84  IO &IO, MachOYAML::FileHeader &FileHdr) {
85  IO.mapRequired("magic", FileHdr.magic);
86  IO.mapRequired("cputype", FileHdr.cputype);
87  IO.mapRequired("cpusubtype", FileHdr.cpusubtype);
88  IO.mapRequired("filetype", FileHdr.filetype);
89  IO.mapRequired("ncmds", FileHdr.ncmds);
90  IO.mapRequired("sizeofcmds", FileHdr.sizeofcmds);
91  IO.mapRequired("flags", FileHdr.flags);
92  if (FileHdr.magic == MachO::MH_MAGIC_64 ||
93  FileHdr.magic == MachO::MH_CIGAM_64)
94  IO.mapRequired("reserved", FileHdr.reserved);
95 }
96 
98  MachOYAML::Object &Object) {
99  // If the context isn't already set, tag the document as !mach-o.
100  // For Fat files there will be a different tag so they can be differentiated.
101  if (!IO.getContext()) {
102  IO.setContext(&Object);
103  }
104  IO.mapTag("!mach-o", true);
105  IO.mapOptional("IsLittleEndian", Object.IsLittleEndian,
107  Object.DWARF.IsLittleEndian = Object.IsLittleEndian;
108 
109  IO.mapRequired("FileHeader", Object.Header);
110  Object.DWARF.Is64BitAddrSize = Object.Header.magic == MachO::MH_MAGIC_64 ||
111  Object.Header.magic == MachO::MH_CIGAM_64;
112  IO.mapOptional("LoadCommands", Object.LoadCommands);
113 
114  if (Object.RawLinkEditSegment || !IO.outputting())
115  IO.mapOptional("__LINKEDIT", Object.RawLinkEditSegment);
116  if(!Object.LinkEdit.isEmpty() || !IO.outputting())
117  IO.mapOptional("LinkEditData", Object.LinkEdit);
118 
119  if(!Object.DWARF.isEmpty() || !IO.outputting())
120  IO.mapOptional("DWARF", Object.DWARF);
121 
122  if (IO.getContext() == &Object)
123  IO.setContext(nullptr);
124 }
125 
127  IO &IO, MachOYAML::FatHeader &FatHeader) {
128  IO.mapRequired("magic", FatHeader.magic);
129  IO.mapRequired("nfat_arch", FatHeader.nfat_arch);
130 }
131 
133  MachOYAML::FatArch &FatArch) {
134  IO.mapRequired("cputype", FatArch.cputype);
135  IO.mapRequired("cpusubtype", FatArch.cpusubtype);
136  IO.mapRequired("offset", FatArch.offset);
137  IO.mapRequired("size", FatArch.size);
138  IO.mapRequired("align", FatArch.align);
139  IO.mapOptional("reserved", FatArch.reserved,
140  static_cast<llvm::yaml::Hex32>(0));
141 }
142 
144  IO &IO, MachOYAML::UniversalBinary &UniversalBinary) {
145  if (!IO.getContext()) {
146  IO.setContext(&UniversalBinary);
147  IO.mapTag("!fat-mach-o", true);
148  }
149  IO.mapRequired("FatHeader", UniversalBinary.Header);
150  IO.mapRequired("FatArchs", UniversalBinary.FatArchs);
151  IO.mapRequired("Slices", UniversalBinary.Slices);
152 
153  if (IO.getContext() == &UniversalBinary)
154  IO.setContext(nullptr);
155 }
156 
158  IO &IO, MachOYAML::LinkEditData &LinkEditData) {
159  IO.mapOptional("RebaseOpcodes", LinkEditData.RebaseOpcodes);
160  IO.mapOptional("BindOpcodes", LinkEditData.BindOpcodes);
161  IO.mapOptional("WeakBindOpcodes", LinkEditData.WeakBindOpcodes);
162  IO.mapOptional("LazyBindOpcodes", LinkEditData.LazyBindOpcodes);
163  if (!LinkEditData.ExportTrie.Children.empty() || !IO.outputting())
164  IO.mapOptional("ExportTrie", LinkEditData.ExportTrie);
165  IO.mapOptional("NameList", LinkEditData.NameList);
166  IO.mapOptional("StringTable", LinkEditData.StringTable);
167  IO.mapOptional("IndirectSymbols", LinkEditData.IndirectSymbols);
168  IO.mapOptional("FunctionStarts", LinkEditData.FunctionStarts);
169 }
170 
173  IO.mapRequired("Opcode", RebaseOpcode.Opcode);
174  IO.mapRequired("Imm", RebaseOpcode.Imm);
175  IO.mapOptional("ExtraData", RebaseOpcode.ExtraData);
176 }
177 
180  IO.mapRequired("Opcode", BindOpcode.Opcode);
181  IO.mapRequired("Imm", BindOpcode.Imm);
182  IO.mapOptional("ULEBExtraData", BindOpcode.ULEBExtraData);
183  IO.mapOptional("SLEBExtraData", BindOpcode.SLEBExtraData);
184  IO.mapOptional("Symbol", BindOpcode.Symbol);
185 }
186 
188  IO &IO, MachOYAML::ExportEntry &ExportEntry) {
189  IO.mapRequired("TerminalSize", ExportEntry.TerminalSize);
190  IO.mapOptional("NodeOffset", ExportEntry.NodeOffset);
191  IO.mapOptional("Name", ExportEntry.Name);
192  IO.mapOptional("Flags", ExportEntry.Flags);
193  IO.mapOptional("Address", ExportEntry.Address);
194  IO.mapOptional("Other", ExportEntry.Other);
195  IO.mapOptional("ImportName", ExportEntry.ImportName);
196  IO.mapOptional("Children", ExportEntry.Children);
197 }
198 
200  IO &IO, MachOYAML::NListEntry &NListEntry) {
201  IO.mapRequired("n_strx", NListEntry.n_strx);
202  IO.mapRequired("n_type", NListEntry.n_type);
203  IO.mapRequired("n_sect", NListEntry.n_sect);
204  IO.mapRequired("n_desc", NListEntry.n_desc);
205  IO.mapRequired("n_value", NListEntry.n_value);
206 }
207 
208 template <typename StructType>
209 void mapLoadCommandData(IO &IO, MachOYAML::LoadCommand &LoadCommand) {}
210 
211 template <>
212 void mapLoadCommandData<MachO::segment_command>(
213  IO &IO, MachOYAML::LoadCommand &LoadCommand) {
214  IO.mapOptional("Sections", LoadCommand.Sections);
215 }
216 
217 template <>
218 void mapLoadCommandData<MachO::segment_command_64>(
219  IO &IO, MachOYAML::LoadCommand &LoadCommand) {
220  IO.mapOptional("Sections", LoadCommand.Sections);
221 }
222 
223 template <>
224 void mapLoadCommandData<MachO::dylib_command>(
225  IO &IO, MachOYAML::LoadCommand &LoadCommand) {
226  IO.mapOptional("Content", LoadCommand.Content);
227 }
228 
229 template <>
230 void mapLoadCommandData<MachO::rpath_command>(
231  IO &IO, MachOYAML::LoadCommand &LoadCommand) {
232  IO.mapOptional("Content", LoadCommand.Content);
233 }
234 
235 template <>
236 void mapLoadCommandData<MachO::dylinker_command>(
237  IO &IO, MachOYAML::LoadCommand &LoadCommand) {
238  IO.mapOptional("Content", LoadCommand.Content);
239 }
240 
241 template <>
242 void mapLoadCommandData<MachO::sub_framework_command>(
243  IO &IO, MachOYAML::LoadCommand &LoadCommand) {
244  IO.mapOptional("Content", LoadCommand.Content);
245 }
246 
247 template <>
248 void mapLoadCommandData<MachO::sub_umbrella_command>(
249  IO &IO, MachOYAML::LoadCommand &LoadCommand) {
250  IO.mapOptional("Content", LoadCommand.Content);
251 }
252 
253 template <>
254 void mapLoadCommandData<MachO::sub_client_command>(
255  IO &IO, MachOYAML::LoadCommand &LoadCommand) {
256  IO.mapOptional("Content", LoadCommand.Content);
257 }
258 
259 template <>
260 void mapLoadCommandData<MachO::sub_library_command>(
261  IO &IO, MachOYAML::LoadCommand &LoadCommand) {
262  IO.mapOptional("Content", LoadCommand.Content);
263 }
264 
265 template <>
266 void mapLoadCommandData<MachO::build_version_command>(
267  IO &IO, MachOYAML::LoadCommand &LoadCommand) {
268  IO.mapOptional("Tools", LoadCommand.Tools);
269 }
270 
272  IO &IO, MachOYAML::LoadCommand &LoadCommand) {
273  MachO::LoadCommandType TempCmd = static_cast<MachO::LoadCommandType>(
274  LoadCommand.Data.load_command_data.cmd);
275  IO.mapRequired("cmd", TempCmd);
276  LoadCommand.Data.load_command_data.cmd = TempCmd;
277  IO.mapRequired("cmdsize", LoadCommand.Data.load_command_data.cmdsize);
278 
279 #define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \
280  case MachO::LCName: \
281  MappingTraits<MachO::LCStruct>::mapping(IO, \
282  LoadCommand.Data.LCStruct##_data); \
283  mapLoadCommandData<MachO::LCStruct>(IO, LoadCommand); \
284  break;
285 
286  switch (LoadCommand.Data.load_command_data.cmd) {
287 #include "llvm/BinaryFormat/MachO.def"
288  }
289  IO.mapOptional("PayloadBytes", LoadCommand.PayloadBytes);
290  IO.mapOptional("ZeroPadBytes", LoadCommand.ZeroPadBytes, (uint64_t)0ull);
291 }
292 
294  IO &IO, MachO::dyld_info_command &LoadCommand) {
295  IO.mapRequired("rebase_off", LoadCommand.rebase_off);
296  IO.mapRequired("rebase_size", LoadCommand.rebase_size);
297  IO.mapRequired("bind_off", LoadCommand.bind_off);
298  IO.mapRequired("bind_size", LoadCommand.bind_size);
299  IO.mapRequired("weak_bind_off", LoadCommand.weak_bind_off);
300  IO.mapRequired("weak_bind_size", LoadCommand.weak_bind_size);
301  IO.mapRequired("lazy_bind_off", LoadCommand.lazy_bind_off);
302  IO.mapRequired("lazy_bind_size", LoadCommand.lazy_bind_size);
303  IO.mapRequired("export_off", LoadCommand.export_off);
304  IO.mapRequired("export_size", LoadCommand.export_size);
305 }
306 
308  IO &IO, MachOYAML::Relocation &Relocation) {
309  IO.mapRequired("address", Relocation.address);
310  IO.mapRequired("symbolnum", Relocation.symbolnum);
311  IO.mapRequired("pcrel", Relocation.is_pcrel);
312  IO.mapRequired("length", Relocation.length);
313  IO.mapRequired("extern", Relocation.is_extern);
314  IO.mapRequired("type", Relocation.type);
315  IO.mapRequired("scattered", Relocation.is_scattered);
316  IO.mapRequired("value", Relocation.value);
317 }
318 
320  MachOYAML::Section &Section) {
321  IO.mapRequired("sectname", Section.sectname);
322  IO.mapRequired("segname", Section.segname);
323  IO.mapRequired("addr", Section.addr);
324  IO.mapRequired("size", Section.size);
325  IO.mapRequired("offset", Section.offset);
326  IO.mapRequired("align", Section.align);
327  IO.mapRequired("reloff", Section.reloff);
328  IO.mapRequired("nreloc", Section.nreloc);
329  IO.mapRequired("flags", Section.flags);
330  IO.mapRequired("reserved1", Section.reserved1);
331  IO.mapRequired("reserved2", Section.reserved2);
332  IO.mapOptional("reserved3", Section.reserved3);
333  IO.mapOptional("content", Section.content);
334  IO.mapOptional("relocations", Section.relocations);
335 }
336 
337 std::string
339  MachOYAML::Section &Section) {
340  if (Section.content && Section.size < Section.content->binary_size())
341  return "Section size must be greater than or equal to the content size";
342  return "";
343 }
344 
346  IO &IO, MachO::build_tool_version &tool) {
347  IO.mapRequired("tool", tool.tool);
348  IO.mapRequired("version", tool.version);
349 }
350 
352  IO.mapRequired("name", DylibStruct.name);
353  IO.mapRequired("timestamp", DylibStruct.timestamp);
354  IO.mapRequired("current_version", DylibStruct.current_version);
355  IO.mapRequired("compatibility_version", DylibStruct.compatibility_version);
356 }
357 
359  IO &IO, MachO::dylib_command &LoadCommand) {
360  IO.mapRequired("dylib", LoadCommand.dylib);
361 }
362 
363 void MappingTraits<MachO::dylinker_command>::mapping(
364  IO &IO, MachO::dylinker_command &LoadCommand) {
365  IO.mapRequired("name", LoadCommand.name);
366 }
367 
368 void MappingTraits<MachO::dysymtab_command>::mapping(
369  IO &IO, MachO::dysymtab_command &LoadCommand) {
370  IO.mapRequired("ilocalsym", LoadCommand.ilocalsym);
371  IO.mapRequired("nlocalsym", LoadCommand.nlocalsym);
372  IO.mapRequired("iextdefsym", LoadCommand.iextdefsym);
373  IO.mapRequired("nextdefsym", LoadCommand.nextdefsym);
374  IO.mapRequired("iundefsym", LoadCommand.iundefsym);
375  IO.mapRequired("nundefsym", LoadCommand.nundefsym);
376  IO.mapRequired("tocoff", LoadCommand.tocoff);
377  IO.mapRequired("ntoc", LoadCommand.ntoc);
378  IO.mapRequired("modtaboff", LoadCommand.modtaboff);
379  IO.mapRequired("nmodtab", LoadCommand.nmodtab);
380  IO.mapRequired("extrefsymoff", LoadCommand.extrefsymoff);
381  IO.mapRequired("nextrefsyms", LoadCommand.nextrefsyms);
382  IO.mapRequired("indirectsymoff", LoadCommand.indirectsymoff);
383  IO.mapRequired("nindirectsyms", LoadCommand.nindirectsyms);
384  IO.mapRequired("extreloff", LoadCommand.extreloff);
385  IO.mapRequired("nextrel", LoadCommand.nextrel);
386  IO.mapRequired("locreloff", LoadCommand.locreloff);
387  IO.mapRequired("nlocrel", LoadCommand.nlocrel);
388 }
389 
390 void MappingTraits<MachO::encryption_info_command>::mapping(
391  IO &IO, MachO::encryption_info_command &LoadCommand) {
392  IO.mapRequired("cryptoff", LoadCommand.cryptoff);
393  IO.mapRequired("cryptsize", LoadCommand.cryptsize);
394  IO.mapRequired("cryptid", LoadCommand.cryptid);
395 }
396 
397 void MappingTraits<MachO::encryption_info_command_64>::mapping(
398  IO &IO, MachO::encryption_info_command_64 &LoadCommand) {
399  IO.mapRequired("cryptoff", LoadCommand.cryptoff);
400  IO.mapRequired("cryptsize", LoadCommand.cryptsize);
401  IO.mapRequired("cryptid", LoadCommand.cryptid);
402  IO.mapRequired("pad", LoadCommand.pad);
403 }
404 
405 void MappingTraits<MachO::entry_point_command>::mapping(
406  IO &IO, MachO::entry_point_command &LoadCommand) {
407  IO.mapRequired("entryoff", LoadCommand.entryoff);
408  IO.mapRequired("stacksize", LoadCommand.stacksize);
409 }
410 
411 void MappingTraits<MachO::fvmfile_command>::mapping(
412  IO &IO, MachO::fvmfile_command &LoadCommand) {
413  IO.mapRequired("name", LoadCommand.name);
414  IO.mapRequired("header_addr", LoadCommand.header_addr);
415 }
416 
418  IO.mapRequired("name", FVMLib.name);
419  IO.mapRequired("minor_version", FVMLib.minor_version);
420  IO.mapRequired("header_addr", FVMLib.header_addr);
421 }
422 
424  IO &IO, MachO::fvmlib_command &LoadCommand) {
425  IO.mapRequired("fvmlib", LoadCommand.fvmlib);
426 }
427 
428 void MappingTraits<MachO::ident_command>::mapping(
429  IO &IO, MachO::ident_command &LoadCommand) {}
430 
431 void MappingTraits<MachO::linkedit_data_command>::mapping(
432  IO &IO, MachO::linkedit_data_command &LoadCommand) {
433  IO.mapRequired("dataoff", LoadCommand.dataoff);
434  IO.mapRequired("datasize", LoadCommand.datasize);
435 }
436 
437 void MappingTraits<MachO::linker_option_command>::mapping(
438  IO &IO, MachO::linker_option_command &LoadCommand) {
439  IO.mapRequired("count", LoadCommand.count);
440 }
441 
442 void MappingTraits<MachO::prebind_cksum_command>::mapping(
443  IO &IO, MachO::prebind_cksum_command &LoadCommand) {
444  IO.mapRequired("cksum", LoadCommand.cksum);
445 }
446 
447 void MappingTraits<MachO::load_command>::mapping(
448  IO &IO, MachO::load_command &LoadCommand) {}
449 
450 void MappingTraits<MachO::prebound_dylib_command>::mapping(
451  IO &IO, MachO::prebound_dylib_command &LoadCommand) {
452  IO.mapRequired("name", LoadCommand.name);
453  IO.mapRequired("nmodules", LoadCommand.nmodules);
454  IO.mapRequired("linked_modules", LoadCommand.linked_modules);
455 }
456 
457 void MappingTraits<MachO::routines_command>::mapping(
458  IO &IO, MachO::routines_command &LoadCommand) {
459  IO.mapRequired("init_address", LoadCommand.init_address);
460  IO.mapRequired("init_module", LoadCommand.init_module);
461  IO.mapRequired("reserved1", LoadCommand.reserved1);
462  IO.mapRequired("reserved2", LoadCommand.reserved2);
463  IO.mapRequired("reserved3", LoadCommand.reserved3);
464  IO.mapRequired("reserved4", LoadCommand.reserved4);
465  IO.mapRequired("reserved5", LoadCommand.reserved5);
466  IO.mapRequired("reserved6", LoadCommand.reserved6);
467 }
468 
469 void MappingTraits<MachO::routines_command_64>::mapping(
470  IO &IO, MachO::routines_command_64 &LoadCommand) {
471  IO.mapRequired("init_address", LoadCommand.init_address);
472  IO.mapRequired("init_module", LoadCommand.init_module);
473  IO.mapRequired("reserved1", LoadCommand.reserved1);
474  IO.mapRequired("reserved2", LoadCommand.reserved2);
475  IO.mapRequired("reserved3", LoadCommand.reserved3);
476  IO.mapRequired("reserved4", LoadCommand.reserved4);
477  IO.mapRequired("reserved5", LoadCommand.reserved5);
478  IO.mapRequired("reserved6", LoadCommand.reserved6);
479 }
480 
481 void MappingTraits<MachO::rpath_command>::mapping(
482  IO &IO, MachO::rpath_command &LoadCommand) {
483  IO.mapRequired("path", LoadCommand.path);
484 }
485 
487  IO.mapRequired("sectname", Section.sectname);
488  IO.mapRequired("segname", Section.segname);
489  IO.mapRequired("addr", Section.addr);
490  IO.mapRequired("size", Section.size);
491  IO.mapRequired("offset", Section.offset);
492  IO.mapRequired("align", Section.align);
493  IO.mapRequired("reloff", Section.reloff);
494  IO.mapRequired("nreloc", Section.nreloc);
495  IO.mapRequired("flags", Section.flags);
496  IO.mapRequired("reserved1", Section.reserved1);
497  IO.mapRequired("reserved2", Section.reserved2);
498 }
499 
501  MachO::section_64 &Section) {
502  IO.mapRequired("sectname", Section.sectname);
503  IO.mapRequired("segname", Section.segname);
504  IO.mapRequired("addr", Section.addr);
505  IO.mapRequired("size", Section.size);
506  IO.mapRequired("offset", Section.offset);
507  IO.mapRequired("align", Section.align);
508  IO.mapRequired("reloff", Section.reloff);
509  IO.mapRequired("nreloc", Section.nreloc);
510  IO.mapRequired("flags", Section.flags);
511  IO.mapRequired("reserved1", Section.reserved1);
512  IO.mapRequired("reserved2", Section.reserved2);
513  IO.mapRequired("reserved3", Section.reserved3);
514 }
515 
517  IO &IO, MachO::segment_command &LoadCommand) {
518  IO.mapRequired("segname", LoadCommand.segname);
519  IO.mapRequired("vmaddr", LoadCommand.vmaddr);
520  IO.mapRequired("vmsize", LoadCommand.vmsize);
521  IO.mapRequired("fileoff", LoadCommand.fileoff);
522  IO.mapRequired("filesize", LoadCommand.filesize);
523  IO.mapRequired("maxprot", LoadCommand.maxprot);
524  IO.mapRequired("initprot", LoadCommand.initprot);
525  IO.mapRequired("nsects", LoadCommand.nsects);
526  IO.mapRequired("flags", LoadCommand.flags);
527 }
528 
529 void MappingTraits<MachO::segment_command_64>::mapping(
530  IO &IO, MachO::segment_command_64 &LoadCommand) {
531  IO.mapRequired("segname", LoadCommand.segname);
532  IO.mapRequired("vmaddr", LoadCommand.vmaddr);
533  IO.mapRequired("vmsize", LoadCommand.vmsize);
534  IO.mapRequired("fileoff", LoadCommand.fileoff);
535  IO.mapRequired("filesize", LoadCommand.filesize);
536  IO.mapRequired("maxprot", LoadCommand.maxprot);
537  IO.mapRequired("initprot", LoadCommand.initprot);
538  IO.mapRequired("nsects", LoadCommand.nsects);
539  IO.mapRequired("flags", LoadCommand.flags);
540 }
541 
542 void MappingTraits<MachO::source_version_command>::mapping(
543  IO &IO, MachO::source_version_command &LoadCommand) {
544  IO.mapRequired("version", LoadCommand.version);
545 }
546 
547 void MappingTraits<MachO::sub_client_command>::mapping(
548  IO &IO, MachO::sub_client_command &LoadCommand) {
549  IO.mapRequired("client", LoadCommand.client);
550 }
551 
552 void MappingTraits<MachO::sub_framework_command>::mapping(
553  IO &IO, MachO::sub_framework_command &LoadCommand) {
554  IO.mapRequired("umbrella", LoadCommand.umbrella);
555 }
556 
557 void MappingTraits<MachO::sub_library_command>::mapping(
558  IO &IO, MachO::sub_library_command &LoadCommand) {
559  IO.mapRequired("sub_library", LoadCommand.sub_library);
560 }
561 
562 void MappingTraits<MachO::sub_umbrella_command>::mapping(
563  IO &IO, MachO::sub_umbrella_command &LoadCommand) {
564  IO.mapRequired("sub_umbrella", LoadCommand.sub_umbrella);
565 }
566 
567 void MappingTraits<MachO::symseg_command>::mapping(
568  IO &IO, MachO::symseg_command &LoadCommand) {
569  IO.mapRequired("offset", LoadCommand.offset);
570  IO.mapRequired("size", LoadCommand.size);
571 }
572 
573 void MappingTraits<MachO::symtab_command>::mapping(
574  IO &IO, MachO::symtab_command &LoadCommand) {
575  IO.mapRequired("symoff", LoadCommand.symoff);
576  IO.mapRequired("nsyms", LoadCommand.nsyms);
577  IO.mapRequired("stroff", LoadCommand.stroff);
578  IO.mapRequired("strsize", LoadCommand.strsize);
579 }
580 
581 void MappingTraits<MachO::thread_command>::mapping(
582  IO &IO, MachO::thread_command &LoadCommand) {}
583 
584 void MappingTraits<MachO::twolevel_hints_command>::mapping(
585  IO &IO, MachO::twolevel_hints_command &LoadCommand) {
586  IO.mapRequired("offset", LoadCommand.offset);
587  IO.mapRequired("nhints", LoadCommand.nhints);
588 }
589 
590 void MappingTraits<MachO::uuid_command>::mapping(
591  IO &IO, MachO::uuid_command &LoadCommand) {
592  IO.mapRequired("uuid", LoadCommand.uuid);
593 }
594 
595 void MappingTraits<MachO::version_min_command>::mapping(
596  IO &IO, MachO::version_min_command &LoadCommand) {
597  IO.mapRequired("version", LoadCommand.version);
598  IO.mapRequired("sdk", LoadCommand.sdk);
599 }
600 
601 void MappingTraits<MachO::note_command>::mapping(
602  IO &IO, MachO::note_command &LoadCommand) {
603  IO.mapRequired("data_owner", LoadCommand.data_owner);
604  IO.mapRequired("offset", LoadCommand.offset);
605  IO.mapRequired("size", LoadCommand.size);
606 }
607 
608 void MappingTraits<MachO::build_version_command>::mapping(
609  IO &IO, MachO::build_version_command &LoadCommand) {
610  IO.mapRequired("platform", LoadCommand.platform);
611  IO.mapRequired("minos", LoadCommand.minos);
612  IO.mapRequired("sdk", LoadCommand.sdk);
613  IO.mapRequired("ntools", LoadCommand.ntools);
614 }
615 
616 void MappingTraits<MachO::fileset_entry_command>::mapping(
617  IO &IO, MachO::fileset_entry_command &LoadCommand) {
618  IO.mapRequired("vmaddr", LoadCommand.vmaddr);
619  IO.mapRequired("fileoff", LoadCommand.fileoff);
620  IO.mapRequired("id", LoadCommand.entry_id);
621 }
622 
623 } // end namespace yaml
624 
625 } // end namespace llvm
llvm::MachO::dylib
Definition: MachO.h:617
llvm::MachOYAML::ExportEntry
Definition: MachOYAML.h:105
llvm::MachO::segment_command_64::flags
uint32_t flags
Definition: MachO.h:567
llvm::MachO::build_tool_version::tool
uint32_t tool
Definition: MachO.h:858
llvm::MachOYAML::FatArch::offset
llvm::yaml::Hex64 offset
Definition: MachOYAML.h:148
llvm::MachO::segment_command_64::initprot
uint32_t initprot
Definition: MachO.h:565
llvm::MachOYAML::LoadCommand::Sections
std::vector< Section > Sections
Definition: MachOYAML.h:76
llvm::MachO::section
Definition: MachO.h:570
llvm::MachOYAML::NListEntry::n_desc
uint16_t n_desc
Definition: MachOYAML.h:87
llvm::MachO::dylib::compatibility_version
uint32_t compatibility_version
Definition: MachO.h:621
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::MachOYAML::Object
Definition: MachOYAML.h:130
llvm::MachOYAML::Relocation::is_scattered
bool is_scattered
Definition: MachOYAML.h:40
llvm::MachOYAML::Section
Definition: MachOYAML.h:44
llvm::MachOYAML::Relocation::is_pcrel
bool is_pcrel
Definition: MachOYAML.h:35
llvm::yaml::char_16
char[16] char_16
Definition: MachOYAML.h:284
StringRef.h
llvm::MachO::segment_command_64::nsects
uint32_t nsects
Definition: MachO.h:566
llvm::MachOYAML::ExportEntry::Address
llvm::yaml::Hex64 Address
Definition: MachOYAML.h:110
llvm::MachOYAML::LinkEditData::ExportTrie
MachOYAML::ExportEntry ExportTrie
Definition: MachOYAML.h:121
Host.h
llvm::MachO::fvmlib::header_addr
uint32_t header_addr
Definition: MachO.h:607
output
Current output
Definition: README.txt:1350
llvm::MachOYAML::LoadCommand::ZeroPadBytes
uint64_t ZeroPadBytes
Definition: MachOYAML.h:80
llvm::MachO::segment_command::filesize
uint32_t filesize
Definition: MachO.h:549
llvm::MachOYAML::FatHeader::nfat_arch
uint32_t nfat_arch
Definition: MachOYAML.h:142
llvm::MachO::dylib::name
uint32_t name
Definition: MachO.h:618
llvm::MachO::segment_command::fileoff
uint32_t fileoff
Definition: MachO.h:548
llvm::MachO::segment_command::vmsize
uint32_t vmsize
Definition: MachO.h:547
llvm::MachO::fvmlib
Definition: MachO.h:604
llvm::MachOYAML::UniversalBinary::FatArchs
std::vector< FatArch > FatArchs
Definition: MachOYAML.h:156
llvm::MachOYAML::ExportEntry::Flags
llvm::yaml::Hex64 Flags
Definition: MachOYAML.h:109
llvm::MachOYAML::LinkEditData::LazyBindOpcodes
std::vector< MachOYAML::BindOpcode > LazyBindOpcodes
Definition: MachOYAML.h:120
llvm::MachOYAML::NListEntry
Definition: MachOYAML.h:83
llvm::MachOYAML::LoadCommand::PayloadBytes
std::vector< llvm::yaml::Hex8 > PayloadBytes
Definition: MachOYAML.h:78
llvm::MachO::LoadCommandType
LoadCommandType
Definition: MachO.h:98
llvm::MachO::dyld_info_command::export_off
uint32_t export_off
Definition: MachO.h:889
llvm::MachO::fvmlib::minor_version
uint32_t minor_version
Definition: MachO.h:606
llvm::MachOYAML::ExportEntry::NodeOffset
uint64_t NodeOffset
Definition: MachOYAML.h:107
llvm::MachOYAML::LinkEditData::FunctionStarts
std::vector< yaml::Hex64 > FunctionStarts
Definition: MachOYAML.h:125
llvm::yaml::MappingTraits
Definition: ModuleSummaryIndex.h:51
llvm::RISCVFeatures::validate
void validate(const Triple &TT, const FeatureBitset &FeatureBits)
Definition: RISCVBaseInfo.cpp:97
Format.h
llvm::MachOYAML::LinkEditData::RebaseOpcodes
std::vector< MachOYAML::RebaseOpcode > RebaseOpcodes
Definition: MachOYAML.h:117
llvm::MachO::build_tool_version::version
uint32_t version
Definition: MachO.h:859
llvm::yaml::uuid_t
raw_ostream::uuid_t uuid_t
Definition: MachOYAML.h:294
llvm::MachOYAML::Relocation::address
llvm::yaml::Hex32 address
Definition: MachOYAML.h:32
llvm::MachOYAML::RebaseOpcode
Definition: MachOYAML.h:91
llvm::MachOYAML::LoadCommand::Content
std::string Content
Definition: MachOYAML.h:79
llvm::MachOYAML::FileHeader::sizeofcmds
uint32_t sizeofcmds
Definition: MachOYAML.h:67
llvm::MachO::dyld_info_command
Definition: MachO.h:878
llvm::MachOYAML::ExportEntry::Other
llvm::yaml::Hex64 Other
Definition: MachOYAML.h:111
llvm::MachOYAML::LinkEditData::IndirectSymbols
std::vector< yaml::Hex32 > IndirectSymbols
Definition: MachOYAML.h:124
llvm::MachO::fvmlib::name
uint32_t name
Definition: MachO.h:605
llvm::MachOYAML::LinkEditData::isEmpty
bool isEmpty() const
Definition: MachOYAML.cpp:28
llvm::MachOYAML::Relocation::is_extern
bool is_extern
Definition: MachOYAML.h:38
llvm::MachOYAML::BindOpcode
Definition: MachOYAML.h:97
llvm::getAsUnsignedInteger
bool getAsUnsignedInteger(StringRef Str, unsigned Radix, unsigned long long &Result)
Helper functions for StringRef::getAsInteger.
Definition: StringRef.cpp:492
llvm::MachOYAML::ExportEntry::Name
std::string Name
Definition: MachOYAML.h:108
llvm::MachO::segment_command_64::segname
char segname[16]
Definition: MachO.h:559
llvm::MachOYAML::FatArch::align
uint32_t align
Definition: MachOYAML.h:150
llvm::MachOYAML::NListEntry::n_value
uint64_t n_value
Definition: MachOYAML.h:88
llvm::MachOYAML::FatArch::cputype
llvm::yaml::Hex32 cputype
Definition: MachOYAML.h:146
llvm::MachOYAML::UniversalBinary
Definition: MachOYAML.h:154
llvm::MachO::segment_command::segname
char segname[16]
Definition: MachO.h:545
llvm::MachOYAML::UniversalBinary::Slices
std::vector< Object > Slices
Definition: MachOYAML.h:157
llvm::MachO::dylib_command::dylib
struct dylib dylib
Definition: MachO.h:627
llvm::MachOYAML::FileHeader::filetype
llvm::yaml::Hex32 filetype
Definition: MachOYAML.h:65
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
llvm::MachOYAML::LoadCommand::Data
llvm::MachO::macho_load_command Data
Definition: MachOYAML.h:75
llvm::MachO::ident_command
Definition: MachO.h:916
llvm::MachO::segment_command::initprot
uint32_t initprot
Definition: MachO.h:551
input
The initial backend is deliberately restricted to z10 We should add support for later architectures at some point If an asm ties an i32 r result to an i64 input
Definition: README.txt:10
llvm::MachOYAML::LoadCommand
Definition: MachOYAML.h:72
llvm::MachOYAML::LinkEditData::NameList
std::vector< NListEntry > NameList
Definition: MachOYAML.h:122
llvm::MachO::fvmlib_command
Definition: MachO.h:611
llvm::OutputFileType::Object
@ Object
llvm::MachOYAML::FatArch::cpusubtype
llvm::yaml::Hex32 cpusubtype
Definition: MachOYAML.h:147
llvm::MachOYAML::FileHeader::reserved
llvm::yaml::Hex32 reserved
Definition: MachOYAML.h:69
llvm::MachO::dylib_command
Definition: MachO.h:624
llvm::MachO::dylinker_command::name
uint32_t name
Definition: MachO.h:666
llvm::MachOYAML::UniversalBinary::Header
FatHeader Header
Definition: MachOYAML.h:155
uint64_t
llvm::MachOYAML::ExportEntry::ImportName
std::string ImportName
Definition: MachOYAML.h:112
llvm::MachOYAML::FileHeader::flags
llvm::yaml::Hex32 flags
Definition: MachOYAML.h:68
llvm::MachO::build_tool_version
Definition: MachO.h:857
llvm::MachOYAML::Relocation::value
int32_t value
Definition: MachOYAML.h:41
llvm::MachOYAML::Relocation::type
uint8_t type
Definition: MachOYAML.h:39
MachOYAML.h
llvm::MachO::dyld_info_command::weak_bind_size
uint32_t weak_bind_size
Definition: MachO.h:886
llvm::MachOYAML::NListEntry::n_sect
uint8_t n_sect
Definition: MachOYAML.h:86
llvm::MachO::dyld_info_command::lazy_bind_off
uint32_t lazy_bind_off
Definition: MachO.h:887
llvm::MachOYAML::FatArch::size
uint64_t size
Definition: MachOYAML.h:149
llvm::MachO::segment_command_64::fileoff
uint64_t fileoff
Definition: MachO.h:562
llvm::MachO::dyld_info_command::bind_size
uint32_t bind_size
Definition: MachO.h:884
llvm::MachOYAML::FileHeader
Definition: MachOYAML.h:61
llvm::MachOYAML::NListEntry::n_type
llvm::yaml::Hex8 n_type
Definition: MachOYAML.h:85
memcpy
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
llvm::MachO::segment_command
Definition: MachO.h:542
llvm::MachO::dylinker_command
Definition: MachO.h:663
llvm::MachO::RebaseOpcode
RebaseOpcode
Definition: MachO.h:242
llvm::MachOYAML::NListEntry::n_strx
uint32_t n_strx
Definition: MachOYAML.h:84
llvm::MachO::segment_command::vmaddr
uint32_t vmaddr
Definition: MachO.h:546
YAMLTraits.h
llvm::MachOYAML::LinkEditData
Definition: MachOYAML.h:116
llvm::MachOYAML::LoadCommand::~LoadCommand
virtual ~LoadCommand()
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::MachOYAML::ExportEntry::TerminalSize
uint64_t TerminalSize
Definition: MachOYAML.h:106
llvm::MachOYAML::FileHeader::cputype
llvm::yaml::Hex32 cputype
Definition: MachOYAML.h:63
llvm::MachO::dyld_info_command::rebase_size
uint32_t rebase_size
Definition: MachO.h:882
llvm::MachOYAML::LinkEditData::WeakBindOpcodes
std::vector< MachOYAML::BindOpcode > WeakBindOpcodes
Definition: MachOYAML.h:119
llvm::MachOYAML::FileHeader::magic
llvm::yaml::Hex32 magic
Definition: MachOYAML.h:62
llvm::MachO::segment_command_64
Definition: MachO.h:556
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::MachO::dyld_info_command::weak_bind_off
uint32_t weak_bind_off
Definition: MachO.h:885
llvm::MachOYAML::LinkEditData::BindOpcodes
std::vector< MachOYAML::BindOpcode > BindOpcodes
Definition: MachOYAML.h:118
llvm::MachOYAML::LoadCommand::Tools
std::vector< MachO::build_tool_version > Tools
Definition: MachOYAML.h:77
llvm::MachO::segment_command::maxprot
uint32_t maxprot
Definition: MachO.h:550
llvm::MachO::dylib::timestamp
uint32_t timestamp
Definition: MachO.h:619
llvm::MachO::section_64
Definition: MachO.h:584
llvm::MachOYAML::FileHeader::cpusubtype
llvm::yaml::Hex32 cpusubtype
Definition: MachOYAML.h:64
llvm::MachO::segment_command::nsects
uint32_t nsects
Definition: MachO.h:552
llvm::MachO::segment_command_64::filesize
uint64_t filesize
Definition: MachO.h:563
llvm::MachOYAML::FatArch
Definition: MachOYAML.h:145
llvm::MachO::segment_command_64::vmaddr
uint64_t vmaddr
Definition: MachO.h:560
llvm::MachOYAML::Relocation::symbolnum
uint32_t symbolnum
Definition: MachOYAML.h:34
llvm::MachOYAML::FatArch::reserved
llvm::yaml::Hex32 reserved
Definition: MachOYAML.h:151
llvm::MachO::dylib::current_version
uint32_t current_version
Definition: MachO.h:620
llvm::MachO::segment_command::flags
uint32_t flags
Definition: MachO.h:553
llvm::sys::IsLittleEndianHost
static const bool IsLittleEndianHost
Definition: SwapByteOrder.h:101
llvm::MachOYAML::LinkEditData::StringTable
std::vector< StringRef > StringTable
Definition: MachOYAML.h:123
llvm::MachOYAML::FileHeader::ncmds
uint32_t ncmds
Definition: MachOYAML.h:66
llvm::MachO::dyld_info_command::bind_off
uint32_t bind_off
Definition: MachO.h:883
llvm::MachOYAML::FatHeader::magic
llvm::yaml::Hex32 magic
Definition: MachOYAML.h:141
llvm::MachO::dyld_info_command::rebase_off
uint32_t rebase_off
Definition: MachO.h:881
llvm::MachO::dyld_info_command::lazy_bind_size
uint32_t lazy_bind_size
Definition: MachO.h:888
llvm::MachOYAML::ExportEntry::Children
std::vector< MachOYAML::ExportEntry > Children
Definition: MachOYAML.h:113
llvm::MachO::segment_command_64::maxprot
uint32_t maxprot
Definition: MachO.h:564
MachO.h
llvm::MachO::MH_CIGAM_64
@ MH_CIGAM_64
Definition: MachO.h:33
llvm::MachO::MH_MAGIC_64
@ MH_MAGIC_64
Definition: MachO.h:32
llvm::MachO::dyld_info_command::export_size
uint32_t export_size
Definition: MachO.h:890
raw_ostream.h
llvm::MachO::fvmlib_command::fvmlib
struct fvmlib fvmlib
Definition: MachO.h:614
llvm::MachO::segment_command_64::vmsize
uint64_t vmsize
Definition: MachO.h:561
llvm::raw_ostream::write_uuid
raw_ostream & write_uuid(const uuid_t UUID)
Definition: raw_ostream.cpp:151
llvm::MachOYAML::Relocation
Definition: MachOYAML.h:30
llvm::MachOYAML::Relocation::length
uint8_t length
Definition: MachOYAML.h:37
llvm::yaml::mapLoadCommandData
void mapLoadCommandData(IO &IO, MachOYAML::LoadCommand &LoadCommand)
Definition: MachOYAML.cpp:209
llvm::MachO::BindOpcode
BindOpcode
Definition: MachO.h:275
llvm::MachOYAML::FatHeader
Definition: MachOYAML.h:140