Skip to content

Commit 1f95610

Browse files
trutstellar
authored andcommitted
[LLD][COFF] Ignore DEBUG_S_XFGHASH_TYPE/VIRTUAL
These are new debug types that ships with the latest Windows SDK and would warn and finally fail lld-link. The symbols seems to be related to Microsoft's XFG which is their version of CFG. We can't handle any of this yet, so for now we can just ignore these types so that lld doesn't fail with a new version of Windows SDK. Fixes: #56285 Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D129378 (cherry picked from commit 576375a)
1 parent 9c68b43 commit 1f95610

File tree

5 files changed

+63
-2
lines changed

5 files changed

+63
-2
lines changed

lld/COFF/PDB.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,10 @@ void DebugSHandler::handleDebugS(SectionChunk *debugChunk) {
811811
// Unclear what this is for.
812812
break;
813813

814+
case DebugSubsectionKind::XfgHashType:
815+
case DebugSubsectionKind::XfgHashVirtual:
816+
break;
817+
814818
default:
815819
warn("ignoring unknown debug$S subsection kind 0x" +
816820
utohexstr(uint32_t(ss.kind())) + " in file " + toString(&file));

lld/test/COFF/pdb-unknown-subsection.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck %s
88

99
# WARNING-NOT: ignoring unknown
10-
# WARNING: ignoring unknown debug$S subsection kind 0xFF
10+
# WARNING: ignoring unknown debug$S subsection kind 0x1FF
1111
# WARNING-NOT: ignoring unknown
1212

1313
# CHECK: Symbols
@@ -43,7 +43,7 @@ ret
4343
.p2align 2
4444
.Ltmp8:
4545
.Ltmp6:
46-
.long 0xFF # Unknown subsection kind
46+
.long 0x1FF # Unknown subsection kind
4747
.long 4 # Subsection size
4848
.long 0
4949
.long 0x800000F1 # Unknown subsection kind

lld/test/COFF/pdb-xfg-section.s

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Check that we ignore XFG subsections in CodeView information.
2+
// This test should be removed if we ever end up adding XFG support to lld.
3+
4+
# REQUIRES: x86
5+
# RUN: llvm-mc -triple=i386-pc-win32 -filetype=obj -o %t.obj %s
6+
# RUN: lld-link -verbose -safeseh:no -subsystem:console -debug -nodefaultlib -entry:foo -out:%t.exe -pdb:%t.pdb %t.obj 2>&1 | FileCheck %s
7+
8+
// XFGHashType should not generate a warning
9+
# CHECK-NOT: ignoring unknown debug$S subsection kind 0xFF
10+
// XFGHashVirtual should not generate a warning
11+
# CHECK-NOT: ignoring unknown debug$S subsection kind 0x100
12+
13+
.text
14+
_foo:
15+
ret
16+
17+
.global _foo
18+
19+
.section .debug$S,"dr"
20+
.p2align 2
21+
.long 4 # Debug section magic
22+
.long 0xF1 # Symbol subsection
23+
.long .Ltmp6-.Ltmp5 # Subsection size
24+
.Ltmp5:
25+
.short .Ltmp8-.Ltmp7 # Record length
26+
.Ltmp7:
27+
.short 4412 # Record kind: S_COMPILE3
28+
.long 0 # Flags and language
29+
.short 208 # CPUType
30+
.short 9 # Frontend version
31+
.short 0
32+
.short 0
33+
.short 0
34+
.short 9000 # Backend version
35+
.short 0
36+
.short 0
37+
.short 0
38+
.asciz "clang version SENTINEL" # Null-terminated compiler version string
39+
.p2align 2
40+
.Ltmp8:
41+
.Ltmp6:
42+
.long 0xFF # XFGHashType subsection
43+
.long 4 # Subsection size
44+
.long 0
45+
.long 0x100 # XFGHashVirtual subsection
46+
.long 4 # Subsection size
47+
.long 0

llvm/include/llvm/DebugInfo/CodeView/CodeView.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,9 @@ enum class DebugSubsectionKind : uint32_t {
330330
MergedAssemblyInput = 0xfc,
331331

332332
CoffSymbolRVA = 0xfd,
333+
334+
XfgHashType = 0xff,
335+
XfgHashVirtual = 0x100,
333336
};
334337

335338
/// Equivalent to CV_ptrtype_e.

llvm/lib/DebugInfo/PDB/Native/FormatUtil.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ std::string llvm::pdb::formatChunkKind(DebugSubsectionKind Kind,
6666
RETURN_CASE(DebugSubsectionKind, MergedAssemblyInput,
6767
"merged assembly input");
6868
RETURN_CASE(DebugSubsectionKind, CoffSymbolRVA, "coff symbol rva");
69+
RETURN_CASE(DebugSubsectionKind, XfgHashType, "xfg hash type");
70+
RETURN_CASE(DebugSubsectionKind, XfgHashVirtual, "xfg hash virtual");
6971
}
7072
} else {
7173
switch (Kind) {
@@ -89,6 +91,11 @@ std::string llvm::pdb::formatChunkKind(DebugSubsectionKind Kind,
8991
"DEBUG_S_MERGED_ASSEMBLYINPUT");
9092
RETURN_CASE(DebugSubsectionKind, CoffSymbolRVA,
9193
"DEBUG_S_COFF_SYMBOL_RVA");
94+
RETURN_CASE(DebugSubsectionKind, XfgHashType,
95+
"DEBUG_S_XFGHASH_TYPE");
96+
RETURN_CASE(DebugSubsectionKind, XfgHashVirtual,
97+
"DEBUG_S_XFGHASH_VIRTUAL");
98+
9299
}
93100
}
94101
return formatUnknownEnum(Kind);

0 commit comments

Comments
 (0)