38 auto Len =
strnlen(&Val[0], 16);
43 size_t CopySize = 16 >=
Scalar.size() ? 16 :
Scalar.size();
44 memcpy((
void *)Val,
Scalar.data(), CopySize);
47 memset((
void *)&Val[
Scalar.size()], 0, 16 -
Scalar.size());
63 for (
size_t Idx = 0; Idx <
Scalar.size(); ++Idx) {
64 if (
Scalar[Idx] ==
'-' || OutIdx >= 16)
66 unsigned long long TempInt;
68 return "invalid number";
70 return "out of range number";
71 Val[OutIdx] =
static_cast<uint8_t>(TempInt);
106 Object.DWARF.IsLittleEndian = Object.IsLittleEndian;
139 static_cast<llvm::yaml::Hex32
>(0));
216template <
typename StructType>
288 LoadCommand.
Data.load_command_data.cmd);
290 LoadCommand.
Data.load_command_data.cmd = TempCmd;
293#define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \
294 case MachO::LCName: \
295 MappingTraits<MachO::LCStruct>::mapping(IO, \
296 LoadCommand.Data.LCStruct##_data); \
297 mapLoadCommandData<MachO::LCStruct>(IO, LoadCommand); \
300 switch (LoadCommand.
Data.load_command_data.cmd) {
301#include "llvm/BinaryFormat/MachO.def"
356 if (!
IO.
error() && Section.content &&
357 Section.size < Section.content->binary_size())
358 return "Section size must be greater than or equal to the content size";
380void MappingTraits<MachO::dylinker_command>::mapping(
382 IO.mapRequired(
"name", LoadCommand.
name);
385void MappingTraits<MachO::dysymtab_command>::mapping(
386 IO &IO, MachO::dysymtab_command &LoadCommand) {
387 IO.mapRequired(
"ilocalsym", LoadCommand.ilocalsym);
388 IO.mapRequired(
"nlocalsym", LoadCommand.nlocalsym);
389 IO.mapRequired(
"iextdefsym", LoadCommand.iextdefsym);
390 IO.mapRequired(
"nextdefsym", LoadCommand.nextdefsym);
391 IO.mapRequired(
"iundefsym", LoadCommand.iundefsym);
392 IO.mapRequired(
"nundefsym", LoadCommand.nundefsym);
393 IO.mapRequired(
"tocoff", LoadCommand.tocoff);
394 IO.mapRequired(
"ntoc", LoadCommand.ntoc);
395 IO.mapRequired(
"modtaboff", LoadCommand.modtaboff);
396 IO.mapRequired(
"nmodtab", LoadCommand.nmodtab);
397 IO.mapRequired(
"extrefsymoff", LoadCommand.extrefsymoff);
398 IO.mapRequired(
"nextrefsyms", LoadCommand.nextrefsyms);
399 IO.mapRequired(
"indirectsymoff", LoadCommand.indirectsymoff);
400 IO.mapRequired(
"nindirectsyms", LoadCommand.nindirectsyms);
401 IO.mapRequired(
"extreloff", LoadCommand.extreloff);
402 IO.mapRequired(
"nextrel", LoadCommand.nextrel);
403 IO.mapRequired(
"locreloff", LoadCommand.locreloff);
404 IO.mapRequired(
"nlocrel", LoadCommand.nlocrel);
407void MappingTraits<MachO::encryption_info_command>::mapping(
408 IO &IO, MachO::encryption_info_command &LoadCommand) {
409 IO.mapRequired(
"cryptoff", LoadCommand.cryptoff);
410 IO.mapRequired(
"cryptsize", LoadCommand.cryptsize);
411 IO.mapRequired(
"cryptid", LoadCommand.cryptid);
414void MappingTraits<MachO::encryption_info_command_64>::mapping(
415 IO &IO, MachO::encryption_info_command_64 &LoadCommand) {
416 IO.mapRequired(
"cryptoff", LoadCommand.cryptoff);
417 IO.mapRequired(
"cryptsize", LoadCommand.cryptsize);
418 IO.mapRequired(
"cryptid", LoadCommand.cryptid);
419 IO.mapRequired(
"pad", LoadCommand.pad);
422void MappingTraits<MachO::entry_point_command>::mapping(
423 IO &IO, MachO::entry_point_command &LoadCommand) {
424 IO.mapRequired(
"entryoff", LoadCommand.entryoff);
425 IO.mapRequired(
"stacksize", LoadCommand.stacksize);
428void MappingTraits<MachO::fvmfile_command>::mapping(
429 IO &IO, MachO::fvmfile_command &LoadCommand) {
430 IO.mapRequired(
"name", LoadCommand.name);
431 IO.mapRequired(
"header_addr", LoadCommand.header_addr);
445void MappingTraits<MachO::ident_command>::mapping(
448void MappingTraits<MachO::linkedit_data_command>::mapping(
449 IO &IO, MachO::linkedit_data_command &LoadCommand) {
450 IO.mapRequired(
"dataoff", LoadCommand.dataoff);
451 IO.mapRequired(
"datasize", LoadCommand.datasize);
454void MappingTraits<MachO::linker_option_command>::mapping(
455 IO &IO, MachO::linker_option_command &LoadCommand) {
456 IO.mapRequired(
"count", LoadCommand.count);
459void MappingTraits<MachO::prebind_cksum_command>::mapping(
460 IO &IO, MachO::prebind_cksum_command &LoadCommand) {
461 IO.mapRequired(
"cksum", LoadCommand.cksum);
464void MappingTraits<MachO::load_command>::mapping(
465 IO &IO, MachO::load_command &LoadCommand) {}
467void MappingTraits<MachO::prebound_dylib_command>::mapping(
468 IO &IO, MachO::prebound_dylib_command &LoadCommand) {
469 IO.mapRequired(
"name", LoadCommand.name);
470 IO.mapRequired(
"nmodules", LoadCommand.nmodules);
471 IO.mapRequired(
"linked_modules", LoadCommand.linked_modules);
474void MappingTraits<MachO::routines_command>::mapping(
475 IO &IO, MachO::routines_command &LoadCommand) {
476 IO.mapRequired(
"init_address", LoadCommand.init_address);
477 IO.mapRequired(
"init_module", LoadCommand.init_module);
478 IO.mapRequired(
"reserved1", LoadCommand.reserved1);
479 IO.mapRequired(
"reserved2", LoadCommand.reserved2);
480 IO.mapRequired(
"reserved3", LoadCommand.reserved3);
481 IO.mapRequired(
"reserved4", LoadCommand.reserved4);
482 IO.mapRequired(
"reserved5", LoadCommand.reserved5);
483 IO.mapRequired(
"reserved6", LoadCommand.reserved6);
486void MappingTraits<MachO::routines_command_64>::mapping(
487 IO &IO, MachO::routines_command_64 &LoadCommand) {
488 IO.mapRequired(
"init_address", LoadCommand.init_address);
489 IO.mapRequired(
"init_module", LoadCommand.init_module);
490 IO.mapRequired(
"reserved1", LoadCommand.reserved1);
491 IO.mapRequired(
"reserved2", LoadCommand.reserved2);
492 IO.mapRequired(
"reserved3", LoadCommand.reserved3);
493 IO.mapRequired(
"reserved4", LoadCommand.reserved4);
494 IO.mapRequired(
"reserved5", LoadCommand.reserved5);
495 IO.mapRequired(
"reserved6", LoadCommand.reserved6);
498void MappingTraits<MachO::rpath_command>::mapping(
499 IO &IO, MachO::rpath_command &LoadCommand) {
500 IO.mapRequired(
"path", LoadCommand.path);
546void MappingTraits<MachO::segment_command_64>::mapping(
548 IO.mapRequired(
"segname", LoadCommand.
segname);
549 IO.mapRequired(
"vmaddr", LoadCommand.
vmaddr);
550 IO.mapRequired(
"vmsize", LoadCommand.
vmsize);
551 IO.mapRequired(
"fileoff", LoadCommand.
fileoff);
552 IO.mapRequired(
"filesize", LoadCommand.
filesize);
553 IO.mapRequired(
"maxprot", LoadCommand.
maxprot);
554 IO.mapRequired(
"initprot", LoadCommand.
initprot);
555 IO.mapRequired(
"nsects", LoadCommand.
nsects);
556 IO.mapRequired(
"flags", LoadCommand.
flags);
559void MappingTraits<MachO::source_version_command>::mapping(
560 IO &IO, MachO::source_version_command &LoadCommand) {
561 IO.mapRequired(
"version", LoadCommand.version);
564void MappingTraits<MachO::sub_client_command>::mapping(
565 IO &IO, MachO::sub_client_command &LoadCommand) {
566 IO.mapRequired(
"client", LoadCommand.client);
569void MappingTraits<MachO::sub_framework_command>::mapping(
570 IO &IO, MachO::sub_framework_command &LoadCommand) {
571 IO.mapRequired(
"umbrella", LoadCommand.umbrella);
574void MappingTraits<MachO::sub_library_command>::mapping(
575 IO &IO, MachO::sub_library_command &LoadCommand) {
576 IO.mapRequired(
"sub_library", LoadCommand.sub_library);
579void MappingTraits<MachO::sub_umbrella_command>::mapping(
580 IO &IO, MachO::sub_umbrella_command &LoadCommand) {
581 IO.mapRequired(
"sub_umbrella", LoadCommand.sub_umbrella);
584void MappingTraits<MachO::symseg_command>::mapping(
585 IO &IO, MachO::symseg_command &LoadCommand) {
586 IO.mapRequired(
"offset", LoadCommand.offset);
587 IO.mapRequired(
"size", LoadCommand.size);
590void MappingTraits<MachO::symtab_command>::mapping(
591 IO &IO, MachO::symtab_command &LoadCommand) {
592 IO.mapRequired(
"symoff", LoadCommand.symoff);
593 IO.mapRequired(
"nsyms", LoadCommand.nsyms);
594 IO.mapRequired(
"stroff", LoadCommand.stroff);
595 IO.mapRequired(
"strsize", LoadCommand.strsize);
598void MappingTraits<MachO::thread_command>::mapping(
599 IO &IO, MachO::thread_command &LoadCommand) {}
601void MappingTraits<MachO::twolevel_hints_command>::mapping(
602 IO &IO, MachO::twolevel_hints_command &LoadCommand) {
603 IO.mapRequired(
"offset", LoadCommand.offset);
604 IO.mapRequired(
"nhints", LoadCommand.nhints);
607void MappingTraits<MachO::uuid_command>::mapping(
608 IO &IO, MachO::uuid_command &LoadCommand) {
609 IO.mapRequired(
"uuid", LoadCommand.uuid);
612void MappingTraits<MachO::version_min_command>::mapping(
613 IO &IO, MachO::version_min_command &LoadCommand) {
614 IO.mapRequired(
"version", LoadCommand.version);
615 IO.mapRequired(
"sdk", LoadCommand.sdk);
618void MappingTraits<MachO::note_command>::mapping(
619 IO &IO, MachO::note_command &LoadCommand) {
620 IO.mapRequired(
"data_owner", LoadCommand.data_owner);
621 IO.mapRequired(
"offset", LoadCommand.offset);
622 IO.mapRequired(
"size", LoadCommand.size);
625void MappingTraits<MachO::build_version_command>::mapping(
626 IO &IO, MachO::build_version_command &LoadCommand) {
627 IO.mapRequired(
"platform", LoadCommand.platform);
628 IO.mapRequired(
"minos", LoadCommand.minos);
629 IO.mapRequired(
"sdk", LoadCommand.sdk);
630 IO.mapRequired(
"ntools", LoadCommand.ntools);
633void MappingTraits<MachO::target_triple_command>::mapping(
634 IO &IO, MachO::target_triple_command &LoadCommand) {
635 IO.mapRequired(
"triple", LoadCommand.triple);
638void MappingTraits<MachO::fileset_entry_command>::mapping(
639 IO &IO, MachO::fileset_entry_command &LoadCommand) {
640 IO.mapRequired(
"vmaddr", LoadCommand.vmaddr);
641 IO.mapRequired(
"fileoff", LoadCommand.fileoff);
642 IO.mapRequired(
"id", LoadCommand.entry_id.offset);
643 IO.mapOptional(
"reserved", LoadCommand.reserved);
This file declares classes for handling the YAML representation of Mach-O.
Represent a constant reference to a string, i.e.
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & write_uuid(const uuid_t UUID)
virtual bool outputting() const =0
virtual bool mapTag(StringRef Tag, bool Default=false)=0
virtual std::error_code error()=0
void mapOptional(StringRef Key, T &Val)
void * getContext() const
void mapRequired(StringRef Key, T &Val)
constexpr bool IsLittleEndianHost
raw_ostream::uuid_t uuid_t
QuotingType
Describe which type of quotes should be used when quoting is necessary.
void mapLoadCommandData(IO &IO, MachOYAML::LoadCommand &LoadCommand)
QuotingType needsQuotes(StringRef S, bool ForcePreserveAsString=true)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI bool getAsUnsignedInteger(StringRef Str, unsigned Radix, unsigned long long &Result)
Helper functions for StringRef::getAsInteger.
size_t strnlen(const char *S, size_t MaxLen) asm("llvm_zos_strnlen")
std::vector< MachOYAML::ExportEntry > Children
llvm::yaml::Hex64 Address
llvm::yaml::Hex32 cputype
llvm::yaml::Hex32 cpusubtype
llvm::yaml::Hex32 reserved
std::vector< MachOYAML::BindOpcode > WeakBindOpcodes
std::vector< DataInCodeEntry > DataInCode
std::vector< yaml::Hex8 > ChainedFixups
std::vector< MachOYAML::BindOpcode > LazyBindOpcodes
std::vector< MachOYAML::BindOpcode > BindOpcodes
std::vector< MachOYAML::RebaseOpcode > RebaseOpcodes
std::vector< StringRef > StringTable
std::vector< yaml::Hex32 > IndirectSymbols
LLVM_ABI bool isEmpty() const
std::vector< yaml::Hex64 > FunctionStarts
MachOYAML::ExportEntry ExportTrie
std::vector< NListEntry > NameList
llvm::MachO::macho_load_command Data
std::vector< Section > Sections
std::vector< MachO::build_tool_version > Tools
std::vector< llvm::yaml::Hex8 > PayloadBytes
llvm::yaml::Hex32 address
std::vector< Object > Slices
std::vector< FatArch > FatArchs
uint32_t compatibility_version
This class should be specialized by any type that needs to be converted to/from a YAML mapping.
This class should be specialized by type that requires custom conversion to/from a yaml scalar.