@@ -268,6 +268,36 @@ Focus is to let macros decide what to do. This can be achieved by having some ki
268
268
that lets the macro tell the compiler where the line marker should be. This affects where you
269
269
set the breakpoints and what happens when you step it.
270
270
271
+ ## Source file checksums in debug info
272
+
273
+ Both DWARF and CodeView (PDB) support embedding a cryptographic hash of each source file that
274
+ contributed the associated binary.
275
+
276
+ The cryptographic hash can be used by a debugger to verify that the source file matches the
277
+ executable. If the source file does not match, the debugger can provide a warning to the user.
278
+
279
+ The hash can also be used to prove that a given source file has not been modified since it was
280
+ used to compile an executable. Because MD5 and SHA1 both have demonstrated vulnerabilities,
281
+ using SHA256 is recommended for this application.
282
+
283
+ #### DWARF 5
284
+ DWARF version 5 supports embedding an MD5 hash to validate the source file version in use.
285
+ DWARF 5 - Section 6.2.4.1 opcode DW_LNCT_MD5
286
+
287
+ #### LLVM
288
+ LLVM IR supports MD5, SHA1, and SHA256 source file checksums in the DIFile node.
289
+
290
+ LLVM DIFile documentation: [ https://llvm.org/docs/LangRef.html#difile ]
291
+
292
+ #### Microsoft Visual C++ Compiler /ZH option
293
+ The MSVC compiler supports embedding MD5, SHA1, or SHA256 hashes in the PDB using the ` /ZH `
294
+ compiler option.
295
+
296
+ MSVC /ZH documentation: [ https://docs.microsoft.com/en-us/cpp/build/reference/zh ]
297
+
298
+ #### Clang
299
+ Clang always embeds an MD5 checksum, though this does not appear in documentation.
300
+
271
301
## Future work
272
302
273
303
#### Name mangling changes
@@ -295,10 +325,6 @@ They implement just the expression language but they also add some extensions li
295
325
convenience variables. Therefore, if you are taking this route then you not only need
296
326
to do this bridge but may have to add some mode to let the compiler understand some extensions.
297
327
298
- #### Windows debugging (PDB) is missing
299
-
300
- This is a complete unknown.
301
-
302
328
[ Tom Tromey discusses debugging support in rustc ] : https://www.youtube.com/watch?v=elBxMRSNYr4
303
329
[ Debugging the Compiler ] : compiler-debugging.md
304
330
[ debugger or debugging tool ] : https://en.wikipedia.org/wiki/Debugger
0 commit comments