about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorAndrew Paverd <andrew.paverd@microsoft.com>2020-01-13 13:25:39 +0000
committerAndrew Paverd <andrew.paverd@microsoft.com>2020-01-28 14:43:23 +0000
commitc0744e1e0c35b1083733fd5c74fc3fb5a6cd04f7 (patch)
tree48b10b069dd6728f528f8f60fca0293674ebe46e /src/test
parentb181835a6bacfa449f55d46764a10e25d1c471dc (diff)
downloadrust-c0744e1e0c35b1083733fd5c74fc3fb5a6cd04f7.tar.gz
rust-c0744e1e0c35b1083733fd5c74fc3fb5a6cd04f7.zip
Add support for Control Flow Guard on Windows.
This patch enables rustc to emit the required LLVM module flags to enable Control Flow Guard metadata (cfguard=1) or metadata and checks (cfguard=2). The LLVM module flags are ignored on unsupported targets and operating systems.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/codegen/cfguard_checks.rs10
-rw-r--r--src/test/codegen/cfguard_disabled.rs10
-rw-r--r--src/test/codegen/cfguard_nochecks.rs10
3 files changed, 30 insertions, 0 deletions
diff --git a/src/test/codegen/cfguard_checks.rs b/src/test/codegen/cfguard_checks.rs
new file mode 100644
index 00000000000..40a7353eac0
--- /dev/null
+++ b/src/test/codegen/cfguard_checks.rs
@@ -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
diff --git a/src/test/codegen/cfguard_disabled.rs b/src/test/codegen/cfguard_disabled.rs
new file mode 100644
index 00000000000..d1747931e15
--- /dev/null
+++ b/src/test/codegen/cfguard_disabled.rs
@@ -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"
diff --git a/src/test/codegen/cfguard_nochecks.rs b/src/test/codegen/cfguard_nochecks.rs
new file mode 100644
index 00000000000..c5d7afbae25
--- /dev/null
+++ b/src/test/codegen/cfguard_nochecks.rs
@@ -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