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 <botca...@adacore.com> * config/rs6000/vxworks.h (RS6000_STARTING_FRAME_OFFSET): Define, accounting for STACK_BOUNDARY 128. (STACK_DYNAMIC_OFFSET): Likewise.
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 { \