diff options
author | Reid Kleckner <rnk@google.com> | 2016-06-08 17:50:29 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2016-06-08 17:50:29 +0000 |
commit | ee641c20cabc59d2d5e212226b9f052f5d0c6187 (patch) | |
tree | 037b24081fa2d58cf27e15bc5869a636a7a09e70 | |
parent | 2401c984756c25ec811bd6bbc3f4ad4f2a8e6cf6 (diff) | |
download | bcm5719-llvm-ee641c20cabc59d2d5e212226b9f052f5d0c6187.tar.gz bcm5719-llvm-ee641c20cabc59d2d5e212226b9f052f5d0c6187.zip |
[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
-rw-r--r-- | llvm/lib/MC/MCCodeView.cpp | 5 | ||||
-rw-r--r-- | llvm/test/MC/COFF/cv-empty-file-table.s | 13 |
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: ] |