bfd/pdb: fix bitmap generation in pdb_write_bitmap

MSVC 2022 is more pedantic than MSVC 2019 when it comes to loading PDB
files in readonly mode, and was rejecting PDB files generated by binutils
because of their invalid free-space bitmaps. It's unknown what would
have happened if you tried to use MS tools to modify a PDB created by
binutils, but it probably would have led to a corrupted file.

This patch fixes pdb_write_bitmap so we generate files that MSVC will accept.

Specifically there were three things we were doing wrong:

- We weren't including the superblock (block 0)

- We were setting bits in bytes backwards (MSB to LSB, rather than LSB to MSB)

- We should have been marking the contents of stream 0 as free. This is
  because, as the comment says, it's intended to be used for the
  directory for the previous write, to allow atomic updates.
1 file changed