This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA] Skip the "red zone" on AMD64
- From: Michal Ludvig <mludvig at suse dot cz>
- To: GDB Patches <gdb-patches at sources dot redhat dot com>
- Date: Thu, 07 Aug 2003 13:05:24 +0200
- Subject: [RFA] Skip the "red zone" on AMD64
- Organization: SuSE CR, s.r.o.
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
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];