* Fix alignment of dynamically allocated stack areas on ppc-vxworks
@ 2018-12-11 14:52 Olivier Hainque
0 siblings, 0 replies; only message in thread
From: Olivier Hainque @ 2018-12-11 14:52 UTC (permalink / raw)
To: GCC Patches; +Cc: Olivier Hainque, Eric Botcazou
[-- Attachment #1: Type: text/plain, Size: 816 bytes --]
Hello,
The attached patch, provided by Eric Botcazou (thanks!), installs
definitions of RS6000_STARTING_FRAME_OFFSET and STACK_DYNAMIC_OFFSET
for PowerPC VxWorks, which has STACK_BOUNDARY set to 128
unconditionally.
AFAICS, this is the third OS config file doing this, after Darwin
and AIX. It seems like we could (should ?) account for STACK_BOUNDARY
or maybe PREFERRED_STACK_BOUNDARY in the common rs6000.h definition.
We have tested this successfully with a gcc-8 based compiler for
powerpc-wrs-vxworks, where this fixes SEGVs observed on Ada programs
performing dynamic stack allocations.
With Kind Regards,
Olivier
2018-12-11 Eric Botcazou <botcazou@adacore.com>
* config/rs6000/vxworks.h (RS6000_STARTING_FRAME_OFFSET): Define,
accounting for STACK_BOUNDARY 128.
(STACK_DYNAMIC_OFFSET): Likewise.
[-- Attachment #2: alloca-align-ppc-vxw.txt --]
[-- Type: text/plain, Size: 2232 bytes --]
diff --git a/gcc/config/rs6000/vxworks.h b/gcc/config/rs6000/vxworks.h
index d2033f6..24fe9ba 100644
--- a/gcc/config/rs6000/vxworks.h
+++ b/gcc/config/rs6000/vxworks.h
@@ -116,7 +116,7 @@ VXWORKS_ADDITIONAL_CPP_SPEC
#undef SDATA_DEFAULT_SIZE
#define SDATA_DEFAULT_SIZE (TARGET_VXWORKS_RTP ? 8 : 0)
-/* Enforce 16bytes alignment for the stack pointer, to permit general
+/* Enforce 16-byte alignment for the stack pointer, to permit general
compliance with e.g. Altivec instructions requirements. Make sure
this isn't overruled by the EABI constraints. */
@@ -128,6 +128,40 @@ VXWORKS_ADDITIONAL_CPP_SPEC
#undef ABI_STACK_BOUNDARY
+/* Offset within stack frame to start allocating local variables at.
+ If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
+ first local allocated. Otherwise, it is the offset to the BEGINNING
+ of the first local allocated.
+
+ On the RS/6000, the frame pointer is the same as the stack pointer,
+ except for dynamic allocations. So we start after the fixed area and
+ outgoing parameter area.
+
+ If the function uses dynamic stack space (CALLS_ALLOCA is set), that
+ space needs to be aligned to STACK_BOUNDARY, i.e. the sum of the
+ sizes of the fixed area and the parameter area must be a multiple of
+ STACK_BOUNDARY. */
+
+#undef RS6000_STARTING_FRAME_OFFSET
+#define RS6000_STARTING_FRAME_OFFSET \
+ (cfun->calls_alloca \
+ ? RS6000_ALIGN (crtl->outgoing_args_size + RS6000_SAVE_AREA, 16) \
+ : (RS6000_ALIGN (crtl->outgoing_args_size, 16) + RS6000_SAVE_AREA))
+
+/* Offset from the stack pointer register to an item dynamically
+ allocated on the stack, e.g., by `alloca'.
+
+ The default value for this macro is `STACK_POINTER_OFFSET' plus the
+ length of the outgoing arguments. The default is correct for most
+ machines. See `function.c' for details.
+
+ This value must be a multiple of STACK_BOUNDARY (hard coded in
+ `emit-rtl.c'). */
+#undef STACK_DYNAMIC_OFFSET
+#define STACK_DYNAMIC_OFFSET(FUNDECL) \
+ RS6000_ALIGN (crtl->outgoing_args_size.to_constant () \
+ + STACK_POINTER_OFFSET, 16)
+
#undef SUBSUBTARGET_OVERRIDE_OPTIONS
#define SUBSUBTARGET_OVERRIDE_OPTIONS \
do { \
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-12-11 14:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-11 14:52 Fix alignment of dynamically allocated stack areas on ppc-vxworks Olivier Hainque
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).