[RFA] Skip the "red zone" on AMD64

Michal Ludvig
2003-08-07T11:05:02Z

[-- 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];