Go to file
Tamar Christina 8c6e3b2355 Ensure that outgoing argument size is at least 8 bytes when alloca and stack-clash.
This patch adds a requirement that the number of outgoing arguments for a
function is at least 8 bytes when using stack-clash protection and alloca.

By using this condition we can avoid a check in the alloca code and so have
smaller and simpler code there.

A simplified version of the AArch64 stack frames is:

   +-----------------------+                                              
   |                       |                                                 
   |                       |                                              
   |                       |                                              
   +-----------------------+                                              
   |LR                     |                                              
   +-----------------------+                                              
   |FP                     |                                              
   +-----------------------+                                              
   |dynamic allocations    | ----  expanding area which will push the outgoing
   +-----------------------+       args down during each allocation.
   |padding                |
   +-----------------------+
   |outgoing stack args    | ---- safety buffer of 8 bytes (aligned)
   +-----------------------+

By always defining an outgoing argument, alloca(0) effectively is safe to probe
at $sp due to the reserved buffer being there.  It will never corrupt the stack.

This is also safe for alloca(x) where x is 0 or x % page_size == 0.  In the
former it is the same case as alloca(0) while the latter is safe because any
allocation pushes the outgoing stack args down:

   |FP                     |                                              
   +-----------------------+                                              
   |                       |
   |dynamic allocations    | ----  alloca (x)
   |                       |
   +-----------------------+
   |padding                |
   +-----------------------+
   |outgoing stack args    | ---- safety buffer of 8 bytes (aligned)
   +-----------------------+

Which means when you probe for the residual, if it's 0 you'll again just probe
in the outgoing stack args range, which we know is non-zero (at least 8 bytes).

gcc/

	PR target/86486
	* config/aarch64/aarch64.h (STACK_CLASH_MIN_BYTES_OUTGOING_ARGS,
	STACK_DYNAMIC_OFFSET): New.
	* config/aarch64/aarch64.c (aarch64_layout_frame):
	Update outgoing args size.
	(aarch64_stack_clash_protection_alloca_probe_range,
	TARGET_STACK_CLASH_PROTECTION_ALLOCA_PROBE_RANGE): New.

gcc/testsuite/

	PR target/86486
	* gcc.target/aarch64/stack-check-alloca-1.c: New.
	* gcc.target/aarch64/stack-check-alloca-10.c: New.
	* gcc.target/aarch64/stack-check-alloca-2.c: New.
	* gcc.target/aarch64/stack-check-alloca-3.c: New.
	* gcc.target/aarch64/stack-check-alloca-4.c: New.
	* gcc.target/aarch64/stack-check-alloca-5.c: New.
	* gcc.target/aarch64/stack-check-alloca-6.c: New.
	* gcc.target/aarch64/stack-check-alloca-7.c: New.
	* gcc.target/aarch64/stack-check-alloca-8.c: New.
	* gcc.target/aarch64/stack-check-alloca-9.c: New.
	* gcc.target/aarch64/stack-check-alloca.h: New.
	* gcc.target/aarch64/stack-check-14.c: New.
	* gcc.target/aarch64/stack-check-15.c: New.

From-SVN: r264751
2018-10-01 13:00:58 +00:00
config Replace 8 spaces with a tabular in ChangeLog files. 2018-08-27 14:04:23 +00:00
contrib Add filter-rtags-warnings.py script. 2018-09-25 07:12:52 +00:00
fixincludes fixincludes: vxworks: remove unnecessary parentheses in ioctl wrapper macro 2018-09-03 13:26:45 +00:00
gcc Ensure that outgoing argument size is at least 8 bytes when alloca and stack-clash. 2018-10-01 13:00:58 +00:00
gnattools Update copyright years. 2018-01-03 11:03:58 +01:00
gotools Ignore chmod errors during mostlyclean-local, check-go-tool 2018-09-26 12:56:09 +00:00
include Replace 8 spaces with a tabular in ChangeLog files. 2018-08-27 14:04:23 +00:00
INSTALL
intl libgnuintl.h (_INTL_MAY_RETURN_STRING_ARG, [...]): Backport changes from upstream gettext. 2018-09-18 22:08:49 -06:00
libada Replace 8 spaces with a tabular in ChangeLog files. 2018-08-27 14:04:23 +00:00
libatomic Replace 8 spaces with a tabular in ChangeLog files. 2018-08-27 14:04:23 +00:00
libbacktrace Replace 8 spaces with a tabular in ChangeLog files. 2018-08-27 14:04:23 +00:00
libcc1 PR c++/69560 - wrong alignof(double) on x86. 2018-04-23 16:49:38 -04:00
libcpp Add range_idx param to range_label::get_text 2018-09-17 23:32:12 +00:00
libdecnumber Replace 8 spaces with a tabular in ChangeLog files. 2018-08-27 14:04:23 +00:00
libffi Replace 8 spaces with a tabular in ChangeLog files. 2018-08-27 14:04:23 +00:00
libgcc crtprec.c (set_precision): Use fnstcw instead of fstcw. 2018-09-26 17:25:15 +02:00
libgfortran Use vectored writes when reporting errors and warnings. 2018-09-21 21:12:59 +03:00
libgo syscall: don't assume we have a GETEUID system call 2018-09-26 15:17:30 +00:00
libgomp [nvptx] Remove use of CUDA unified memory in libgomp 2018-09-18 08:41:54 -07:00
libhsail-rt [BRIGFE] phsa-specific optimizations 2018-05-04 19:43:57 +00:00
libiberty Replace 8 spaces with a tabular in ChangeLog files. 2018-08-27 14:04:23 +00:00
libitm Remove nfs bogon 2018-08-03 14:53:48 -06:00
libobjc Replace 8 spaces with a tabular in ChangeLog files. 2018-08-27 14:04:23 +00:00
liboffloadmic re PR jit/85384 (libgccjit does not work if --with-gcc-major-version is used) 2018-04-18 11:46:58 +02:00
libquadmath Regenerate configure of target libraries 2018-04-24 09:45:26 -07:00
libsanitizer Replace 8 spaces with a tabular in ChangeLog files. 2018-08-27 14:04:23 +00:00
libssp Replace 8 spaces with a tabular in ChangeLog files. 2018-08-27 14:04:23 +00:00
libstdc++-v3 messages.xml: Switch link to www.oracle.com to https. 2018-09-30 11:41:31 +00:00
libvtv Replace 8 spaces with a tabular in ChangeLog files. 2018-08-27 14:04:23 +00:00
lto-plugin Replace 8 spaces with a tabular in ChangeLog files. 2018-08-27 14:04:23 +00:00
maintainer-scripts re PR other/85622 (gcc-8.1.0/NEWS says it's not released yet) 2018-05-03 11:29:39 +02:00
zlib Allow building of the zlib component when the building takes place in the source directory. 2018-06-19 11:49:08 +00:00
.dir-locals.el
.gitattributes add basic .gitattributes files to notice whitespace issues 2016-04-23 02:37:43 +00:00
.gitignore .gitignore: Ignore in-tree prerequisites. 2016-09-09 17:20:55 -04:00
ABOUT-NLS
ChangeLog Add self to maintainers list. 2018-09-13 16:11:29 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in config-ml.in: Remove references to GCJ. 2016-11-15 16:34:02 +00:00
config.guess Update config.guess and config.sub 2018-07-06 05:57:35 +00:00
config.rpath
config.sub Update config.sub 2018-07-06 06:22:08 +00:00
configure Introduce @unless/@endunless and postbootstrap Makefile targets 2018-06-30 02:47:29 +00:00
configure.ac Introduce @unless/@endunless and postbootstrap Makefile targets 2018-06-30 02:47:29 +00:00
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.RUNTIME
depcomp
install-sh
libtool-ldflags
libtool.m4 libtool.m4: Sort output of 'find' to enable deterministic builds. 2018-07-05 13:13:45 -06:00
lt~obsolete.m4
ltgcc.m4
ltmain.sh libtool.m4: Sort output of 'find' to enable deterministic builds. 2018-07-05 13:13:45 -06:00
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS Add self to maintainers list. 2018-09-13 16:11:29 +00:00
Makefile.def Makefile.def (fortran): Add check-target-libgomp-fortran. 2018-06-18 22:01:58 +00:00
Makefile.in Introduce @unless/@endunless and postbootstrap Makefile targets 2018-06-30 02:47:29 +00:00
Makefile.tpl Introduce @unless/@endunless and postbootstrap Makefile targets 2018-06-30 02:47:29 +00:00
missing
mkdep
mkinstalldirs
move-if-change
README
symlink-tree
ylwrap

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.