38 void ScalarTraits<char_16>::output(
const char_16 &Val,
void *,
40 auto Len = strnlen(&Val[0], 16);
45 size_t CopySize = 16 >= Scalar.
size() ? 16 : Scalar.
size();
48 if (Scalar.
size() < 16) {
55 QuotingType ScalarTraits<char_16>::mustQuote(
StringRef S) {
56 return needsQuotes(S);
65 for (
size_t Idx = 0; Idx < Scalar.
size(); ++Idx) {
66 if (Scalar[Idx] ==
'-' || OutIdx >= 16)
68 unsigned long long TempInt;
70 return "invalid number";
72 return "out of range number";
73 Val[OutIdx] =
static_cast<uint8_t
>(TempInt);
80 QuotingType ScalarTraits<uuid_t>::mustQuote(
StringRef S) {
81 return needsQuotes(S);
86 IO.mapRequired(
"magic", FileHdr.
magic);
87 IO.mapRequired(
"cputype", FileHdr.
cputype);
88 IO.mapRequired(
"cpusubtype", FileHdr.
cpusubtype);
89 IO.mapRequired(
"filetype", FileHdr.
filetype);
90 IO.mapRequired(
"ncmds", FileHdr.
ncmds);
91 IO.mapRequired(
"sizeofcmds", FileHdr.
sizeofcmds);
92 IO.mapRequired(
"flags", FileHdr.
flags);
95 IO.mapRequired(
"reserved", FileHdr.
reserved);
102 if (!IO.getContext()) {
103 IO.setContext(&Object);
105 IO.mapTag(
"!mach-o",
true);
110 IO.mapRequired(
"FileHeader", Object.
Header);
113 IO.mapOptional(
"LinkEditData", Object.
LinkEdit);
116 IO.mapOptional(
"DWARF", Object.
DWARF);
118 if (IO.getContext() == &Object)
119 IO.setContext(
nullptr);
124 IO.mapRequired(
"magic", FatHeader.
magic);
125 IO.mapRequired(
"nfat_arch", FatHeader.
nfat_arch);
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));
141 if (!IO.getContext()) {
142 IO.setContext(&UniversalBinary);
143 IO.mapTag(
"!fat-mach-o",
true);
145 IO.mapRequired(
"FatHeader", UniversalBinary.
Header);
146 IO.mapRequired(
"FatArchs", UniversalBinary.
FatArchs);
147 IO.mapRequired(
"Slices", UniversalBinary.
Slices);
149 if (IO.getContext() == &UniversalBinary)
150 IO.setContext(
nullptr);
156 IO.mapOptional(
"BindOpcodes", LinkEditData.
BindOpcodes);
160 IO.mapOptional(
"ExportTrie", LinkEditData.
ExportTrie);
161 IO.mapOptional(
"NameList", LinkEditData.
NameList);
162 IO.mapOptional(
"StringTable", LinkEditData.
StringTable);
167 IO.mapRequired(
"Opcode", RebaseOpcode.
Opcode);
168 IO.mapRequired(
"Imm", RebaseOpcode.
Imm);
169 IO.mapOptional(
"ExtraData", RebaseOpcode.
ExtraData);
174 IO.mapRequired(
"Opcode", BindOpcode.
Opcode);
175 IO.mapRequired(
"Imm", BindOpcode.
Imm);
178 IO.mapOptional(
"Symbol", BindOpcode.
Symbol);
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);
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);
202 template <
typename StructType>
206 void mapLoadCommandData<MachO::segment_command>(
208 IO.mapOptional(
"Sections", LoadCommand.Sections);
212 void mapLoadCommandData<MachO::segment_command_64>(
214 IO.mapOptional(
"Sections", LoadCommand.Sections);
218 void mapLoadCommandData<MachO::dylib_command>(
220 IO.mapOptional(
"PayloadString", LoadCommand.PayloadString);
224 void mapLoadCommandData<MachO::rpath_command>(
226 IO.mapOptional(
"PayloadString", LoadCommand.PayloadString);
230 void mapLoadCommandData<MachO::dylinker_command>(
232 IO.mapOptional(
"PayloadString", LoadCommand.PayloadString);
236 void mapLoadCommandData<MachO::build_version_command>(
238 IO.mapOptional(
"Tools", LoadCommand.Tools);
244 LoadCommand.
Data.load_command_data.cmd);
245 IO.mapRequired(
"cmd", TempCmd);
246 LoadCommand.
Data.load_command_data.cmd = TempCmd;
247 IO.mapRequired(
"cmdsize", LoadCommand.
Data.load_command_data.cmdsize);
249 #define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \ 250 case MachO::LCName: \ 251 MappingTraits<MachO::LCStruct>::mapping(IO, \ 252 LoadCommand.Data.LCStruct##_data); \ 253 mapLoadCommandData<MachO::LCStruct>(IO, LoadCommand); \ 256 switch (LoadCommand.
Data.load_command_data.cmd) {
257 #include "llvm/BinaryFormat/MachO.def" 259 IO.mapOptional(
"PayloadBytes", LoadCommand.
PayloadBytes);
260 IO.mapOptional(
"ZeroPadBytes", LoadCommand.
ZeroPadBytes, (uint64_t)0ull);
265 IO.mapRequired(
"rebase_off", LoadCommand.
rebase_off);
266 IO.mapRequired(
"rebase_size", LoadCommand.
rebase_size);
267 IO.mapRequired(
"bind_off", LoadCommand.
bind_off);
268 IO.mapRequired(
"bind_size", LoadCommand.
bind_size);
273 IO.mapRequired(
"export_off", LoadCommand.
export_off);
274 IO.mapRequired(
"export_size", LoadCommand.
export_size);
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);
295 IO.mapRequired(
"tool", tool.
tool);
296 IO.mapRequired(
"version", tool.
version);
300 IO.mapRequired(
"name", DylibStruct.
name);
301 IO.mapRequired(
"timestamp", DylibStruct.
timestamp);
308 IO.mapRequired(
"dylib", LoadCommand.
dylib);
313 IO.mapRequired(
"name", LoadCommand.
name);
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);
332 IO.mapRequired(
"extreloff", LoadCommand.
extreloff);
333 IO.mapRequired(
"nextrel", LoadCommand.
nextrel);
334 IO.mapRequired(
"locreloff", LoadCommand.
locreloff);
335 IO.mapRequired(
"nlocrel", LoadCommand.
nlocrel);
340 IO.mapRequired(
"cryptoff", LoadCommand.
cryptoff);
341 IO.mapRequired(
"cryptsize", LoadCommand.
cryptsize);
342 IO.mapRequired(
"cryptid", LoadCommand.
cryptid);
347 IO.mapRequired(
"cryptoff", LoadCommand.
cryptoff);
348 IO.mapRequired(
"cryptsize", LoadCommand.
cryptsize);
349 IO.mapRequired(
"cryptid", LoadCommand.
cryptid);
350 IO.mapRequired(
"pad", LoadCommand.
pad);
355 IO.mapRequired(
"entryoff", LoadCommand.
entryoff);
356 IO.mapRequired(
"stacksize", LoadCommand.
stacksize);
361 IO.mapRequired(
"name", LoadCommand.
name);
362 IO.mapRequired(
"header_addr", LoadCommand.
header_addr);
366 IO.mapRequired(
"name", FVMLib.
name);
373 IO.mapRequired(
"fvmlib", LoadCommand.
fvmlib);
381 IO.mapRequired(
"dataoff", LoadCommand.
dataoff);
382 IO.mapRequired(
"datasize", LoadCommand.
datasize);
387 IO.mapRequired(
"count", LoadCommand.
count);
392 IO.mapRequired(
"cksum", LoadCommand.
cksum);
400 IO.mapRequired(
"name", LoadCommand.
name);
401 IO.mapRequired(
"nmodules", LoadCommand.
nmodules);
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);
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);
431 IO.mapRequired(
"path", LoadCommand.
path);
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);
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);
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);
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);
492 IO.mapRequired(
"version", LoadCommand.
version);
497 IO.mapRequired(
"client", LoadCommand.
client);
502 IO.mapRequired(
"umbrella", LoadCommand.
umbrella);
507 IO.mapRequired(
"sub_library", LoadCommand.
sub_library);
512 IO.mapRequired(
"sub_umbrella", LoadCommand.
sub_umbrella);
517 IO.mapRequired(
"offset", LoadCommand.
offset);
518 IO.mapRequired(
"size", LoadCommand.
size);
523 IO.mapRequired(
"symoff", LoadCommand.
symoff);
524 IO.mapRequired(
"nsyms", LoadCommand.
nsyms);
525 IO.mapRequired(
"stroff", LoadCommand.
stroff);
526 IO.mapRequired(
"strsize", LoadCommand.
strsize);
534 IO.mapRequired(
"offset", LoadCommand.
offset);
535 IO.mapRequired(
"nhints", LoadCommand.
nhints);
540 IO.mapRequired(
"uuid", LoadCommand.
uuid);
545 IO.mapRequired(
"version", LoadCommand.
version);
546 IO.mapRequired(
"sdk", LoadCommand.
sdk);
551 IO.mapRequired(
"data_owner", LoadCommand.
data_owner);
552 IO.mapRequired(
"offset", LoadCommand.
offset);
553 IO.mapRequired(
"size", LoadCommand.
size);
558 IO.mapRequired(
"platform", LoadCommand.
platform);
559 IO.mapRequired(
"minos", LoadCommand.
minos);
560 IO.mapRequired(
"sdk", LoadCommand.
sdk);
561 IO.mapRequired(
"ntools", LoadCommand.
ntools);
This class represents lattice values for constants.
std::vector< Object > Slices
std::vector< MachOYAML::ExportEntry > Children
std::vector< llvm::yaml::Hex8 > PayloadBytes
bool getAsUnsignedInteger(StringRef Str, unsigned Radix, unsigned long long &Result)
Helper functions for StringRef::getAsInteger.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
std::vector< int64_t > SLEBExtraData
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
raw_ostream & write_uuid(const uuid_t UUID)
std::vector< MachOYAML::RebaseOpcode > RebaseOpcodes
llvm::yaml::Hex32 cputype
static const bool IsLittleEndianHost
llvm::yaml::Hex32 cpusubtype
std::vector< yaml::Hex64 > ExtraData
std::vector< LoadCommand > LoadCommands
llvm::yaml::Hex64 Address
std::vector< MachOYAML::BindOpcode > WeakBindOpcodes
MachOYAML::ExportEntry ExportTrie
std::vector< yaml::Hex64 > ULEBExtraData
MachO::RebaseOpcode Opcode
std::vector< MachOYAML::BindOpcode > BindOpcodes
std::vector< FatArch > FatArchs
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
This file declares classes for handling the YAML representation of Mach-O.
llvm::yaml::Hex32 reserved3
std::vector< NListEntry > NameList
void mapLoadCommandData(IO &IO, MachOYAML::LoadCommand &LoadCommand)
llvm::yaml::Hex32 reserved2
This class implements an extremely fast bulk output stream that can only output to a stream...
std::vector< StringRef > StringTable
StringRef - Represent a constant reference to a string, i.e.
llvm::MachO::macho_load_command Data
llvm::yaml::Hex32 reserved
std::vector< MachOYAML::BindOpcode > LazyBindOpcodes
uint32_t compatibility_version
llvm::yaml::Hex32 reserved1
raw_ostream::uuid_t uuid_t