]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
bfd/pdb: fix bitmap generation in pdb_write_bitmap
authorMark Harmstone <mark@harmstone.com>
Sun, 1 Sep 2024 16:42:30 +0000 (17:42 +0100)
committerMark Harmstone <mark@harmstone.com>
Wed, 4 Sep 2024 01:24:37 +0000 (02:24 +0100)
commitb281480b26f1f27dc83ad3271fb2eaf9736dc3e0
treeb4df41bd8dce821103fa9649810a8f4b5814303c
parent6225a4d33a783e2556ab78e8c137654caa3d6dfe
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.
bfd/pdb.c