On Fri, Feb 2, 2018 at 9:57 AM, H.J. Lu <hjl.to...@gmail.com> wrote: > On Fri, Feb 2, 2018 at 9:53 AM, Eric Botcazou <ebotca...@adacore.com> wrote: >>> We currently read and write beyond the builtin jmpbuf on ILP32 targets >>> where Pmode == DImode and ptr_mode == SImode. Since the builtin jmpbuf >>> is an array of 5 pointers, ptr_mode should be used to save and restore >>> frame and program pointers. Since x86 only saves stack pointer in >>> stack save area, STACK_SAVEAREA_MODE should be ptr_mode, not Pmode. >> >> I think that some targets really need Pmode. And the buffer should be able >> to > > Some targets need more than Pmode. ia64/ia64.h has > > /* We need 32 bytes, so we can save the sp, ar.rnat, ar.bsp, and ar.pfs of > the function containing a non-local goto target. */ > > #define STACK_SAVEAREA_MODE(LEVEL) \ > ((LEVEL) == SAVE_NONLOCAL ? OImode : Pmode) > >> accomodate up to 5 words, see init_eh:
One more thing. Word can be bigger than pointer on ILP32 targets. 5 pointers aren't sufficient. >> /* Compute a minimally sized jump buffer. We need room to store at >> least 3 pointers - stack pointer, frame pointer and return address. >> Plus for some targets we need room for an extra pointer - in the >> case of MIPS this is the global pointer. This makes a total of four >> pointers, but to be safe we actually allocate room for 5. >> >> If pointers are smaller than words then we allocate enough room for >> 5 words, just in case the backend needs this much room. For more >> discussion on this issue see: >> http://gcc.gnu.org/ml/gcc-patches/2014-05/msg00313.html. */ >> if (POINTER_SIZE > BITS_PER_WORD) >> tmp = size_int (5 - 1); >> else >> tmp = size_int ((5 * BITS_PER_WORD / POINTER_SIZE) - 1); >> > > My only changes STACK_SAVEAREA_MODE for x86. Other targets > are unchanged. -- H.J.