@@ -1560,15 +1560,21 @@ static void handlePAuthABI(const ArgList &DriverArgs, ArgStringList &CC1Args) {
15601560
15611561static void CollectARMPACBTIOptions (const ToolChain &TC, const ArgList &Args,
15621562 ArgStringList &CmdArgs, bool isAArch64) {
1563+ const llvm::Triple &Triple = TC.getEffectiveTriple ();
15631564 const Arg *A = isAArch64
15641565 ? Args.getLastArg (options::OPT_msign_return_address_EQ,
15651566 options::OPT_mbranch_protection_EQ)
15661567 : Args.getLastArg (options::OPT_mbranch_protection_EQ);
1567- if (!A)
1568+ if (!A) {
1569+ if (Triple.isOSOpenBSD () && isAArch64) {
1570+ CmdArgs.push_back (" -msign-return-address=non-leaf" );
1571+ CmdArgs.push_back (" -msign-return-address-key=a_key" );
1572+ CmdArgs.push_back (" -mbranch-target-enforce" );
1573+ }
15681574 return ;
1575+ }
15691576
15701577 const Driver &D = TC.getDriver ();
1571- const llvm::Triple &Triple = TC.getEffectiveTriple ();
15721578 if (!(isAArch64 || (Triple.isArmT32 () && Triple.isArmMClass ())))
15731579 D.Diag (diag::warn_incompatible_branch_protection_option)
15741580 << Triple.getArchName ();
@@ -1582,7 +1588,7 @@ static void CollectARMPACBTIOptions(const ToolChain &TC, const ArgList &Args,
15821588 D.Diag (diag::err_drv_unsupported_option_argument)
15831589 << A->getSpelling () << Scope;
15841590 Key = " a_key" ;
1585- IndirectBranches = false ;
1591+ IndirectBranches = Triple. isOSOpenBSD () && isAArch64 ;
15861592 BranchProtectionPAuthLR = false ;
15871593 GuardedControlStack = false ;
15881594 } else {
0 commit comments