aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorJohn Brawn <john.brawn@arm.com>2024-01-11 12:53:23 +0000
committerGitHub <noreply@github.com>2024-01-11 12:53:23 +0000
commit40d5c2bcd41a534e6bab98fedf1a930d9bd165e7 (patch)
tree84ddc7acc5c32f0991a2f9adb17c953b9b05d9b4 /clang/lib/CodeGen/CodeGenModule.cpp
parentb7770befee37feca3d732d6daf9513c62f75c5f0 (diff)
downloadllvm-40d5c2bcd41a534e6bab98fedf1a930d9bd165e7.zip
llvm-40d5c2bcd41a534e6bab98fedf1a930d9bd165e7.tar.gz
llvm-40d5c2bcd41a534e6bab98fedf1a930d9bd165e7.tar.bz2
[clang][AArch64] Add a -mbranch-protection option to enable GCS (#75486)
-mbranch-protection=gcs (enabled by -mbranch-protection=standard) causes generated objects to be marked with the gcs feature. This is done via the guarded-control-stack module flag, in a similar way to branch-target-enforcement and sign-return-address. Enabling GCS causes the GNU_PROPERTY_AARCH64_FEATURE_1_GCS bit to be set on generated objects. No code generation changes are required, as GCS just requires that functions are called using BL and returned from using RET (or other similar variant instructions), which is already the case.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 4fd3233..ad6fc71 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1109,6 +1109,8 @@ void CodeGenModule::Release() {
if (LangOpts.BranchProtectionPAuthLR)
getModule().addModuleFlag(llvm::Module::Min, "branch-protection-pauth-lr",
1);
+ if (LangOpts.GuardedControlStack)
+ getModule().addModuleFlag(llvm::Module::Min, "guarded-control-stack", 1);
if (LangOpts.hasSignReturnAddress())
getModule().addModuleFlag(llvm::Module::Min, "sign-return-address", 1);
if (LangOpts.isSignReturnAddressScopeAll())