Skip to content

Commit 3067c93

Browse files
committed
Allow pauthabi+bti and disallow other combinations with pauthabi
1 parent 2608617 commit 3067c93

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

clang/test/Driver/aarch64-ptrauth.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,13 @@
3737
// RUN: not %clang -### -c --target=x86_64 -mbranch-protection=pauthabi %s 2>&1 | \
3838
// RUN: FileCheck %s --check-prefix=ERR2
3939
// ERR2: error: unsupported option '-mbranch-protection=' for target 'x86_64'
40+
41+
// RUN: not %clang -### -c --target=aarch64 -mbranch-protection=pauthabi+pac-ret %s 2>&1 | \
42+
// RUN: FileCheck %s --check-prefix=ERR3
43+
// ERR3: error: unsupported argument 'pauthabi+pac-ret' to option '-mbranch-protection='
44+
45+
// RUN: not %clang -### -c --target=aarch64 -mbranch-protection=gcs+pauthabi %s 2>&1 | \
46+
// RUN: FileCheck %s --check-prefix=ERR4
47+
// ERR4: error: unsupported argument 'pauthabi+gcs' to option '-mbranch-protection='
48+
49+
// RUN: %clang -### -c --target=aarch64 -mbranch-protection=bti+pauthabi %s 2>&1

llvm/lib/TargetParser/ARMTargetParserCommon.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,5 +190,17 @@ bool ARM::parseBranchProtection(StringRef Spec, ParsedBranchProtection &PBP,
190190
return false;
191191
}
192192

193+
if (!PBP.HasPauthABI)
194+
return true;
195+
196+
if (PBP.Scope != "none") {
197+
Err = "pauthabi+pac-ret";
198+
return false;
199+
}
200+
if (PBP.GuardedControlStack) {
201+
Err = "pauthabi+gcs";
202+
return false;
203+
}
204+
193205
return true;
194206
}

0 commit comments

Comments
 (0)