Index: lld/COFF/DriverUtils.cpp =================================================================== --- lld/COFF/DriverUtils.cpp +++ lld/COFF/DriverUtils.cpp @@ -186,12 +186,6 @@ return; } - // FIXME: Remove this once other page sizes work. - if (v != 4096) { - warn("/pdbpagesize: page sizes != 4096 not yet implemented, ignoring flag"); - v = 4096; - } - config->pdbPageSize = v; } Index: lld/test/COFF/pdbpagesize.test =================================================================== --- lld/test/COFF/pdbpagesize.test +++ lld/test/COFF/pdbpagesize.test @@ -10,6 +10,14 @@ # RUN: llvm-pdbutil pdb2yaml %t.pdb | FileCheck --check-prefix=PAGE4096 %s # PAGE4096: BlockSize: 4096 -# RUN: lld-link /entry:main %t.obj /out:%t.exe /debug /pdbpagesize:8192 2>&1 \ -# RUN: | FileCheck --check-prefix=TODO %s -# TODO: warning: /pdbpagesize: page sizes != 4096 not yet implemented, ignoring flag +# RUN: lld-link /entry:main %t.obj /out:%t.exe /debug /pdbpagesize:8192 +# RUN: llvm-pdbutil pdb2yaml %t.pdb | FileCheck --check-prefix=PAGE8192 %s +# PAGE4096: BlockSize: 8192 + +# RUN: lld-link /entry:main %t.obj /out:%t.exe /debug /pdbpagesize:16384 +# RUN: llvm-pdbutil pdb2yaml %t.pdb | FileCheck --check-prefix=PAGE16384 %s +# PAGE4096: BlockSize: 16384 + +# RUN: lld-link /entry:main %t.obj /out:%t.exe /debug /pdbpagesize:32768 +# RUN: llvm-pdbutil pdb2yaml %t.pdb | FileCheck --check-prefix=PAGE32768 %s +# PAGE4096: BlockSize: 32768 Index: llvm/include/llvm/DebugInfo/MSF/MSFCommon.h =================================================================== --- llvm/include/llvm/DebugInfo/MSF/MSFCommon.h +++ llvm/include/llvm/DebugInfo/MSF/MSFCommon.h @@ -101,6 +101,26 @@ return false; } +/// Given the specified block size, returns the maximum possible file size. +/// Block Size | Max File Size +/// <= 4096 | 4GB +/// 8192 | 8GB +/// 16384 | 16GB +/// 32768 | 32GB +/// \p Size - the block size of the MSF +inline uint64_t getMaxFileSizeFromBlockSize(uint32_t Size) { + switch (Size) { + case 8192: + return (uint64_t)UINT32_MAX * 2ULL; + case 16384: + return (uint64_t)UINT32_MAX * 3ULL; + case 32768: + return (uint64_t)UINT32_MAX * 4ULL; + default: + return (uint64_t)UINT32_MAX; + } +} + // Super Block, Fpm0, Fpm1, and Block Map inline uint32_t getMinimumBlockCount() { return 4; } Index: llvm/include/llvm/DebugInfo/PDB/Native/PDBFile.h =================================================================== --- llvm/include/llvm/DebugInfo/PDB/Native/PDBFile.h +++ llvm/include/llvm/DebugInfo/PDB/Native/PDBFile.h @@ -65,7 +65,7 @@ uint32_t getStreamByteSize(uint32_t StreamIndex) const override; ArrayRef getStreamBlockList(uint32_t StreamIndex) const override; - uint32_t getFileSize() const; + uint64_t getFileSize() const; Expected> getBlockData(uint32_t BlockIndex, uint32_t NumBytes) const override; Index: llvm/lib/DebugInfo/MSF/MSFBuilder.cpp =================================================================== --- llvm/lib/DebugInfo/MSF/MSFBuilder.cpp +++ llvm/lib/DebugInfo/MSF/MSFBuilder.cpp @@ -343,12 +343,8 @@ 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)) { return make_error( msf_error_code::size_overflow, formatv("File size would have been {0,1:N}", FileSize)); Index: llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp =================================================================== --- llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp +++ llvm/lib/DebugInfo/PDB/Native/PDBFile.cpp @@ -100,7 +100,7 @@ return ContainerLayout.StreamMap[StreamIndex]; } -uint32_t PDBFile::getFileSize() const { return Buffer->getLength(); } +uint64_t PDBFile::getFileSize() const { return Buffer->getLength(); } Expected> PDBFile::getBlockData(uint32_t BlockIndex, uint32_t NumBytes) const { Index: llvm/tools/llvm-pdbutil/PdbYaml.h =================================================================== --- llvm/tools/llvm-pdbutil/PdbYaml.h +++ llvm/tools/llvm-pdbutil/PdbYaml.h @@ -40,7 +40,7 @@ uint32_t NumDirectoryBlocks = 0; std::vector DirectoryBlocks; uint32_t NumStreams = 0; - uint32_t FileSize = 0; + uint64_t FileSize = 0; }; struct StreamBlockList {