ld/pdb: Report PDB write failures
Ensures linker reports errors when writing PDB files, preventing silent failures.
This patch modifies the linker’s PDB writing process to check the return value of bfd_close. Previously, errors during the closing and writing of PDB streams were ignored, leading to truncated files and successful exits. The change adds a warning message when bfd_close fails, ensuring that write errors are reported to the user.
In Details
This change in the PDB writing functionality of binutils' linker (ld) addresses a silent failure mode. PDB streams are flushed and written upon closing the file handle (bfd_close). If bfd_close encountered an error (e.g., disk full, I/O error), the return value was ignored. This meant that ld would exit successfully even if the PDB file was incomplete or corrupted. The patch now checks bfd_close's return value and emits an error message via einfo if it fails.
- PDB
- Program Database. A file format used by Microsoft for storing debugging and project-related information for Microsoft Windows applications.
- ld
- The GNU linker, responsible for combining object files into an executable or shared library.
- bfd_close
- A function in the BFD library that closes a binary file descriptor, flushing any pending writes.
- einfo
- A logging function used within binutils to print informational messages.