From 6d4156572690f935ad02b3501d405e46fe265f1e Mon Sep 17 00:00:00 2001 From: csmoe Date: Fri, 4 Mar 2022 09:28:29 +0000 Subject: [PATCH] add address sanitizer fo android --- compiler/rustc_target/src/spec/aarch64_linux_android.rs | 3 ++- compiler/rustc_target/src/spec/arm_linux_androideabi.rs | 3 ++- compiler/rustc_target/src/spec/armv7_linux_androideabi.rs | 3 ++- compiler/rustc_target/src/spec/i686_linux_android.rs | 4 ++-- compiler/rustc_target/src/spec/x86_64_linux_android.rs | 4 ++-- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_target/src/spec/aarch64_linux_android.rs b/compiler/rustc_target/src/spec/aarch64_linux_android.rs index 5692925f63b..87696b3664c 100644 --- a/compiler/rustc_target/src/spec/aarch64_linux_android.rs +++ b/compiler/rustc_target/src/spec/aarch64_linux_android.rs @@ -16,7 +16,8 @@ pub fn target() -> Target { features: "+neon,+fp-armv8".to_string(), supported_sanitizers: SanitizerSet::CFI | SanitizerSet::HWADDRESS - | SanitizerSet::MEMTAG, + | SanitizerSet::MEMTAG + | SanitizerSet::ADDRESS, ..super::android_base::opts() }, } diff --git a/compiler/rustc_target/src/spec/arm_linux_androideabi.rs b/compiler/rustc_target/src/spec/arm_linux_androideabi.rs index 9b5366c576e..933b43986c9 100644 --- a/compiler/rustc_target/src/spec/arm_linux_androideabi.rs +++ b/compiler/rustc_target/src/spec/arm_linux_androideabi.rs @@ -1,4 +1,4 @@ -use crate::spec::{Target, TargetOptions}; +use crate::spec::{SanitizerSet, Target, TargetOptions}; pub fn target() -> Target { Target { @@ -10,6 +10,7 @@ pub fn target() -> Target { abi: "eabi".to_string(), // https://developer.android.com/ndk/guides/abis.html#armeabi features: "+strict-align,+v5te".to_string(), + supported_sanitizers: SanitizerSet::ADDRESS, max_atomic_width: Some(32), ..super::android_base::opts() }, diff --git a/compiler/rustc_target/src/spec/armv7_linux_androideabi.rs b/compiler/rustc_target/src/spec/armv7_linux_androideabi.rs index 55956f3bad4..adf831c12eb 100644 --- a/compiler/rustc_target/src/spec/armv7_linux_androideabi.rs +++ b/compiler/rustc_target/src/spec/armv7_linux_androideabi.rs @@ -1,4 +1,4 @@ -use crate::spec::{LinkerFlavor, Target, TargetOptions}; +use crate::spec::{LinkerFlavor, SanitizerSet, Target, TargetOptions}; // This target if is for the baseline of the Android v7a ABI // in thumb mode. It's named armv7-* instead of thumbv7-* @@ -19,6 +19,7 @@ pub fn target() -> Target { options: TargetOptions { abi: "eabi".to_string(), features: "+v7,+thumb-mode,+thumb2,+vfp3,-d32,-neon".to_string(), + supported_sanitizers: SanitizerSet::ADDRESS, max_atomic_width: Some(64), ..base }, diff --git a/compiler/rustc_target/src/spec/i686_linux_android.rs b/compiler/rustc_target/src/spec/i686_linux_android.rs index 640f9e42f4a..e9ddaa37c26 100644 --- a/compiler/rustc_target/src/spec/i686_linux_android.rs +++ b/compiler/rustc_target/src/spec/i686_linux_android.rs @@ -1,4 +1,4 @@ -use crate::spec::{StackProbeType, Target}; +use crate::spec::{SanitizerSet, StackProbeType, Target, TargetOptions}; // See https://developer.android.com/ndk/guides/abis.html#x86 // for target ABI requirements. @@ -21,6 +21,6 @@ pub fn target() -> Target { f64:32:64-f80:32-n8:16:32-S128" .to_string(), arch: "x86".to_string(), - options: base, + options: TargetOptions { supported_sanitizers: SanitizerSet::ADDRESS, ..base }, } } diff --git a/compiler/rustc_target/src/spec/x86_64_linux_android.rs b/compiler/rustc_target/src/spec/x86_64_linux_android.rs index 9065283b731..657520a8caf 100644 --- a/compiler/rustc_target/src/spec/x86_64_linux_android.rs +++ b/compiler/rustc_target/src/spec/x86_64_linux_android.rs @@ -1,4 +1,4 @@ -use crate::spec::{LinkerFlavor, StackProbeType, Target}; +use crate::spec::{LinkerFlavor, SanitizerSet, StackProbeType, Target, TargetOptions}; pub fn target() -> Target { let mut base = super::android_base::opts(); @@ -16,6 +16,6 @@ pub fn target() -> Target { data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" .to_string(), arch: "x86_64".to_string(), - options: base, + options: TargetOptions { supported_sanitizers: SanitizerSet::ADDRESS, ..base }, } }