Skip to content

Instantly share code, notes, and snippets.

Source file checksums in debug info

Both the DWARF standard and the Microsoft CodeView (PDB) support embedding a cryptographic hash of each source file that contributed the associated binary.

The cryptographic hash can be used by a debugger to verify that the source file matches the executable. If the source file does not match, the debugger can provide a warning to the user.

The hash can also be used to prove that a given source file has not been modified since it was used to compile an executable. Because MD5 and SHA1 both have demonstrated vulnerabilities, using SHA256 is recommended for this application.