-
Notifications
You must be signed in to change notification settings - Fork 32
Externally inject auditable data #29
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
Comments
I've been thinking along the same lines!
It's mildly more portable, in the sense that we don't need extra platform-specific tools for every platform (e.g. I have big ambitions of getting this thing into Cargo, and I'm not 100% sure what their policy on calling external tools would be. But yes, writing a Cargo wrapper that does this would be fairly trivial and I'd be happy to have a branch with that approach. |
An option would be to compile a staticlib containing the audit data and then tell rustc to link this staticlib when building the final executable. |
@bjorn3 I was not aware of that approach! I understand that would require some sort of extra crate with |
I fear the symbol would not survive LTO with the staticlib approach unless it's used from the main binary. |
I just realized that rustc produces staticlibs will contain a copy of the standard library which would cause conflicts. You could copy the logic rustc itself uses to produce object files containing the crate metadata. These are normally used for dylibs, but should work fine for executables too: https://github.com/rust-lang/rust/blob/e100ec5bc7cd768ec17d75448b29c9ab4a39272b/compiler/rustc_codegen_ssa/src/back/metadata.rs#L233-L287 You can then use |
I have pushed a new branch, The proof-of-concept tool is called Usage: I have ignored endianness as well as some tricky special-casing for MIPS and RISC-V, because I don't know how to derive those from the target triple without having access to rustc internals. I hope Cargo has access to that stuff internally. In the meanwhile I'll probably have to get by with a hardcoded list of big-endian architectures or some such... |
Cargo uses |
Thanks a lot for the tip, @Nemo157 ! I have migrated to parsing |
I think I'm going to make a |
External injection via I've removed mentions of the original |
I was recently thinking about what it would take to integrate something like this into a
cargo install
process. The biggest issue I see is that it requires modifying the binary sources to have the data added. I think a potentially more useful approach is a way to inject this data into an arbitrary binary build; maybe via something like a cargo wrappercargo auditable build
.This would also avoid issues #9, #11 and #13 (but probably introduce others 😀).
Is there a reason to prefer the current approach where each binary needs to be configured to include the data?
The text was updated successfully, but these errors were encountered: