Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BinSkim wants DWARF 5 but fails when analyzing binary with DWARF 5 #1020

Open
wesleywiser opened this issue Oct 31, 2024 · 0 comments
Open
Assignees
Labels
rust Rust

Comments

@wesleywiser
Copy link

wesleywiser commented Oct 31, 2024

By default, Rust generates DWARF 4 debug info for maximum compatibility with various debuggers and other tools. If I create a new an empty Rust project and analyze it, BinSkim complains that I should be using DWARF 5:

$ cargo new --bin hello_world
$ cd hello_world
$ cargo build
...
$ ~/Downloads/microsoft.codeanalysis.binskim.2.0.0-rc2/tools/netcoreapp3.1/win-x64/BinSkim.exe analyze ./target/debug/hello_world
Analyzing...
hello_world: error BA3003: The stack protector was not found in 'hello_world'. This may be because '--stack-protector-strong' was not used, or because it was explicitly disabled by '-fno-stack-protectors'.
Modules did not meet the criteria: hello_world
hello_world: error BA3004: 'hello_world' is using debugging dwarf version '4'. The dwarf version 5 contains more information and should be used. To enable the debugging version 5 use '-gdwarf-5'.

Done. 1 files scanned.
Analysis completed successfully.

One or more rules was disabled for an analysis target, as it was determined not to be applicable to it (this is a common condition). Pass --verbose on the command-line for more information.

However, if I recompile and force the use of DWARF 5, BinSkim fails with an unhandled exception:

$ RUSTFLAGS="-Zdwarf-version=5" cargo +nightly build --target x86_64-unknown-linux-gnu -Zbuild-std
...
$ ~/Downloads/microsoft.codeanalysis.binskim.2.0.0-rc2/tools/netcoreapp3.1/win-x64/BinSkim.exe analyze ./target/x86_64-unknown-linux-gnu/debug/hello_world
Analyzing...
hello_world : error ERR997.ExceptionLoadingAnalysisTarget : Could not load analysis target 'hello_world'.

Done. 1 files scanned.

Analysis did not complete due to one or more unrecoverable execution conditions.
Unexpected fatal runtime condition(s) observed: ExceptionLoadingTargetFile

Tested with

$ rustc +nightly --version
rustc 1.84.0-nightly (759e07f06 2024-10-30)
@AllDwarf AllDwarf added the rust Rust label Jan 9, 2025
@AllDwarf AllDwarf self-assigned this Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rust Rust
Projects
None yet
Development

No branches or pull requests

2 participants