Skip to content

Commit 00f5bfe

Browse files
ahmedbougachadtapuska
authored andcommitted
[AArch64] Add -fbranch-target-identification alias to -mbranch-target-enforce.
1 parent d61d58c commit 00f5bfe

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4384,6 +4384,10 @@ defm aarch64_jump_table_hardening: OptInCC1FFlag<"aarch64-jump-table-hardening",
43844384
}
43854385

43864386
let Group = f_Group in {
4387+
def fbranch_target_identification : Flag<["-"], "fbranch-target-identification">,
4388+
HelpText<"Emit branch target identification instructions for indirect branch destinations">;
4389+
def fno_branch_target_identification : Flag<["-"], "fno-branch-target-identification">;
4390+
43874391
def fptrauth_objc_isa_mode : Joined<["-"], "fptrauth-objc-isa-mode=">,
43884392
Visibility<[ClangOption, CC1Option, CC1AsOption]>,
43894393
HelpText<"Authentication mode for ObjC isa field. Full auth if unspecified">, Values<"strip,sign-and-strip,sign-and-auth">;

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,6 +1910,9 @@ void Clang::AddAArch64TargetArgs(const ArgList &Args,
19101910

19111911
// Enable/disable return address signing and indirect branch targets.
19121912
CollectARMPACBTIOptions(getToolChain(), Args, CmdArgs, true /*isAArch64*/);
1913+
if (Args.hasArg(options::OPT_fbranch_target_identification,
1914+
options::OPT_fno_branch_target_identification, false))
1915+
CmdArgs.push_back("-mbranch-target-enforce");
19131916
}
19141917

19151918
void Clang::AddLoongArchTargetArgs(const ArgList &Args,

clang/test/CodeGen/ptrauth-function-attributes.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
// RUN: %clang_cc1 -triple arm64e-apple-ios -faarch64-jump-table-hardening -emit-llvm %s -o - | FileCheck %s --check-prefixes=ALL,JMPTBL
1818
// RUN: %clang_cc1 -triple aarch64-linux-gnu -faarch64-jump-table-hardening -emit-llvm %s -o - | FileCheck %s --check-prefixes=ALL,JMPTBL
1919

20+
// RUN: %clang_cc1 -triple arm64e-apple-ios -mbranch-target-enforce -emit-llvm %s -o - | FileCheck %s --check-prefixes=ALL,BTI
21+
2022
// ALL: define {{(dso_local )?}}void @test() #0
2123
void test() {
2224
}
@@ -31,4 +33,7 @@ void test() {
3133

3234
// JMPTBL: attributes #0 = {{{.*}} "aarch64-jump-table-hardening" {{.*}}}
3335

36+
// BTI: !1 = !{i32 8, !"branch-target-enforcement", i32 1}
37+
3438
// OFF-NOT: attributes {{.*}} "ptrauth-
39+
// OFF-NOT: !"branch-target-enforcement"

0 commit comments

Comments
 (0)