Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit d3fa840

Browse files
committed
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272183 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 8999baf commit d3fa840

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/MC/MCCodeView.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ void CodeViewContext::emitStringTable(MCObjectStreamer &OS) {
118118
}
119119

120120
void CodeViewContext::emitFileChecksums(MCObjectStreamer &OS) {
121+
// Do nothing if there are no file checksums. Microsoft's linker rejects empty
122+
// CodeView substreams.
123+
if (Filenames.empty())
124+
return;
125+
121126
MCContext &Ctx = OS.getContext();
122127
MCSymbol *FileBegin = Ctx.createTempSymbol("filechecksums_begin", false),
123128
*FileEnd = Ctx.createTempSymbol("filechecksums_end", false);

test/MC/COFF/cv-empty-file-table.s

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# RUN: llvm-mc -filetype=obj -triple i686-pc-win32 < %s | llvm-readobj -codeview - | FileCheck %s
2+
.text
3+
.section .debug$S,"dr"
4+
.p2align 2
5+
.long 4 # Debug section magic
6+
.cv_filechecksums # File index to string table offset subsection
7+
.cv_stringtable # String table
8+
9+
# CHECK: CodeViewDebugInfo [
10+
# CHECK: Section: .debug$S (4)
11+
# CHECK: Magic: 0x4
12+
# CHECK-NOT: FileChecksum
13+
# CHECK: ]

0 commit comments

Comments
 (0)