Index: llvm/lib/DebugInfo/MSF/MSFBuilder.cpp =================================================================== --- llvm/lib/DebugInfo/MSF/MSFBuilder.cpp +++ llvm/lib/DebugInfo/MSF/MSFBuilder.cpp @@ -341,7 +341,17 @@ Layout = std::move(*L); - uint64_t FileSize = Layout.SB->BlockSize * Layout.SB->NumBlocks; + 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. + return make_error(msf_error_code::invalid_format, + "Output larger than 4 GiB"); + } + auto OutFileOrError = FileOutputBuffer::create(Path, FileSize); if (auto EC = OutFileOrError.takeError()) return std::move(EC);