-
Notifications
You must be signed in to change notification settings - Fork 11.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ARM] Enable cfi-icall for thumb triples #102126
Conversation
Support for this was added back in 2016 (https://reviews.llvm.org/D27499), but never enabled in the driver. Since then, it's been possible to enable this with an arm triple and the -mthumb option, but not with a thumb triple. This also caused -fsanitise=cfi to enable cfi-icall for arm triple but not thumb triples, which caused spurious sanitiser failures if mixing the two ISAs in one program.
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-driver Author: Oliver Stannard (ostannard) ChangesSupport for this was added back in 2016 (https://reviews.llvm.org/D27499), but never enabled in the driver. Since then, it's been possible to enable this with an arm triple and the -mthumb option, but not with a thumb triple. This also caused -fsanitise=cfi to enable cfi-icall for arm triple but not thumb triples, which caused spurious sanitiser failures if mixing the two ISAs in one program. Full diff: https://github.com/llvm/llvm-project/pull/102126.diff 2 Files Affected:
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 20a555afb8092..2d50c2cbbc881 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -1381,7 +1381,8 @@ SanitizerMask ToolChain::getSupportedSanitizers() const {
SanitizerKind::Nullability | SanitizerKind::LocalBounds;
if (getTriple().getArch() == llvm::Triple::x86 ||
getTriple().getArch() == llvm::Triple::x86_64 ||
- getTriple().getArch() == llvm::Triple::arm || getTriple().isWasm() ||
+ getTriple().getArch() == llvm::Triple::arm ||
+ getTriple().getArch() == llvm::Triple::thumb || getTriple().isWasm() ||
getTriple().isAArch64() || getTriple().isRISCV() ||
getTriple().isLoongArch64())
Res |= SanitizerKind::CFIICall;
diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index db14f6e195c64..678fa432fb0a0 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -611,6 +611,8 @@
// RUN: %clang --target=arm-linux-gnu -fvisibility=hidden -fsanitize=cfi -flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
// RUN: %clang --target=aarch64-linux-gnu -fvisibility=hidden -fsanitize=cfi -flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
// RUN: %clang --target=arm-linux-android -fvisibility=hidden -fsanitize=cfi -flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
+// RUN: %clang --target=arm-none-eabi -fvisibility=hidden -fsanitize=cfi -flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
+// RUN: %clang --target=thumb-none-eabi -fvisibility=hidden -fsanitize=cfi -flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
// RUN: %clang --target=aarch64-linux-android -fvisibility=hidden -fsanitize=cfi -flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
// RUN: %clang --target=aarch64_be -fvisibility=hidden -fsanitize=cfi -flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
// RUN: %clang --target=riscv32 -fvisibility=hidden -fsanitize=cfi -flto -resource-dir=%S/Inputs/resource_dir -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI
|
Support for this was added back in 2016 (https://reviews.llvm.org/D27499), but never enabled in the driver. Since then, it's been possible to enable this with an arm triple and the -mthumb option, but not with a thumb triple. This also caused -fsanitise=cfi to enable cfi-icall for arm triple but not thumb triples, which caused spurious sanitiser failures if mixing the two ISAs in one program.
Support for this was added back in 2016 (https://reviews.llvm.org/D27499), but never enabled in the driver. Since then, it's been possible to enable this with an arm triple and the -mthumb option, but not with a thumb triple. This also caused -fsanitise=cfi to enable cfi-icall for arm triple but not thumb triples, which caused spurious sanitiser failures if mixing the two ISAs in one program.
Support for this was added back in 2016 (https://reviews.llvm.org/D27499), but never enabled in the driver. Since then, it's been possible to enable this with an arm triple and the -mthumb option, but not with a thumb triple. This also caused -fsanitise=cfi to enable cfi-icall for arm triple but not thumb triples, which caused spurious sanitiser failures if mixing the two ISAs in one program.
Support for this was added back in 2016 (https://reviews.llvm.org/D27499), but never enabled in the driver. Since then, it's been possible to enable this with an arm triple and the -mthumb option, but not with a thumb triple.
This also caused -fsanitise=cfi to enable cfi-icall for arm triple but not thumb triples, which caused spurious sanitiser failures if mixing the two ISAs in one program.