Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [commit] Respect "red zone" for SPU inferior calls
@ 2008-08-06 18:31 Ulrich Weigand
  2008-08-06 19:15 ` Mark Kettenis
  0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Weigand @ 2008-08-06 18:31 UTC (permalink / raw)
  To: gdb-patches

Hello,

GDB neglected to respect the ABI-defined "red zone" of 2000 bytes on the SPU,
which could cause stack corruption when calling an inferior function while
within prologue code of another function.  Fixed by the patch below.  

Tested on spu-elf with no regressions, applied to mainline.

Bye,
Ulrich


ChangeLog:

	* spu-tdep.c (spu_gdbarch_init): Call set_gdbarch_frame_red_zone_size.

Index: gdb/spu-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/spu-tdep.c,v
retrieving revision 1.31
diff -c -p -r1.31 spu-tdep.c
*** gdb/spu-tdep.c	12 Jul 2008 22:42:52 -0000	1.31
--- gdb/spu-tdep.c	6 Aug 2008 18:25:35 -0000
*************** spu_gdbarch_init (struct gdbarch_info in
*** 2043,2048 ****
--- 2043,2049 ----
    /* Inferior function calls.  */
    set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
    set_gdbarch_frame_align (gdbarch, spu_frame_align);
+   set_gdbarch_frame_red_zone_size (gdbarch, 2000);
    set_gdbarch_push_dummy_call (gdbarch, spu_push_dummy_call);
    set_gdbarch_dummy_id (gdbarch, spu_dummy_id);
    set_gdbarch_return_value (gdbarch, spu_return_value);
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [commit] Respect "red zone" for SPU inferior calls
  2008-08-06 18:31 [commit] Respect "red zone" for SPU inferior calls Ulrich Weigand
@ 2008-08-06 19:15 ` Mark Kettenis
  2008-08-06 20:13   ` Ulrich Weigand
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Kettenis @ 2008-08-06 19:15 UTC (permalink / raw)
  To: uweigand; +Cc: gdb-patches

> Date: Wed, 6 Aug 2008 20:29:28 +0200 (CEST)
> From: "Ulrich Weigand" <uweigand@de.ibm.com>
> 
> Hello,
> 
> GDB neglected to respect the ABI-defined "red zone" of 2000 bytes on the SPU,
> which could cause stack corruption when calling an inferior function while
> within prologue code of another function.  Fixed by the patch below.

Do I read that right, is that reallu *decimal* 2000?  Seems a bit ood
to me.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [commit] Respect "red zone" for SPU inferior calls
  2008-08-06 19:15 ` Mark Kettenis
@ 2008-08-06 20:13   ` Ulrich Weigand
  0 siblings, 0 replies; 3+ messages in thread
From: Ulrich Weigand @ 2008-08-06 20:13 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

Mark Kettenis wrote:

> > From: "Ulrich Weigand" <uweigand@de.ibm.com>
> > GDB neglected to respect the ABI-defined "red zone" of 2000 bytes on the SPU,
> > which could cause stack corruption when calling an inferior function while
> > within prologue code of another function.  Fixed by the patch below.
> 
> Do I read that right, is that reallu *decimal* 2000?  Seems a bit ood
> to me.

It may be odd, but this is indeed what the ABI specifies:
http://www-01.ibm.com/chips/techlib/techlib.nsf/techdocs/02E544E65760B0BF87257060006F8F20/$file/SPU_ABI-Specification_1.8.pdf

  "Storing to memory using the stack pointer plus an offset must never be
   done with an offset less than -2000 (-125*16). This allows interrupt
   handlers to use the application stack by first adding -2000 to the
   stack pointer."   (p. 9)

This also agrees with what GCC implements.

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-08-06 20:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-06 18:31 [commit] Respect "red zone" for SPU inferior calls Ulrich Weigand
2008-08-06 19:15 ` Mark Kettenis
2008-08-06 20:13   ` Ulrich Weigand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox