[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.

llvm-svn: 272183
This commit is contained in:
Reid Kleckner 2016-06-08 17:50:29 +00:00
parent 4009301768
commit 16fb1d2906
2 changed files with 18 additions and 0 deletions

View File

@ -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);

View File

@ -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: ]