summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremiah Gowdy <jeremiah@gowdy.me>2022-06-15 10:31:15 -0700
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-06-17 11:58:10 +0900
commitf3b54d5fc236d01c0e34650b797820e4b09e2a41 (patch)
tree4f7b834ccf6906416430a2db9458fd48ba9acb3b
parent2c190863239bee3f54cfb74b16bb6ea4cae6ed20 (diff)
Add branch protection to aarch64 targets
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6025
-rw-r--r--configure.ac14
1 files changed, 14 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 50ccc76504..ef3f521a6d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -780,6 +780,20 @@ AS_IF([test "$GCC" = yes], [
RUBY_APPEND_OPTION(LDFLAGS, $stack_protector)
])
+ # aarch64 branch protection
+ AS_CASE(["$target_cpu"], [aarch64], [
+ branch_protection=no
+ RUBY_TRY_CFLAGS(-mbranch-protection=pac-ret,[branch_protection=yes])
+ AS_IF([test "x$branch_protection" = xyes], [
+ RUBY_APPEND_OPTION(XCFLAGS, -mbranch-protection=pac-ret)
+ ],
+ [
+ RUBY_TRY_CFLAGS(-msign-return-address=all, [
+ RUBY_APPEND_OPTION(XCFLAGS, -msign-return-address=all)
+ ])
+ ])
+ ])
+
AS_CASE("${compress_debug_sections:-zlib}",
[none|no], [], [
RUBY_TRY_LDFLAGS(${linker_flag}--compress-debug-sections=${compress_debug_sections:-zlib},