From 019d75b44e3f4349495890453d2d154a8f7ba116 Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Fri, 19 May 2023 19:30:15 -0400 Subject: 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 --- compiler/rustc_codegen_llvm/src/attributes.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'compiler/rustc_codegen_llvm/src/attributes.rs') 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 } -- cgit 1.4.1-3-g733a5