only enable bti and pac by default on arm64
authorjsg <jsg@openbsd.org>
Mon, 20 Nov 2023 01:35:21 +0000 (01:35 +0000)
committerjsg <jsg@openbsd.org>
Mon, 20 Nov 2023 01:35:21 +0000 (01:35 +0000)
before this change, clang on armv7 defined __ARM_FEATURE_BTI_DEFAULT and
__ARM_FEATURE_PAC_DEFAULT which broke the build of llvm libunwind

ok kettenis@ deraadt@

gnu/llvm/clang/lib/Driver/ToolChains/Clang.cpp

index 28feeed..1d07342 100644 (file)
@@ -1572,7 +1572,7 @@ static void CollectARMPACBTIOptions(const ToolChain &TC, const ArgList &Args,
                                        options::OPT_mbranch_protection_EQ)
                      : Args.getLastArg(options::OPT_mbranch_protection_EQ);
   if (!A) {
-    if (Triple.isOSOpenBSD()) {
+    if (Triple.isOSOpenBSD() && isAArch64) {
       CmdArgs.push_back("-msign-return-address=non-leaf");
       CmdArgs.push_back("-msign-return-address-key=a_key");
       CmdArgs.push_back("-mbranch-target-enforce");
@@ -1594,7 +1594,7 @@ static void CollectARMPACBTIOptions(const ToolChain &TC, const ArgList &Args,
       D.Diag(diag::err_drv_unsupported_option_argument)
           << A->getSpelling() << Scope;
     Key = "a_key";
-    if (Triple.isOSOpenBSD())
+    if (Triple.isOSOpenBSD() && isAArch64)
       IndirectBranches = true;
     else
       IndirectBranches = false;