308b2c0
From 8af8f327457738620d2c85bd65db8cc5594585db Mon Sep 17 00:00:00 2001
308b2c0
From: Yuta Saito <kateinoigakukun@gmail.com>
308b2c0
Date: Wed, 27 Dec 2023 06:22:45 +0000
308b2c0
Subject: [PATCH 1/2] [Bug #20085] Use consistent default options for
308b2c0
 `-mbranch-protection`
308b2c0
308b2c0
We need to use the same options for both C compiler and assembler
308b2c0
when `-mbranch-protection` is guessed by configure. Otherwise,
308b2c0
`coroutine/arm64/Context.{h,S}` will use incompatible PAC strategies.
308b2c0
---
308b2c0
 configure.ac | 3 +++
308b2c0
 1 file changed, 3 insertions(+)
308b2c0
308b2c0
diff --git a/configure.ac b/configure.ac
308b2c0
index 9286946fc1..18b4247991 100644
308b2c0
--- a/configure.ac
308b2c0
+++ b/configure.ac
308b2c0
@@ -830,7 +830,10 @@ AS_IF([test "$GCC" = yes], [
308b2c0
 	AS_FOR(option, opt, [-mbranch-protection=pac-ret -msign-return-address=all], [
308b2c0
             RUBY_TRY_CFLAGS(option, [branch_protection=yes], [branch_protection=no])
308b2c0
             AS_IF([test "x$branch_protection" = xyes], [
308b2c0
+                # C compiler and assembler must be consistent for -mbranch-protection
308b2c0
+                # since they both check `__ARM_FEATURE_PAC_DEFAULT` definition.
308b2c0
                 RUBY_APPEND_OPTION(XCFLAGS, option)
308b2c0
+                RUBY_APPEND_OPTION(ASFLAGS, option)
308b2c0
                 break
308b2c0
             ])
308b2c0
         ])
308b2c0
-- 
308b2c0
2.43.0
308b2c0
308b2c0
308b2c0
From 80281e14e411e8e5fe4955effbb2c650a2f52667 Mon Sep 17 00:00:00 2001
308b2c0
From: Jarek Prokop <jprokop@redhat.com>
308b2c0
Date: Fri, 12 Jan 2024 18:33:34 +0100
308b2c0
Subject: [PATCH 2/2] aarch64: Prepend -mbranch-protection=standard option when
308b2c0
 checking branch protection.
308b2c0
308b2c0
Related Upstream issue: https://bugs.ruby-lang.org/issues/20154
308b2c0
---
308b2c0
 configure.ac | 2 +-
308b2c0
 1 file changed, 1 insertion(+), 1 deletion(-)
308b2c0
308b2c0
diff --git a/configure.ac b/configure.ac
308b2c0
index 18b4247991..5ea8ada8f7 100644
308b2c0
--- a/configure.ac
308b2c0
+++ b/configure.ac
308b2c0
@@ -827,7 +827,7 @@ AS_IF([test "$GCC" = yes], [
308b2c0
 
308b2c0
     # aarch64 branch protection
308b2c0
     AS_CASE(["$target_cpu"], [aarch64], [
308b2c0
-	AS_FOR(option, opt, [-mbranch-protection=pac-ret -msign-return-address=all], [
308b2c0
+	AS_FOR(option, opt, [-mbranch-protection=standard -mbranch-protection=pac-ret -msign-return-address=all], [
308b2c0
             RUBY_TRY_CFLAGS(option, [branch_protection=yes], [branch_protection=no])
308b2c0
             AS_IF([test "x$branch_protection" = xyes], [
308b2c0
                 # C compiler and assembler must be consistent for -mbranch-protection
308b2c0
-- 
308b2c0
2.43.0
308b2c0