Add new build option to support Windows DLLs#388
Merged
fitzgen merged 8 commits intorust-fuzz:mainfrom Nov 4, 2024
Merged
Conversation
…'exec_build()') for dependencies to detect when cargo-fuzz is running
…llows for Windows DLLs to be built *without* the '/include:main' linker argument. This, plus a few other tricks, allows for Windows DLLs to be built for fuzzing.
Member
|
Contributor
Author
|
@fitzgen - Thanks for your patience; I was out of town the past few days and haven't had a chance to address the two PRs. Just added the fix to set that argument's default value! |
Contributor
Author
|
Hi @fitzgen - just wanted to check in and see if you've been able to give this a second look! |
Member
|
I was on vacation for a bit, re-running CI now. Thanks for your patience! |
Contributor
Author
|
Thank you very much! Appreciate your help with getting this merged in 😄 |
Contributor
Author
|
@fitzgen - Will this be built into a future release? (When do you think that release would come?) It would be great to be able to pull this new code down via an updated version number in Let me know if there is anything I can do to help there. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi - this PR implements a new build argument:
--no-include-main-msvc- in order to help enable support for building and fuzzing Windows DLLs.I recently ran into an issue when attempting to fuzz a Windows-only DLL (#386) where the
/include:mainlinker argument that is added duringFuzzProject::cargo()for MSVC-based builds gave the DLL amainsymbol it could not resolve, which caused linking to fail:The DLL is, by nature, completely separate from the fuzzing targets in my cargo-fuzz repository, but I still wanted it to be a dependency listed in
fuzz/Cargo.toml, so that it would be built and instrumented in the exact same way as the fuzzing target binaries. I found that by controlling whether or not/include:mainis added to thecargo buildarguments executed by cargo-fuzz, I was able to set up a "dummy" fuzzing target that provides its own main function:Then, by executing
cargo fuzz run --no-include-main-msvc --features=build_dll dummy_target, the DLL would be built successfully. I could then proceed to run all other fuzzing targets, which would load in the instrumented DLL and fuzz it.TL;DR: This solution allows Windows DLLs to be instrumented & fuzzed, but only if manual control over
/include:mainis allowed (hence,--no-include-main-msvc). This resolves #386.