[llvm] r272183 - [codeview] Avoid emitting an empty file checksum table

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 8 10:50:29 PDT 2016


Author: rnk
Date: Wed Jun  8 12:50:29 2016
New Revision: 272183

URL: http://llvm.org/viewvc/llvm-project?rev=272183&view=rev
Log:
[codeview] Avoid emitting an empty file checksum table

Again, the Microsoft linker does not like empty substreams.

We still emit an empty string table if CodeView is enabled, but that
doesn't cause problems because it always contains at least one null
byte.

Added:
    llvm/trunk/test/MC/COFF/cv-empty-file-table.s
Modified:
    llvm/trunk/lib/MC/MCCodeView.cpp

Modified: llvm/trunk/lib/MC/MCCodeView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCCodeView.cpp?rev=272183&r1=272182&r2=272183&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCCodeView.cpp (original)
+++ llvm/trunk/lib/MC/MCCodeView.cpp Wed Jun  8 12:50:29 2016
@@ -118,6 +118,11 @@ void CodeViewContext::emitStringTable(MC
 }
 
 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);

Added: llvm/trunk/test/MC/COFF/cv-empty-file-table.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/cv-empty-file-table.s?rev=272183&view=auto
==============================================================================
--- llvm/trunk/test/MC/COFF/cv-empty-file-table.s (added)
+++ llvm/trunk/test/MC/COFF/cv-empty-file-table.s Wed Jun  8 12:50:29 2016
@@ -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: ]




More information about the llvm-commits mailing list