[PDB] Ignore .debug$S subsections with high bit set
Some versions of the Visual C++ 2015 runtime have line tables with the
subsection kind of 0x800000F2. In cvinfo.h, 0x80000000 is documented to
be DEBUG_S_IGNORE. This appears to implement the intended behavior.
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@363724 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/COFF/PDB.cpp b/COFF/PDB.cpp
index 8d42f78..6d3bf64 100644
--- a/COFF/PDB.cpp
+++ b/COFF/PDB.cpp
@@ -1002,6 +1002,11 @@
ExitOnErr(Reader.readArray(Subsections, RelocatedDebugContents.size()));
for (const DebugSubsectionRecord &SS : Subsections) {
+ // Ignore subsections with the 'ignore' bit. Some versions of the Visual C++
+ // runtime have subsections with this bit set.
+ if (uint32_t(SS.kind()) & codeview::SubsectionIgnoreFlag)
+ continue;
+
switch (SS.kind()) {
case DebugSubsectionKind::StringTable: {
assert(!CVStrTab.valid() &&
diff --git a/test/COFF/pdb-unknown-subsection.s b/test/COFF/pdb-unknown-subsection.s
index 669f51e..b64ed03 100644
--- a/test/COFF/pdb-unknown-subsection.s
+++ b/test/COFF/pdb-unknown-subsection.s
@@ -6,7 +6,9 @@
# RUN: lld-link -subsystem:console -debug -nodefaultlib -entry:foo -out:%t.exe -pdb:%t.pdb %t.obj 2>&1 | FileCheck %s --check-prefix=WARNING
# RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck %s
+# WARNING-NOT: ignoring unknown
# WARNING: ignoring unknown debug$S subsection kind 0xFF
+# WARNING-NOT: ignoring unknown
# CHECK: Symbols
# CHECK: 4 | S_COMPILE3 [size = 52]
@@ -44,3 +46,15 @@
.long 0xFF # Unknown subsection kind
.long 4 # Subsection size
.long 0
+ .long 0x800000F1 # Unknown subsection kind
+ .long 4 # Subsection size
+ .long 0
+ .long 0x800000F2 # Unknown subsection kind
+ .long 4 # Subsection size
+ .long 0
+ .long 0x800000F3 # Unknown subsection kind
+ .long 4 # Subsection size
+ .long 0
+ .long 0x800000F4 # Unknown subsection kind
+ .long 4 # Subsection size
+ .long 0