bfd/pdb: Increase the PDB block size to 4096
Increases the PDB block size in Binutils from 1024 bytes to 4096 bytes to support larger PDB files, aligning with MSVC usage.
Oleg Tolmatcev proposes increasing the PDB block size in Binutils from 1024 bytes to 4096 bytes. The current 1024-byte block size limits PDB files to approximately 64 MB due to the stream directory’s block map size, causing LLVM tools to reject larger files. Increasing the block size to 4096, which matches MSVC’s usage, raises this limit to around 4 GB.
- proposer
Proposes increasing PDB block size to 4096 to support larger PDB files and overcome limitations with current 1024-byte blocks.
“The block map of the stream directory is itself a single block, so with 1024 byte blocks it can only hold 256 block numbers, which limits a PDB file to about 64 MB. Writing a larger one fails partway through and leaves a truncated file behind, which llvm-pdbutil rejects with "Too many directory blocks".”
- reviewer
Questions the necessity of a fixed large block size for smaller PDBs and asks for proof of MSVC's usage, suggesting a dynamic block size.
“That sounds pretty limiting, making me wonder why it was done like that. Mark? The claim on what MSVC uses could do with some reference / proof. And then, while surely many will say disk space is cheap, isn't this a little wasteful for smallish PDBs? I.e. ... may this want to become dynamically determined?”
Technical Tradeoffs
- Enables support for larger PDB files, crucial for complex projects.
- Increases the minimum storage overhead for very small PDB files.
- Aligns Binutils' PDB implementation with common practices (MSVC), improving compatibility.
In Details
This change addresses a limitation in Binutils' PDB writing capabilities where the maximum PDB file size is capped at approximately 64 MB due to the use of 1024-byte blocks. The stream directory's block map, being a single block itself, can only reference 256 sub-blocks, constraining the total file size. The proposal is to increase this block size to 4096 bytes, aligning with Microsoft's Visual C++ compiler usage and extending the maximum supported PDB size to around 4 GB. This is essential for larger projects that generate substantial debugging information.
- PDB
- Program Database. A file format used by Microsoft's compilers and debuggers to store information about program symbols and types, often used for debugging C/C++ code.
- block size
- The fundamental unit of data allocation and transfer within the PDB file structure. A larger block size allows for larger files but may be less efficient for very small files.
- stream directory
- A data structure within the PDB format that manages access to different streams (logical data segments) within the PDB file.
- block map
- A data structure within the PDB format that maps logical block addresses to physical block addresses on disk.
- MSVC
- Microsoft Visual C++, Microsoft's C and C++ compiler.