binutils Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
ld/pdb

ld/pdb: Report failures to write the PDB file

Ensures linker write errors for PDB files are reported to the user.

Previously, the linker ignored errors that occurred when closing and writing the PDB file. This meant that if the PDB file write failed (e.g., due to disk full or permissions), the linker would still report success, leaving a potentially truncated or empty PDB file. This change modifies create_pdb_file to check the return value of bfd_close and report any write failures.

In Details

The bfd_close call within create_pdb_file was not checked for errors. PDB streams are flushed and written upon closing the BFD. Ignoring bfd_close's return value meant that write errors (e.g., I/O errors) went unreported, potentially leaving a corrupt PDB file. This commit propagates the error return from bfd_close and includes error reporting and cleanup via unlink_if_ordinary.

For Context
PDB
Program Database file. Stores debugging and project-specific information for Microsoft Windows applications. The linker generates PDB files for debugging symbols.
bfd_close
A function in the Binary Descriptor Format (BFD) library that closes a file descriptor, flushing any pending writes and releasing resources.
coff_write_object_contents
A function within the coffcode.h header that handles writing object file contents, including invoking callback hooks for post-write operations.
unlink_if_ordinary
A function that removes a file if it exists and is a regular file, typically used for cleanup after a failed operation.
Filed Under: ldpdbbugfixreliability