From adf61e3b2b72f4a06b3ac5cf90d49deda42da605 Mon Sep 17 00:00:00 2001 From: Ivan Lozano Date: Fri, 17 Jun 2022 14:14:58 -0400 Subject: Add ShadowCallStack Support Adds support for the LLVM ShadowCallStack sanitizer. --- compiler/rustc_codegen_llvm/src/attributes.rs | 3 +++ compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 1 + 2 files changed, 4 insertions(+) (limited to 'compiler/rustc_codegen_llvm') diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index 62da99ac3fb..1a96dd8bec4 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -69,6 +69,9 @@ pub fn sanitize_attrs<'ll>( if enabled.contains(SanitizerSet::HWADDRESS) { attrs.push(llvm::AttributeKind::SanitizeHWAddress.create_attr(cx.llcx)); } + if enabled.contains(SanitizerSet::SHADOWCALLSTACK) { + attrs.push(llvm::AttributeKind::ShadowCallStack.create_attr(cx.llcx)); + } if enabled.contains(SanitizerSet::MEMTAG) { // Check to make sure the mte target feature is actually enabled. let features = cx.tcx.global_backend_features(()); diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 73cedb59349..8a6101e051b 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -192,6 +192,7 @@ pub enum AttributeKind { NoUndef = 33, SanitizeMemTag = 34, NoCfCheck = 35, + ShadowCallStack = 36, } /// LLVMIntPredicate -- cgit 1.4.1-3-g733a5