[llvm] d9e2c8f - [yaml2obj][COFF] Make some PEHeader fields optional
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 6 16:40:05 PDT 2021
Author: Fangrui Song
Date: 2021-11-06T16:39:59-07:00
New Revision: d9e2c8f54ddefa89e5599f0a011f946cab1a8534
URL: https://github.com/llvm/llvm-project/commit/d9e2c8f54ddefa89e5599f0a011f946cab1a8534
DIFF: https://github.com/llvm/llvm-project/commit/d9e2c8f54ddefa89e5599f0a011f946cab1a8534.diff
LOG: [yaml2obj][COFF] Make some PEHeader fields optional
This makes it easy to write tests where the irrelevant fields are not needed.
Added:
Modified:
llvm/lib/ObjectYAML/COFFYAML.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ObjectYAML/COFFYAML.cpp b/llvm/lib/ObjectYAML/COFFYAML.cpp
index 5a85e22e4f49c..6e5cdce89060f 100644
--- a/llvm/lib/ObjectYAML/COFFYAML.cpp
+++ b/llvm/lib/ObjectYAML/COFFYAML.cpp
@@ -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);
More information about the llvm-commits
mailing list