зеркало из https://github.com/github/ruby.git
Revert autoconf macros defining RUBY_AARCH64_{BTI|PAC}_ENABLED
This partially reverts https://github.com/ruby/ruby/pull/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]
This commit is contained in:
Родитель
b18701a7ae
Коммит
b940de83de
52
configure.ac
52
configure.ac
|
@ -1006,58 +1006,6 @@ AC_SUBST(incflags, "$INCFLAGS")
|
|||
test -z "${ac_env_CFLAGS_set}" -a -n "${cflags+set}" && eval CFLAGS="\"$cflags $ARCH_FLAG\""
|
||||
test -z "${ac_env_CXXFLAGS_set}" -a -n "${cxxflags+set}" && eval CXXFLAGS="\"$cxxflags $ARCH_FLAG\""
|
||||
|
||||
# The lines above expand out the $cflags/$optflags/$debugflags/$hardenflags variables into the
|
||||
# CFLAGS variable. So, at this point, we have a $CFLAGS var with the actual compiler flags we're
|
||||
# going to use.
|
||||
# That means this is the right time to check what branch protection flags are going to be in use
|
||||
# and define appropriate macros for use in Context.S based on this
|
||||
AS_CASE(["$target_cpu"], [aarch64], [
|
||||
AC_CACHE_CHECK([whether __ARM_FEATURE_BTI_DEFAULT is defined],
|
||||
rb_cv_aarch64_bti_enabled,
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([[
|
||||
@%:@ifndef __ARM_FEATURE_BTI_DEFAULT
|
||||
@%:@error "__ARM_FEATURE_BTI_DEFAULT not defined"
|
||||
@%:@endif
|
||||
]])],
|
||||
[rb_cv_aarch64_bti_enabled=yes],
|
||||
[rb_cv_aarch64_bti_enabled=no])
|
||||
)
|
||||
AS_IF([test "$rb_cv_aarch64_bti_enabled" = yes],
|
||||
AC_DEFINE(RUBY_AARCH64_BTI_ENABLED, 1))
|
||||
AC_CACHE_CHECK([whether __ARM_FEATURE_PAC_DEFAULT is defined],
|
||||
rb_cv_aarch64_pac_enabled,
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([[
|
||||
@%:@ifndef __ARM_FEATURE_PAC_DEFAULT
|
||||
@%:@error "__ARM_FEATURE_PAC_DEFAULT not defined"
|
||||
@%:@endif
|
||||
]])],
|
||||
[rb_cv_aarch64_pac_enabled=yes],
|
||||
[rb_cv_aarch64_pac_enabled=no])
|
||||
)
|
||||
AS_IF([test "$rb_cv_aarch64_pac_enabled" = yes],
|
||||
AC_DEFINE(RUBY_AARCH64_PAC_ENABLED, 1))
|
||||
# Context.S will only ever sign its return address with the A-key; it doesn't support
|
||||
# the B-key at the moment.
|
||||
AS_IF([test "$rb_cv_aarch64_pac_enabled" = yes], [
|
||||
AC_CACHE_CHECK([whether __ARM_FEATURE_PAC_DEFAULT specifies the b-key bit 0x02],
|
||||
rb_cv_aarch64_pac_b_key,
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([[
|
||||
@%:@ifdef __ARM_FEATURE_PAC_DEFAULT
|
||||
@%:@if __ARM_FEATURE_PAC_DEFAULT & 0x02
|
||||
@%:@error "__ARM_FEATURE_PAC_DEFAULT specifies B key"
|
||||
@%:@endif
|
||||
@%:@endif
|
||||
]])],
|
||||
[rb_cv_aarch64_pac_b_key=no],
|
||||
[rb_cv_aarch64_pac_b_key=yes])
|
||||
)
|
||||
AS_IF([test "$rb_cv_aarch64_pac_b_key" = yes],
|
||||
AC_MSG_ERROR(-mbranch-protection flag specified b-key but Ruby's Context.S does not support this yet.))
|
||||
])
|
||||
])
|
||||
|
||||
AC_CACHE_CHECK([whether compiler has statement and declarations in expressions],
|
||||
rb_cv_have_stmt_and_decl_in_expr,
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
## Copyright, 2018, by Samuel Williams.
|
||||
##
|
||||
|
||||
#include "ruby/config.h"
|
||||
|
||||
#define TOKEN_PASTE(x,y) x##y
|
||||
#define PREFIXED_SYMBOL(prefix,name) TOKEN_PASTE(prefix,name)
|
||||
|
||||
|
@ -20,6 +18,10 @@
|
|||
.align 2
|
||||
#endif
|
||||
|
||||
#if defined(__ARM_FEATURE_PAC_DEFAULT) && (__ARM_FEATURE_PAC_DEFAULT & 0x02) != 0
|
||||
# error "-mbranch-protection flag specified b-key but Context.S does not support this"
|
||||
#endif
|
||||
|
||||
## NOTE(PAC): Use we HINT mnemonics instead of PAC mnemonics to
|
||||
## keep compatibility with those assemblers that don't support PAC.
|
||||
##
|
||||
|
@ -29,10 +31,10 @@
|
|||
.global PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
|
||||
PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
|
||||
|
||||
#if defined(RUBY_AARCH64_PAC_ENABLED)
|
||||
#if defined(__ARM_FEATURE_PAC_DEFAULT) && (__ARM_FEATURE_PAC_DEFAULT != 0)
|
||||
# paciasp (it also acts as BTI landing pad, so no need to insert BTI also)
|
||||
hint #25
|
||||
#elif defined(RUBY_AARCH64_BTI_ENABLED)
|
||||
#elif defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT != 0)
|
||||
# For the case PAC is not enabled but BTI is.
|
||||
# bti c
|
||||
hint #34
|
||||
|
@ -75,7 +77,7 @@ PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
|
|||
# Pop stack frame
|
||||
add sp, sp, 0xa0
|
||||
|
||||
#if defined(RUBY_AARCH64_PAC_ENABLED)
|
||||
#if defined(__ARM_FEATURE_PAC_DEFAULT) && (__ARM_FEATURE_PAC_DEFAULT != 0)
|
||||
# autiasp: Authenticate x30 (LR) with SP and key A
|
||||
hint #29
|
||||
#endif
|
||||
|
@ -87,18 +89,18 @@ PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
|
|||
.section .note.GNU-stack,"",%progbits
|
||||
#endif
|
||||
|
||||
#if defined(RUBY_AARCH64_BTI_ENABLED) || defined(RUBY_AARCH64_PAC_ENABLED)
|
||||
#if (defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT != 0) || (defined(____ARM_FEATURE_PAC_DEFAULT) && __ARM_FEATURE_PAC_DEFAULT != 0)
|
||||
/* See "ELF for the Arm 64-bit Architecture (AArch64)"
|
||||
https://github.com/ARM-software/abi-aa/blob/2023Q3/aaelf64/aaelf64.rst#program-property */
|
||||
# define GNU_PROPERTY_AARCH64_FEATURE_1_BTI (1<<0)
|
||||
# define GNU_PROPERTY_AARCH64_FEATURE_1_PAC (1<<1)
|
||||
|
||||
# if defined(RUBY_AARCH64_BTI_ENABLED)
|
||||
# if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT != 0
|
||||
# define BTI_FLAG GNU_PROPERTY_AARCH64_FEATURE_1_BTI
|
||||
# else
|
||||
# define BTI_FLAG 0
|
||||
# endif
|
||||
# if defined(RUBY_AARCH64_PAC_ENABLED)
|
||||
# if defined(__ARM_FEATURE_PAC_DEFAULT) && __ARM_FEATURE_PAC_DEFAULT != 0
|
||||
# define PAC_FLAG GNU_PROPERTY_AARCH64_FEATURE_1_PAC
|
||||
# else
|
||||
# define PAC_FLAG 0
|
||||
|
|
Загрузка…
Ссылка в новой задаче