-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Synthetic object files disable control flow protection features #103001
Comments
I can think of three possible solutions:
@MaskRay may have thoughts on this. |
Option 3 is not enough to solve this. The crate metadata object is also produced without these properties and can't be replaced with a linker option. Option 2 will take a long time before everyone has a new linker and needs coordination with ld.bfd, ld.gold, ld.ldd and ld.mold. As such option 1 makes most sense to me. |
Option 2 needs coordination among linker maintainers and it does impose some complexity to linkers. And as mentioned, it requires very new linkers. If Rust is open to 1, I think it is a great direction. |
@rustbot claim |
Use constants from object crate Replace hard-coded values with `GNU_PROPERTY_{X86|AARCH64}_FEATURE_1_AND` from the object crate. When working on [issue](rust-lang#103001) it was suggested that we moved these constants to the object crate . [PR](gimli-rs/object#537). Now that that the object crate has been updated [PR](rust-lang#111413) we can make this change.
Use constants from object crate Replace hard-coded values with `GNU_PROPERTY_{X86|AARCH64}_FEATURE_1_AND` from the object crate. When working on [issue](rust-lang#103001) it was suggested that we moved these constants to the object crate . [PR](gimli-rs/object#537). Now that that the object crate has been updated [PR](rust-lang#111413) we can make this change.
I noticed that the synthetic object files added in #95604 will disable the IBT (on x86, enabled by
-Z cf-protection=branch
) and BTI (on AArch64, enabled by-Z branch-protection=bti
) features because the object files are missing.note.gnu.property
sections indicating that the object file is compatible with those features. Normally, if an object file is missing a.note.gnu.property
section, the linker will disable all such features, on the assumption that the object file is not compatible.This issue is reproducible on the master branch (slightly awkwardly because many distros don't ship IBT-enabled
*crt*.o
files, and neither is it enabled in Rust's standard library by default):In another directory:
After commenting out the line of code that adds
symbols.o
to the link:the binary has the correct property note:
The text was updated successfully, but these errors were encountered: