Auto merge of #68180 - ajpaverd:cfguard-rust, r=nagisa
Add support for Control Flow Guard on Windows.
LLVM now supports Windows Control Flow Guard (CFG): d157a9bc8b
This patch adds support for rustc to emit the required LLVM module flags to enable CFG metadata (cfguard=1) or metadata and checks (cfguard=2). The LLVM module flags are ignored on unsupported targets and operating systems.
This commit is contained in:
commit
64184a3288
8 changed files with 98 additions and 5 deletions
10
src/test/codegen/cfguard_checks.rs
Normal file
10
src/test/codegen/cfguard_checks.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// compile-flags: -Z control_flow_guard=checks
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
||||
// A basic test function.
|
||||
pub fn test() {
|
||||
}
|
||||
|
||||
// Ensure the module flag cfguard=2 is present
|
||||
// CHECK: !"cfguard", i32 2
|
||||
10
src/test/codegen/cfguard_disabled.rs
Normal file
10
src/test/codegen/cfguard_disabled.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// compile-flags: -Z control_flow_guard=disabled
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
||||
// A basic test function.
|
||||
pub fn test() {
|
||||
}
|
||||
|
||||
// Ensure the module flag cfguard is not present
|
||||
// CHECK-NOT: !"cfguard"
|
||||
10
src/test/codegen/cfguard_nochecks.rs
Normal file
10
src/test/codegen/cfguard_nochecks.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// compile-flags: -Z control_flow_guard=nochecks
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
||||
// A basic test function.
|
||||
pub fn test() {
|
||||
}
|
||||
|
||||
// Ensure the module flag cfguard=1 is present
|
||||
// CHECK: !"cfguard", i32 1
|
||||
Loading…
Add table
Add a link
Reference in a new issue