Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Skip the "red zone" on AMD64
@ 2003-08-07 11:05 Michal Ludvig
  2003-08-07 11:18 ` Andreas Schwab
  0 siblings, 1 reply; 6+ messages in thread
From: Michal Ludvig @ 2003-08-07 11:05 UTC (permalink / raw)
  To: GDB Patches

[-- Attachment #1: Type: text/plain, Size: 550 bytes --]

Hi all,
this simple patch skips the "red zone" before pushing anything to the 
stack when calling functions from the GDB prompt. If the red zone isn't 
skipped than local variables, etc. could be overwritten by called 
function parameters or return address.

This is pretty obvious patch that doesn't harm anything, but anyway - OK 
to apply?

2003-08-07  Michal Ludvig  <mludvig@suse.cz>
	* x86-64-tdep.c (x86_64_push_arguments): Skip the red zone.

Michal Ludvig
-- 
* SuSE CR, s.r.o     * mludvig@suse.cz
* (+420) 296.545.373 * http://www.suse.cz

[-- Attachment #2: redzone-1.diff --]
[-- Type: text/plain, Size: 839 bytes --]

Index: x86-64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-tdep.c,v
retrieving revision 1.79.2.5
diff -u -p -r1.79.2.5 x86-64-tdep.c
--- x86-64-tdep.c	7 Aug 2003 08:09:22 -0000	1.79.2.5
+++ x86-64-tdep.c	7 Aug 2003 10:56:29 -0000
@@ -624,6 +624,14 @@ x86_64_push_arguments (struct regcache *
   int stack_values_count = 0;
   int *stack_values;
   stack_values = alloca (nargs * sizeof (int));
+
+  /* Before storing anything to the stack we must skip
+     the "Red zone" (see the "Function calling sequence" section
+     of AMD64 ABI).
+     It could have already been skipped in the function's
+     prologue, but we don't care and will easily skip it once again.  */
+  sp -= 128;
+
   for (i = 0; i < nargs; i++)
     {
       enum x86_64_reg_class class[MAX_CLASSES];

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

end of thread, other threads:[~2003-08-07 15:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-07 11:05 [RFA] Skip the "red zone" on AMD64 Michal Ludvig
2003-08-07 11:18 ` Andreas Schwab
2003-08-07 11:27   ` Michal Ludvig
2003-08-07 14:10     ` Andrew Cagney
2003-08-07 14:40       ` Michal Ludvig
2003-08-07 15:04         ` Andrew Cagney

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