Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0a5c8e1

Browse files
committedMar 19, 2020
Add Source file checksums in debug info section
1 parent 77600c0 commit 0a5c8e1

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed
 

‎src/debugging-support-in-rustc.md

+32-4
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,36 @@ Focus is to let macros decide what to do. This can be achieved by having some ki
268268
that lets the macro tell the compiler where the line marker should be. This affects where you
269269
set the breakpoints and what happens when you step it.
270270

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+
271301
## Future work
272302

273303
#### Name mangling changes
@@ -295,10 +325,6 @@ They implement just the expression language but they also add some extensions li
295325
convenience variables. Therefore, if you are taking this route then you not only need
296326
to do this bridge but may have to add some mode to let the compiler understand some extensions.
297327

298-
#### Windows debugging (PDB) is missing
299-
300-
This is a complete unknown.
301-
302328
[Tom Tromey discusses debugging support in rustc]: https://www.youtube.com/watch?v=elBxMRSNYr4
303329
[Debugging the Compiler]: compiler-debugging.md
304330
[debugger or debugging tool]: https://en.wikipedia.org/wiki/Debugger
@@ -319,3 +345,5 @@ This is a complete unknown.
319345
[Apple developer documentation for System Integrity Protection]: https://developer.apple.com/library/archive/releasenotes/MacOSX/WhatsNewInOSX/Articles/MacOSX10_11.html#//apple_ref/doc/uid/TP40016227-SW11
320346
[https://github.com/rust-lang/lldb]: https://github.com/rust-lang/lldb
321347
[https://github.com/rust-lang/llvm-project]: https://github.com/rust-lang/llvm-project
348+
[https://llvm.org/docs/LangRef.html#difile]: https://llvm.org/docs/LangRef.html#difile
349+
[https://docs.microsoft.com/en-us/cpp/build/reference/zh]: https://docs.microsoft.com/en-us/cpp/build/reference/zh

0 commit comments

Comments
 (0)
Please sign in to comment.