diff options
Diffstat (limited to 'llvm/lib/DebugInfo/MSF/MSFBuilder.cpp')
| -rw-r--r-- | llvm/lib/DebugInfo/MSF/MSFBuilder.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp b/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp index 1a92e2cb7754..f9a763d724a8 100644 --- a/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp +++ b/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp @@ -343,15 +343,25 @@ Expected<FileBufferByteStream> MSFBuilder::commit(StringRef Path, Layout = std::move(*L); uint64_t FileSize = uint64_t(Layout.SB->BlockSize) * Layout.SB->NumBlocks; - if (FileSize > UINT32_MAX) { - // FIXME: Changing the BinaryStream classes to use 64-bit numbers lets - // us create PDBs larger than 4 GiB successfully. The file format is - // block-based and as long as each stream is small enough, PDBs larger than - // 4 GiB might work. Check if tools can handle these large PDBs, and if so - // add support for writing them. + // Ensure that the file size is under the limit for the specified block size. + if (FileSize > getMaxFileSizeFromBlockSize(Layout.SB->BlockSize)) { + msf_error_code error_code = [](uint32_t BlockSize) { + switch (BlockSize) { + case 8192: + return msf_error_code::size_overflow_8192; + case 16384: + return msf_error_code::size_overflow_16384; + case 32768: + return msf_error_code::size_overflow_32768; + default: + return msf_error_code::size_overflow_4096; + } + }(Layout.SB->BlockSize); + return make_error<MSFError>( - msf_error_code::size_overflow, - formatv("File size would have been {0,1:N}", FileSize)); + error_code, + formatv("File size {0,1:N} too large for current PDB page size {1}", + FileSize, Layout.SB->BlockSize)); } auto OutFileOrError = FileOutputBuffer::create(Path, FileSize); |
