Skip to content

Commit b940de8

Browse files
Revert autoconf macros defining RUBY_AARCH64_{BTI|PAC}_ENABLED
This partially reverts ruby#10944; now that we decided to pass CFLAGS to $(CC) when assembling .S files, we don't need these autoconf macros that capture the state of __ARM_FEATURE{PAC|BTI}_DEFAULT. [Bug #20601]
1 parent b18701a commit b940de8

File tree

2 files changed

+10
-60
lines changed

2 files changed

+10
-60
lines changed

configure.ac

-52
Original file line numberDiff line numberDiff line change
@@ -1006,58 +1006,6 @@ AC_SUBST(incflags, "$INCFLAGS")
10061006
test -z "${ac_env_CFLAGS_set}" -a -n "${cflags+set}" && eval CFLAGS="\"$cflags $ARCH_FLAG\""
10071007
test -z "${ac_env_CXXFLAGS_set}" -a -n "${cxxflags+set}" && eval CXXFLAGS="\"$cxxflags $ARCH_FLAG\""
10081008

1009-
# The lines above expand out the $cflags/$optflags/$debugflags/$hardenflags variables into the
1010-
# CFLAGS variable. So, at this point, we have a $CFLAGS var with the actual compiler flags we're
1011-
# going to use.
1012-
# That means this is the right time to check what branch protection flags are going to be in use
1013-
# and define appropriate macros for use in Context.S based on this
1014-
AS_CASE(["$target_cpu"], [aarch64], [
1015-
AC_CACHE_CHECK([whether __ARM_FEATURE_BTI_DEFAULT is defined],
1016-
rb_cv_aarch64_bti_enabled,
1017-
AC_COMPILE_IFELSE(
1018-
[AC_LANG_PROGRAM([[
1019-
@%:@ifndef __ARM_FEATURE_BTI_DEFAULT
1020-
@%:@error "__ARM_FEATURE_BTI_DEFAULT not defined"
1021-
@%:@endif
1022-
]])],
1023-
[rb_cv_aarch64_bti_enabled=yes],
1024-
[rb_cv_aarch64_bti_enabled=no])
1025-
)
1026-
AS_IF([test "$rb_cv_aarch64_bti_enabled" = yes],
1027-
AC_DEFINE(RUBY_AARCH64_BTI_ENABLED, 1))
1028-
AC_CACHE_CHECK([whether __ARM_FEATURE_PAC_DEFAULT is defined],
1029-
rb_cv_aarch64_pac_enabled,
1030-
AC_COMPILE_IFELSE(
1031-
[AC_LANG_PROGRAM([[
1032-
@%:@ifndef __ARM_FEATURE_PAC_DEFAULT
1033-
@%:@error "__ARM_FEATURE_PAC_DEFAULT not defined"
1034-
@%:@endif
1035-
]])],
1036-
[rb_cv_aarch64_pac_enabled=yes],
1037-
[rb_cv_aarch64_pac_enabled=no])
1038-
)
1039-
AS_IF([test "$rb_cv_aarch64_pac_enabled" = yes],
1040-
AC_DEFINE(RUBY_AARCH64_PAC_ENABLED, 1))
1041-
# Context.S will only ever sign its return address with the A-key; it doesn't support
1042-
# the B-key at the moment.
1043-
AS_IF([test "$rb_cv_aarch64_pac_enabled" = yes], [
1044-
AC_CACHE_CHECK([whether __ARM_FEATURE_PAC_DEFAULT specifies the b-key bit 0x02],
1045-
rb_cv_aarch64_pac_b_key,
1046-
AC_COMPILE_IFELSE(
1047-
[AC_LANG_PROGRAM([[
1048-
@%:@ifdef __ARM_FEATURE_PAC_DEFAULT
1049-
@%:@if __ARM_FEATURE_PAC_DEFAULT & 0x02
1050-
@%:@error "__ARM_FEATURE_PAC_DEFAULT specifies B key"
1051-
@%:@endif
1052-
@%:@endif
1053-
]])],
1054-
[rb_cv_aarch64_pac_b_key=no],
1055-
[rb_cv_aarch64_pac_b_key=yes])
1056-
)
1057-
AS_IF([test "$rb_cv_aarch64_pac_b_key" = yes],
1058-
AC_MSG_ERROR(-mbranch-protection flag specified b-key but Ruby's Context.S does not support this yet.))
1059-
])
1060-
])
10611009

10621010
AC_CACHE_CHECK([whether compiler has statement and declarations in expressions],
10631011
rb_cv_have_stmt_and_decl_in_expr,

coroutine/arm64/Context.S

+10-8
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
## Copyright, 2018, by Samuel Williams.
66
##
77

8-
#include "ruby/config.h"
9-
108
#define TOKEN_PASTE(x,y) x##y
119
#define PREFIXED_SYMBOL(prefix,name) TOKEN_PASTE(prefix,name)
1210

@@ -20,6 +18,10 @@
2018
.align 2
2119
#endif
2220

21+
#if defined(__ARM_FEATURE_PAC_DEFAULT) && (__ARM_FEATURE_PAC_DEFAULT & 0x02) != 0
22+
# error "-mbranch-protection flag specified b-key but Context.S does not support this"
23+
#endif
24+
2325
## NOTE(PAC): Use we HINT mnemonics instead of PAC mnemonics to
2426
## keep compatibility with those assemblers that don't support PAC.
2527
##
@@ -29,10 +31,10 @@
2931
.global PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
3032
PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
3133

32-
#if defined(RUBY_AARCH64_PAC_ENABLED)
34+
#if defined(__ARM_FEATURE_PAC_DEFAULT) && (__ARM_FEATURE_PAC_DEFAULT != 0)
3335
# paciasp (it also acts as BTI landing pad, so no need to insert BTI also)
3436
hint #25
35-
#elif defined(RUBY_AARCH64_BTI_ENABLED)
37+
#elif defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT != 0)
3638
# For the case PAC is not enabled but BTI is.
3739
# bti c
3840
hint #34
@@ -75,7 +77,7 @@ PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
7577
# Pop stack frame
7678
add sp, sp, 0xa0
7779

78-
#if defined(RUBY_AARCH64_PAC_ENABLED)
80+
#if defined(__ARM_FEATURE_PAC_DEFAULT) && (__ARM_FEATURE_PAC_DEFAULT != 0)
7981
# autiasp: Authenticate x30 (LR) with SP and key A
8082
hint #29
8183
#endif
@@ -87,18 +89,18 @@ PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
8789
.section .note.GNU-stack,"",%progbits
8890
#endif
8991

90-
#if defined(RUBY_AARCH64_BTI_ENABLED) || defined(RUBY_AARCH64_PAC_ENABLED)
92+
#if (defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT != 0) || (defined(____ARM_FEATURE_PAC_DEFAULT) && __ARM_FEATURE_PAC_DEFAULT != 0)
9193
/* See "ELF for the Arm 64-bit Architecture (AArch64)"
9294
https://github.com/ARM-software/abi-aa/blob/2023Q3/aaelf64/aaelf64.rst#program-property */
9395
# define GNU_PROPERTY_AARCH64_FEATURE_1_BTI (1<<0)
9496
# define GNU_PROPERTY_AARCH64_FEATURE_1_PAC (1<<1)
9597

96-
# if defined(RUBY_AARCH64_BTI_ENABLED)
98+
# if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT != 0
9799
# define BTI_FLAG GNU_PROPERTY_AARCH64_FEATURE_1_BTI
98100
# else
99101
# define BTI_FLAG 0
100102
# endif
101-
# if defined(RUBY_AARCH64_PAC_ENABLED)
103+
# if defined(__ARM_FEATURE_PAC_DEFAULT) && __ARM_FEATURE_PAC_DEFAULT != 0
102104
# define PAC_FLAG GNU_PROPERTY_AARCH64_FEATURE_1_PAC
103105
# else
104106
# define PAC_FLAG 0

0 commit comments

Comments
 (0)