@@ -1560,15 +1560,21 @@ static void handlePAuthABI(const ArgList &DriverArgs, ArgStringList &CC1Args) {
1560
1560
1561
1561
static void CollectARMPACBTIOptions (const ToolChain &TC, const ArgList &Args,
1562
1562
ArgStringList &CmdArgs, bool isAArch64) {
1563
+ const llvm::Triple &Triple = TC.getEffectiveTriple ();
1563
1564
const Arg *A = isAArch64
1564
1565
? Args.getLastArg (options::OPT_msign_return_address_EQ,
1565
1566
options::OPT_mbranch_protection_EQ)
1566
1567
: 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
+ }
1568
1574
return ;
1575
+ }
1569
1576
1570
1577
const Driver &D = TC.getDriver ();
1571
- const llvm::Triple &Triple = TC.getEffectiveTriple ();
1572
1578
if (!(isAArch64 || (Triple.isArmT32 () && Triple.isArmMClass ())))
1573
1579
D.Diag (diag::warn_incompatible_branch_protection_option)
1574
1580
<< Triple.getArchName ();
@@ -1582,7 +1588,7 @@ static void CollectARMPACBTIOptions(const ToolChain &TC, const ArgList &Args,
1582
1588
D.Diag (diag::err_drv_unsupported_option_argument)
1583
1589
<< A->getSpelling () << Scope;
1584
1590
Key = " a_key" ;
1585
- IndirectBranches = false ;
1591
+ IndirectBranches = Triple. isOSOpenBSD () && isAArch64 ;
1586
1592
BranchProtectionPAuthLR = false ;
1587
1593
GuardedControlStack = false ;
1588
1594
} else {
0 commit comments