Skip to content

Commit 0a9b5cf

Browse files
unconditionally allow shadow call-stack for AArch64 whenever fixed-x18 is applied
1 parent 8c7e0e1 commit 0a9b5cf

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

Diff for: compiler/rustc_session/src/session.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,12 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
11871187

11881188
// Sanitizers can only be used on platforms that we know have working sanitizer codegen.
11891189
let supported_sanitizers = sess.target.options.supported_sanitizers;
1190-
let unsupported_sanitizers = sess.opts.unstable_opts.sanitizer - supported_sanitizers;
1190+
let mut unsupported_sanitizers = sess.opts.unstable_opts.sanitizer - supported_sanitizers;
1191+
// Niche: if `fixed-x18`, or effectively switching on `reserved-x18` flag, is enabled
1192+
// we should allow Shadow Call Stack sanitizer.
1193+
if sess.opts.unstable_opts.fixed_x18 && sess.target.arch == "aarch64" {
1194+
unsupported_sanitizers -= SanitizerSet::SHADOWCALLSTACK;
1195+
}
11911196
match unsupported_sanitizers.into_iter().count() {
11921197
0 => {}
11931198
1 => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ needs-llvm-components: aarch64
2+
//@ revisions: aarch64 android
3+
//@[aarch64] compile-flags: --target aarch64-unknown-none -Zfixed-x18 -Zsanitizer=shadow-call-stack
4+
//@[android] compile-flags: --target aarch64-linux-android -Zfixed-x18 -Zsanitizer=shadow-call-stack
5+
6+
#![allow(internal_features)]
7+
#![crate_type = "rlib"]
8+
#![feature(no_core, lang_items)]
9+
#![no_core]
10+
11+
#[lang = "sized"]
12+
trait Sized {}
13+
14+
// CHECK: ; Function Attrs:{{.*}}shadowcallstack
15+
#[no_mangle]
16+
pub fn foo() {}
17+
18+
// CHECK: attributes #0 = {{.*}}shadowcallstack{{.*}}+reserve-x18

Diff for: tests/ui/abi/shadow-call-stack-without-fixed-x18.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ compile-flags: --target aarch64-unknown-none -Zsanitizer=shadow-call-stack
2+
//@ error-pattern: shadow-call-stack sanitizer is not supported for this target
3+
//@ dont-check-compiler-stderr
4+
//@ needs-llvm-components: aarch64
5+
6+
#![allow(internal_features)]
7+
#![crate_type = "rlib"]
8+
#![feature(no_core, lang_items)]
9+
#![no_core]
10+
11+
#[lang = "sized"]
12+
trait Sized {}
13+
14+
#[no_mangle]
15+
pub fn foo() {}

0 commit comments

Comments
 (0)