[yaml2obj][COFF] Make some PEHeader fields optional

This makes it easy to write tests where the irrelevant fields are not needed.
This commit is contained in:
Fangrui Song 2021-11-06 16:39:59 -07:00
parent 2249ecee8d
commit d9e2c8f54d
1 changed files with 16 additions and 16 deletions

View File

@ -448,24 +448,24 @@ void MappingTraits<COFFYAML::PEHeader>::mapping(IO &IO,
MappingNormalization<NDLLCharacteristics, uint16_t> NDC(
IO, PH.Header.DLLCharacteristics);
IO.mapRequired("AddressOfEntryPoint", PH.Header.AddressOfEntryPoint);
IO.mapRequired("ImageBase", PH.Header.ImageBase);
IO.mapRequired("SectionAlignment", PH.Header.SectionAlignment);
IO.mapRequired("FileAlignment", PH.Header.FileAlignment);
IO.mapRequired("MajorOperatingSystemVersion",
IO.mapOptional("AddressOfEntryPoint", PH.Header.AddressOfEntryPoint);
IO.mapOptional("ImageBase", PH.Header.ImageBase);
IO.mapOptional("SectionAlignment", PH.Header.SectionAlignment, 1);
IO.mapOptional("FileAlignment", PH.Header.FileAlignment, 1);
IO.mapOptional("MajorOperatingSystemVersion",
PH.Header.MajorOperatingSystemVersion);
IO.mapRequired("MinorOperatingSystemVersion",
IO.mapOptional("MinorOperatingSystemVersion",
PH.Header.MinorOperatingSystemVersion);
IO.mapRequired("MajorImageVersion", PH.Header.MajorImageVersion);
IO.mapRequired("MinorImageVersion", PH.Header.MinorImageVersion);
IO.mapRequired("MajorSubsystemVersion", PH.Header.MajorSubsystemVersion);
IO.mapRequired("MinorSubsystemVersion", PH.Header.MinorSubsystemVersion);
IO.mapRequired("Subsystem", NWS->Subsystem);
IO.mapRequired("DLLCharacteristics", NDC->Characteristics);
IO.mapRequired("SizeOfStackReserve", PH.Header.SizeOfStackReserve);
IO.mapRequired("SizeOfStackCommit", PH.Header.SizeOfStackCommit);
IO.mapRequired("SizeOfHeapReserve", PH.Header.SizeOfHeapReserve);
IO.mapRequired("SizeOfHeapCommit", PH.Header.SizeOfHeapCommit);
IO.mapOptional("MajorImageVersion", PH.Header.MajorImageVersion);
IO.mapOptional("MinorImageVersion", PH.Header.MinorImageVersion);
IO.mapOptional("MajorSubsystemVersion", PH.Header.MajorSubsystemVersion);
IO.mapOptional("MinorSubsystemVersion", PH.Header.MinorSubsystemVersion);
IO.mapOptional("Subsystem", NWS->Subsystem);
IO.mapOptional("DLLCharacteristics", NDC->Characteristics);
IO.mapOptional("SizeOfStackReserve", PH.Header.SizeOfStackReserve);
IO.mapOptional("SizeOfStackCommit", PH.Header.SizeOfStackCommit);
IO.mapOptional("SizeOfHeapReserve", PH.Header.SizeOfHeapReserve);
IO.mapOptional("SizeOfHeapCommit", PH.Header.SizeOfHeapCommit);
IO.mapOptional("NumberOfRvaAndSize", PH.Header.NumberOfRvaAndSize,
COFF::NUM_DATA_DIRECTORIES + 1);