[llvm-branch-commits] [llvm] 1f95610 - [LLD][COFF] Ignore DEBUG_S_XFGHASH_TYPE/VIRTUAL

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Aug 8 13:23:42 PDT 2022


Author: Tobias Hieta
Date: 2022-08-08T13:23:11-07:00
New Revision: 1f9561096d893fe68c818e555e0590405e375978

URL: https://github.com/llvm/llvm-project/commit/1f9561096d893fe68c818e555e0590405e375978
DIFF: https://github.com/llvm/llvm-project/commit/1f9561096d893fe68c818e555e0590405e375978.diff

LOG: [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 576375a2d670a7b1bd84b53b0187605a5f4ea0c8)

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

Modified: 
    lld/COFF/PDB.cpp
    lld/test/COFF/pdb-unknown-subsection.s
    llvm/include/llvm/DebugInfo/CodeView/CodeView.h
    llvm/lib/DebugInfo/PDB/Native/FormatUtil.cpp

Removed: 
    


################################################################################
diff  --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp
index 87b6bb55d6101..2da63ab4e59a9 100644
--- a/lld/COFF/PDB.cpp
+++ b/lld/COFF/PDB.cpp
@@ -811,6 +811,10 @@ void DebugSHandler::handleDebugS(SectionChunk *debugChunk) {
       // Unclear what this is for.
       break;
 
+    case DebugSubsectionKind::XfgHashType:
+    case DebugSubsectionKind::XfgHashVirtual:
+      break;
+
     default:
       warn("ignoring unknown debug$S subsection kind 0x" +
            utohexstr(uint32_t(ss.kind())) + " in file " + toString(&file));

diff  --git a/lld/test/COFF/pdb-unknown-subsection.s b/lld/test/COFF/pdb-unknown-subsection.s
index 10ffa46ded3f6..a1f369c958443 100644
--- a/lld/test/COFF/pdb-unknown-subsection.s
+++ b/lld/test/COFF/pdb-unknown-subsection.s
@@ -7,7 +7,7 @@
 # RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck %s
 
 # WARNING-NOT: ignoring unknown
-# WARNING: ignoring unknown debug$S subsection kind 0xFF
+# WARNING: ignoring unknown debug$S subsection kind 0x1FF
 # WARNING-NOT: ignoring unknown
 
 # CHECK:                           Symbols
@@ -43,7 +43,7 @@ ret
 	.p2align	2
 .Ltmp8:
 .Ltmp6:
-	.long	0xFF # Unknown subsection kind
+	.long	0x1FF # Unknown subsection kind
 	.long	4           # Subsection size
 	.long  0
 	.long	0x800000F1 # Unknown subsection kind

diff  --git a/lld/test/COFF/pdb-xfg-section.s b/lld/test/COFF/pdb-xfg-section.s
new file mode 100644
index 0000000000000..5983de55b20b3
--- /dev/null
+++ b/lld/test/COFF/pdb-xfg-section.s
@@ -0,0 +1,47 @@
+// Check that we ignore XFG subsections in CodeView information.
+// This test should be removed if we ever end up adding XFG support to lld.
+
+# REQUIRES: x86
+# RUN: llvm-mc -triple=i386-pc-win32 -filetype=obj -o %t.obj %s
+# RUN: lld-link -verbose -safeseh:no -subsystem:console -debug -nodefaultlib -entry:foo -out:%t.exe -pdb:%t.pdb %t.obj 2>&1 | FileCheck %s
+
+// XFGHashType should not generate a warning
+# CHECK-NOT: ignoring unknown debug$S subsection kind 0xFF
+// XFGHashVirtual should not generate a warning
+# CHECK-NOT: ignoring unknown debug$S subsection kind 0x100
+
+.text
+_foo:
+ret
+
+.global _foo
+
+.section .debug$S,"dr"
+	.p2align	2
+	.long	4                       # Debug section magic
+	.long	0xF1 # Symbol subsection
+	.long	.Ltmp6-.Ltmp5           # Subsection size
+.Ltmp5:
+	.short	.Ltmp8-.Ltmp7           # Record length
+.Ltmp7:
+	.short	4412                    # Record kind: S_COMPILE3
+	.long	0                       # Flags and language
+	.short	208                     # CPUType
+	.short	9                       # Frontend version
+	.short	0
+	.short	0
+	.short	0
+	.short	9000                    # Backend version
+	.short	0
+	.short	0
+	.short	0
+	.asciz	"clang version SENTINEL" # Null-terminated compiler version string
+	.p2align	2
+.Ltmp8:
+.Ltmp6:
+	.long	0xFF # XFGHashType subsection
+	.long	4           # Subsection size
+	.long  0
+	.long	0x100 # XFGHashVirtual subsection
+	.long	4           # Subsection size
+	.long  0

diff  --git a/llvm/include/llvm/DebugInfo/CodeView/CodeView.h b/llvm/include/llvm/DebugInfo/CodeView/CodeView.h
index d4cb6ae7a28ee..b7a3e1561a079 100644
--- a/llvm/include/llvm/DebugInfo/CodeView/CodeView.h
+++ b/llvm/include/llvm/DebugInfo/CodeView/CodeView.h
@@ -330,6 +330,9 @@ enum class DebugSubsectionKind : uint32_t {
   MergedAssemblyInput = 0xfc,
 
   CoffSymbolRVA = 0xfd,
+
+  XfgHashType = 0xff,
+  XfgHashVirtual = 0x100,
 };
 
 /// Equivalent to CV_ptrtype_e.

diff  --git a/llvm/lib/DebugInfo/PDB/Native/FormatUtil.cpp b/llvm/lib/DebugInfo/PDB/Native/FormatUtil.cpp
index a167d45982a90..9c05d585831a9 100644
--- a/llvm/lib/DebugInfo/PDB/Native/FormatUtil.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/FormatUtil.cpp
@@ -66,6 +66,8 @@ std::string llvm::pdb::formatChunkKind(DebugSubsectionKind Kind,
       RETURN_CASE(DebugSubsectionKind, MergedAssemblyInput,
                   "merged assembly input");
       RETURN_CASE(DebugSubsectionKind, CoffSymbolRVA, "coff symbol rva");
+      RETURN_CASE(DebugSubsectionKind, XfgHashType, "xfg hash type");
+      RETURN_CASE(DebugSubsectionKind, XfgHashVirtual, "xfg hash virtual");
     }
   } else {
     switch (Kind) {
@@ -89,6 +91,11 @@ std::string llvm::pdb::formatChunkKind(DebugSubsectionKind Kind,
                   "DEBUG_S_MERGED_ASSEMBLYINPUT");
       RETURN_CASE(DebugSubsectionKind, CoffSymbolRVA,
                   "DEBUG_S_COFF_SYMBOL_RVA");
+      RETURN_CASE(DebugSubsectionKind, XfgHashType,
+                  "DEBUG_S_XFGHASH_TYPE");
+      RETURN_CASE(DebugSubsectionKind, XfgHashVirtual,
+                  "DEBUG_S_XFGHASH_VIRTUAL");
+
     }
   }
   return formatUnknownEnum(Kind);


        


More information about the llvm-branch-commits mailing list