summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/MC/MCCodeView.cpp5
-rw-r--r--llvm/test/MC/COFF/cv-empty-file-table.s13
2 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCCodeView.cpp b/llvm/lib/MC/MCCodeView.cpp
index 8ae0187237a..2d8ef442f75 100644
--- a/llvm/lib/MC/MCCodeView.cpp
+++ b/llvm/lib/MC/MCCodeView.cpp
@@ -118,6 +118,11 @@ void CodeViewContext::emitStringTable(MCObjectStreamer &OS) {
}
void CodeViewContext::emitFileChecksums(MCObjectStreamer &OS) {
+ // Do nothing if there are no file checksums. Microsoft's linker rejects empty
+ // CodeView substreams.
+ if (Filenames.empty())
+ return;
+
MCContext &Ctx = OS.getContext();
MCSymbol *FileBegin = Ctx.createTempSymbol("filechecksums_begin", false),
*FileEnd = Ctx.createTempSymbol("filechecksums_end", false);
diff --git a/llvm/test/MC/COFF/cv-empty-file-table.s b/llvm/test/MC/COFF/cv-empty-file-table.s
new file mode 100644
index 00000000000..157cd3167d2
--- /dev/null
+++ b/llvm/test/MC/COFF/cv-empty-file-table.s
@@ -0,0 +1,13 @@
+# RUN: llvm-mc -filetype=obj -triple i686-pc-win32 < %s | llvm-readobj -codeview - | FileCheck %s
+ .text
+ .section .debug$S,"dr"
+ .p2align 2
+ .long 4 # Debug section magic
+ .cv_filechecksums # File index to string table offset subsection
+ .cv_stringtable # String table
+
+# CHECK: CodeViewDebugInfo [
+# CHECK: Section: .debug$S (4)
+# CHECK: Magic: 0x4
+# CHECK-NOT: FileChecksum
+# CHECK: ]
OpenPOWER on IntegriCloud