Mark Kettenis:

> CVSROOT:      /cvs
> Module name:  src
> Changes by:   kette...@cvs.openbsd.org        2023/04/17 12:10:26
> 
> Modified files:
>       gnu/llvm/clang/lib/Driver/ToolChains: Clang.cpp 
> 
> Log message:
> Make -mbranch-protection=bti the default on OpenBSD.

LLVM 15 reshuffled some code, so the change above no longer applies
there.  Here's my attempt to add it:

-----------------------------------------------
commit d80c4bf3bc72f631512bdaa922cc31d46a07257b (llvm15)
from: Christian Weisgerber <na...@mips.inka.de>
date: Mon Apr 17 22:33:20 2023 UTC
 
 llvm: Make -mbranch-protection=bti the default on OpenBSD.
 
diff f0fc5537edb677b1573883cbb90bfbfe54440790 
d80c4bf3bc72f631512bdaa922cc31d46a07257b
commit - f0fc5537edb677b1573883cbb90bfbfe54440790
commit + d80c4bf3bc72f631512bdaa922cc31d46a07257b
blob - 8c27644576624ffcb1242d848a9684fa16b7744c
blob + 903e477bb0e466763e5ba8e1156d763986310c81
--- gnu/llvm/clang/lib/Driver/ToolChains/Clang.cpp
+++ gnu/llvm/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1671,15 +1671,19 @@ static void CollectARMPACBTIOptions(const ToolChain &T
 
 static void CollectARMPACBTIOptions(const ToolChain &TC, const ArgList &Args,
                                     ArgStringList &CmdArgs, bool isAArch64) {
+  const llvm::Triple &Triple = TC.getEffectiveTriple();
+
   const Arg *A = isAArch64
                      ? Args.getLastArg(options::OPT_msign_return_address_EQ,
                                        options::OPT_mbranch_protection_EQ)
                      : Args.getLastArg(options::OPT_mbranch_protection_EQ);
-  if (!A)
+  if (!A) {
+    if (isAArch64 && Triple.isOSOpenBSD())
+      CmdArgs.push_back("-mbranch-target-enforce");
     return;
+  }
 
   const Driver &D = TC.getDriver();
-  const llvm::Triple &Triple = TC.getEffectiveTriple();
   if (!(isAArch64 || (Triple.isArmT32() && Triple.isArmMClass())))
     D.Diag(diag::warn_incompatible_branch_protection_option)
         << Triple.getArchName();

-- 
Christian "naddy" Weisgerber                          na...@mips.inka.de

Reply via email to