Add support for generating the EHCont section
In the future Windows will enable Control-flow Enforcement Technology (CET aka Shadow Stacks). To protect the path where the context is updated during exception handling, the binary is required to enumerate valid unwind entrypoints in a dedicated section which is validated when the context is being set during exception handling. The required support for EHCONT has already been merged into LLVM, long ago. This change adds the Rust codegen option to enable it. Reference: * https://reviews.llvm.org/D40223 This also adds a new `ehcont-guard` option to the bootstrap config which enables EHCont Guard when building std.
This commit is contained in:
parent
2f8d81f9db
commit
e11d8d147b
10 changed files with 76 additions and 2 deletions
|
|
@ -1964,6 +1964,12 @@ impl<'a> Builder<'a> {
|
|||
rustflags.arg("-Ccontrol-flow-guard");
|
||||
}
|
||||
|
||||
// Same for EHCont Guard (this is not combined with the previous if-statement to make
|
||||
// merges with upstream easier).
|
||||
if cfg!(windows) && mode == Mode::Std && self.config.ehcont_guard && compiler.stage >= 1 {
|
||||
rustflags.arg("-Cehcont-guard");
|
||||
}
|
||||
|
||||
// For `cargo doc` invocations, make rustdoc print the Rust version into the docs
|
||||
// This replaces spaces with tabs because RUSTDOCFLAGS does not
|
||||
// support arguments with regular spaces. Hopefully someday Cargo will
|
||||
|
|
@ -2172,7 +2178,11 @@ impl<'a> Builder<'a> {
|
|||
}
|
||||
|
||||
// Only execute if it's supposed to run as default
|
||||
if desc.default && should_run.is_really_default() { self.ensure(step) } else { None }
|
||||
if desc.default && should_run.is_really_default() {
|
||||
self.ensure(step)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks if any of the "should_run" paths is in the `Builder` paths.
|
||||
|
|
|
|||
|
|
@ -248,6 +248,7 @@ pub struct Config {
|
|||
pub local_rebuild: bool,
|
||||
pub jemalloc: bool,
|
||||
pub control_flow_guard: bool,
|
||||
pub ehcont_guard: bool,
|
||||
|
||||
// dist misc
|
||||
pub dist_sign_folder: Option<PathBuf>,
|
||||
|
|
@ -1019,6 +1020,7 @@ define_config! {
|
|||
test_compare_mode: Option<bool> = "test-compare-mode",
|
||||
llvm_libunwind: Option<String> = "llvm-libunwind",
|
||||
control_flow_guard: Option<bool> = "control-flow-guard",
|
||||
ehcont_guard: Option<bool> = "ehcont-guard",
|
||||
new_symbol_mangling: Option<bool> = "new-symbol-mangling",
|
||||
profile_generate: Option<String> = "profile-generate",
|
||||
profile_use: Option<String> = "profile-use",
|
||||
|
|
@ -1452,6 +1454,7 @@ impl Config {
|
|||
config.rust_thin_lto_import_instr_limit = rust.thin_lto_import_instr_limit;
|
||||
set(&mut config.rust_remap_debuginfo, rust.remap_debuginfo);
|
||||
set(&mut config.control_flow_guard, rust.control_flow_guard);
|
||||
set(&mut config.ehcont_guard, rust.ehcont_guard);
|
||||
config.llvm_libunwind_default = rust
|
||||
.llvm_libunwind
|
||||
.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind"));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use super::*;
|
||||
use crate::core::config::{Config, DryRun, TargetSelection};
|
||||
use crate::core::build_steps::doc::DocumentationFormat;
|
||||
use crate::core::config::{Config, DryRun, TargetSelection};
|
||||
use std::thread;
|
||||
|
||||
fn configure(cmd: &str, host: &[&str], target: &[&str]) -> Config {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue