Commit 630b1e3a by Tamar Christina Committed by Tamar Christina

Allow setting of stack-clash via configure options.

This patch defines a configure option to allow the setting of the default
guard size via configure flags when building the target.

The new flag is:

 * --with-stack-clash-protection-guard-size=<num>

The patch defines a new macro DEFAULT_STK_CLASH_GUARD_SIZE which targets need
to use explicitly is they want to support this configure flag and values that
users may have set.

gcc/

	PR target/86486
	* configure.ac: Add stack-clash-protection-guard-size.
	* doc/install.texi: Document it.
	* config.in (DEFAULT_STK_CLASH_GUARD_SIZE): New.
	* params.def: Update comment for guard-size.
	(PARAM_STACK_CLASH_PROTECTION_GUARD_SIZE,
	PARAM_STACK_CLASH_PROTECTION_PROBE_INTERVAL): Update description.
	* configure: Regenerate.

From-SVN: r264752
parent 8c6e3b23
2018-10-01 Tamar Christina <tamar.christina@arm.com> 2018-10-01 Tamar Christina <tamar.christina@arm.com>
PR target/86486 PR target/86486
* configure.ac: Add stack-clash-protection-guard-size.
* doc/install.texi: Document it.
* config.in (DEFAULT_STK_CLASH_GUARD_SIZE): New.
* params.def: Update comment for guard-size.
(PARAM_STACK_CLASH_PROTECTION_GUARD_SIZE,
PARAM_STACK_CLASH_PROTECTION_PROBE_INTERVAL): Update description.
* configure: Regenerate.
2018-10-01 Tamar Christina <tamar.christina@arm.com>
PR target/86486
* config/aarch64/aarch64.h (STACK_CLASH_MIN_BYTES_OUTGOING_ARGS, * config/aarch64/aarch64.h (STACK_CLASH_MIN_BYTES_OUTGOING_ARGS,
STACK_DYNAMIC_OFFSET): New. STACK_DYNAMIC_OFFSET): New.
* config/aarch64/aarch64.c (aarch64_layout_frame): * config/aarch64/aarch64.c (aarch64_layout_frame):
...@@ -55,6 +55,13 @@ ...@@ -55,6 +55,13 @@
#endif #endif
/* Define to larger than zero set to the default stack clash protector size as
a power of two in bytes. */
#ifndef USED_FOR_TARGET
#undef DEFAULT_STK_CLASH_GUARD_SIZE
#endif
/* Define if you want to use __cxa_atexit, rather than atexit, to register C++ /* Define if you want to use __cxa_atexit, rather than atexit, to register C++
destructors for local statics and global objects. This is essential for destructors for local statics and global objects. This is essential for
fully standards-compliant handling of destructors, but requires fully standards-compliant handling of destructors, but requires
......
...@@ -906,6 +906,7 @@ enable_valgrind_annotations ...@@ -906,6 +906,7 @@ enable_valgrind_annotations
with_stabs with_stabs
enable_multilib enable_multilib
enable_multiarch enable_multiarch
with_stack_clash_protection_guard_size
enable___cxa_atexit enable___cxa_atexit
enable_decimal_float enable_decimal_float
enable_fixed_point enable_fixed_point
...@@ -1727,6 +1728,9 @@ Optional Packages: ...@@ -1727,6 +1728,9 @@ Optional Packages:
--with-gnu-as arrange to work with GNU as --with-gnu-as arrange to work with GNU as
--with-as arrange to use the specified as (full pathname) --with-as arrange to use the specified as (full pathname)
--with-stabs arrange to use stabs instead of host debug format --with-stabs arrange to use stabs instead of host debug format
--with-stack-clash-protection-guard-size=size
Set the default stack clash protection guard size
for specific targets as a power of two in bytes.
--with-dwarf2 force the default debug format to be DWARF 2 --with-dwarf2 force the default debug format to be DWARF 2
--with-specs=SPECS add SPECS to driver command-line processing --with-specs=SPECS add SPECS to driver command-line processing
--with-pkgversion=PKG Use PKG in the version string in place of "GCC" --with-pkgversion=PKG Use PKG in the version string in place of "GCC"
...@@ -7439,6 +7443,34 @@ $as_echo "$enable_multiarch$ma_msg_suffix" >&6; } ...@@ -7439,6 +7443,34 @@ $as_echo "$enable_multiarch$ma_msg_suffix" >&6; }
# default stack clash protection guard size as power of twos in bytes.
# Please keep these in sync with params.def.
stk_clash_min=12
stk_clash_max=30
# Keep the default value when the option is not used to 0, this allows us to
# distinguish between the cases where the user specifially set a value via
# configure and when the normal default value is used.
# Check whether --with-stack-clash-protection-guard-size was given.
if test "${with_stack_clash_protection_guard_size+set}" = set; then :
withval=$with_stack_clash_protection_guard_size; DEFAULT_STK_CLASH_GUARD_SIZE="$with_stack_clash_protection_guard_size"
else
DEFAULT_STK_CLASH_GUARD_SIZE=0
fi
if test $DEFAULT_STK_CLASH_GUARD_SIZE -ne 0 \
&& (test $DEFAULT_STK_CLASH_GUARD_SIZE -lt $stk_clash_min \
|| test $DEFAULT_STK_CLASH_GUARD_SIZE -gt $stk_clash_max); then
as_fn_error "Invalid value $DEFAULT_STK_CLASH_GUARD_SIZE for --with-stack-clash-protection-guard-size. Must be between $stk_clash_min and $stk_clash_max." "$LINENO" 5
fi
cat >>confdefs.h <<_ACEOF
#define DEFAULT_STK_CLASH_GUARD_SIZE $DEFAULT_STK_CLASH_GUARD_SIZE
_ACEOF
# Enable __cxa_atexit for C++. # Enable __cxa_atexit for C++.
# Check whether --enable-__cxa_atexit was given. # Check whether --enable-__cxa_atexit was given.
if test "${enable___cxa_atexit+set}" = set; then : if test "${enable___cxa_atexit+set}" = set; then :
...@@ -18463,7 +18495,7 @@ else ...@@ -18463,7 +18495,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF cat > conftest.$ac_ext <<_LT_EOF
#line 18466 "configure" #line 18498 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H
...@@ -18569,7 +18601,7 @@ else ...@@ -18569,7 +18601,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF cat > conftest.$ac_ext <<_LT_EOF
#line 18572 "configure" #line 18604 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H
......
...@@ -811,6 +811,29 @@ AC_MSG_RESULT($enable_multiarch$ma_msg_suffix) ...@@ -811,6 +811,29 @@ AC_MSG_RESULT($enable_multiarch$ma_msg_suffix)
AC_SUBST(with_cpu) AC_SUBST(with_cpu)
AC_SUBST(with_float) AC_SUBST(with_float)
# default stack clash protection guard size as power of twos in bytes.
# Please keep these in sync with params.def.
stk_clash_min=12
stk_clash_max=30
# Keep the default value when the option is not used to 0, this allows us to
# distinguish between the cases where the user specifially set a value via
# configure and when the normal default value is used.
AC_ARG_WITH(stack-clash-protection-guard-size,
[AS_HELP_STRING([--with-stack-clash-protection-guard-size=size],
[Set the default stack clash protection guard size for specific targets as a power of two in bytes.])],
[DEFAULT_STK_CLASH_GUARD_SIZE="$with_stack_clash_protection_guard_size"], [DEFAULT_STK_CLASH_GUARD_SIZE=0])
if test $DEFAULT_STK_CLASH_GUARD_SIZE -ne 0 \
&& (test $DEFAULT_STK_CLASH_GUARD_SIZE -lt $stk_clash_min \
|| test $DEFAULT_STK_CLASH_GUARD_SIZE -gt $stk_clash_max); then
AC_MSG_ERROR(m4_normalize([
Invalid value $DEFAULT_STK_CLASH_GUARD_SIZE for --with-stack-clash-protection-guard-size. \
Must be between $stk_clash_min and $stk_clash_max.]))
fi
AC_DEFINE_UNQUOTED(DEFAULT_STK_CLASH_GUARD_SIZE, $DEFAULT_STK_CLASH_GUARD_SIZE,
[Define to larger than zero set the default stack clash protector size.])
# Enable __cxa_atexit for C++. # Enable __cxa_atexit for C++.
AC_ARG_ENABLE(__cxa_atexit, AC_ARG_ENABLE(__cxa_atexit,
[AS_HELP_STRING([--enable-__cxa_atexit], [enable __cxa_atexit for C++])], [AS_HELP_STRING([--enable-__cxa_atexit], [enable __cxa_atexit for C++])],
......
...@@ -1414,6 +1414,11 @@ These features are extensions to the traditional ...@@ -1414,6 +1414,11 @@ These features are extensions to the traditional
SVR4-based MIPS ABIs and require support from GNU binutils SVR4-based MIPS ABIs and require support from GNU binutils
and the runtime C library. and the runtime C library.
@item --with-stack-clash-protection-guard-size=@var{size}
On certain targets this option sets the default stack clash protection guard
size as a power of two in bytes. On AArch64 @var{size} is required to be either
12 (4KB) or 16 (64KB).
@item --enable-__cxa_atexit @item --enable-__cxa_atexit
Define if you want to use __cxa_atexit, rather than atexit, to Define if you want to use __cxa_atexit, rather than atexit, to
register C++ destructors for local statics and global objects. register C++ destructors for local statics and global objects.
......
...@@ -213,14 +213,15 @@ DEFPARAM(PARAM_STACK_FRAME_GROWTH, ...@@ -213,14 +213,15 @@ DEFPARAM(PARAM_STACK_FRAME_GROWTH,
"Maximal stack frame growth due to inlining (in percent).", "Maximal stack frame growth due to inlining (in percent).",
1000, 0, 0) 1000, 0, 0)
/* Keep these up to date with those in configure.ac. */
DEFPARAM(PARAM_STACK_CLASH_PROTECTION_GUARD_SIZE, DEFPARAM(PARAM_STACK_CLASH_PROTECTION_GUARD_SIZE,
"stack-clash-protection-guard-size", "stack-clash-protection-guard-size",
"Size of the stack guard expressed as a power of two.", "Size of the stack guard expressed as a power of two in bytes.",
12, 12, 30) 12, 12, 30)
DEFPARAM(PARAM_STACK_CLASH_PROTECTION_PROBE_INTERVAL, DEFPARAM(PARAM_STACK_CLASH_PROTECTION_PROBE_INTERVAL,
"stack-clash-protection-probe-interval", "stack-clash-protection-probe-interval",
"Interval in which to probe the stack expressed as a power of two.", "Interval in which to probe the stack expressed as a power of two in bytes.",
12, 10, 16) 12, 10, 16)
/* The GCSE optimization will be disabled if it would require /* The GCSE optimization will be disabled if it would require
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment