summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/attributes.rs
diff options
context:
space:
mode:
authorWesley Wiser <wesleywiser@microsoft.com>2023-05-19 19:30:15 -0400
committerWesley Wiser <wesleywiser@microsoft.com>2023-05-26 15:18:54 -0400
commit019d75b44e3f4349495890453d2d154a8f7ba116 (patch)
tree799eb3cf43244f783683bd449231fac0b8924c52 /compiler/rustc_codegen_llvm/src/attributes.rs
parentd22314e0f5fdb8ed1181dc1a9d1a85eb54b37c73 (diff)
downloadrust-019d75b44e3f4349495890453d2d154a8f7ba116.tar.gz
rust-019d75b44e3f4349495890453d2d154a8f7ba116.zip
Add SafeStack support to rustc
Adds support for LLVM [SafeStack] which provides backward edge control
flow protection by separating the stack into two parts: data which is
only accessed in provable safe ways is allocated on the normal stack
(the "safe stack") and all other data is placed in a separate allocation
(the "unsafe stack").

SafeStack support is enabled by passing `-Zsanitizer=safestack`.

[SafeStack]: https://clang.llvm.org/docs/SafeStack.html
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/attributes.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/attributes.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs
index 651d644ebb6..6d00464e0a0 100644
--- a/compiler/rustc_codegen_llvm/src/attributes.rs
+++ b/compiler/rustc_codegen_llvm/src/attributes.rs
@@ -88,6 +88,9 @@ pub fn sanitize_attrs<'ll>(
 
         attrs.push(llvm::AttributeKind::SanitizeMemTag.create_attr(cx.llcx));
     }
+    if enabled.contains(SanitizerSet::SAFESTACK) {
+        attrs.push(llvm::AttributeKind::SanitizeSafeStack.create_attr(cx.llcx));
+    }
     attrs
 }