Skip to content

Commit f931f17

Browse files
authored
Merge pull request #7218 from hjyamauchi/lldb
[lldb][PECOFF] Exclude alignment padding when reading section data
2 parents 0341a67 + 5a5430e commit f931f17

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

llvm/lib/ObjectYAML/COFFYAML.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -599,11 +599,12 @@ void MappingTraits<COFFYAML::Section>::mapping(IO &IO, COFFYAML::Section &Sec) {
599599
return;
600600
}
601601

602-
// Uninitialized sections, such as .bss, typically have no data, but the size
603-
// is carried in SizeOfRawData, even though PointerToRawData is zero.
604-
if (Sec.SectionData.binary_size() == 0 && Sec.StructuredData.empty() &&
605-
NC->Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA)
606-
IO.mapOptional("SizeOfRawData", Sec.Header.SizeOfRawData);
602+
IO.mapOptional("SizeOfRawData", Sec.Header.SizeOfRawData, 0U);
603+
604+
if (!Sec.StructuredData.empty() && Sec.Header.SizeOfRawData) {
605+
IO.setError("StructuredData and SizeOfRawData can't be used together");
606+
return;
607+
}
607608

608609
IO.mapOptional("Relocations", Sec.Relocations);
609610
}

llvm/test/tools/yaml2obj/COFF/invalid-raw-data.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# RUN: not yaml2obj %s -o %t 2>&1 | FileCheck %s
2-
# CHECK: YAML:18:5: error: unknown key 'SizeOfRawData'
2+
# CHECK: YAML:14:5: error: StructuredData and SizeOfRawData can't be used together
33

44
--- !COFF
55
OptionalHeader:

0 commit comments

Comments
 (0)