This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[committed] avr: fix clash between returned structure and return address
- From: Tristan Gingold <gingold at adacore dot com>
- To: gdb-patches ml <gdb-patches at sourceware dot org>
- Date: Fri, 13 Nov 2009 11:29:12 +0100
- Subject: [committed] avr: fix clash between returned structure and return address
Hi,
this patch fixes two issues related to inferior call than return
structures whose address is passed by the
first parameter.
* an endianness issue: bytes were swapped.
* because the stack is post decremented, one byte must be reserved to
avoid an overlap between the
returned structure and the return address (or the last parameter
passed on the stack).
Tristan.
2009-11-13 Tristan Gingold <gingold@adacore.com>
* avr-tdep.c (avr_push_dummy_call): Fix endianness issue and avoid
overlap between returned structure and return address/parameters.
*** avr-tdep.c 10 Nov 2009 11:14:38 -0000 1.122
--- avr-tdep.c 13 Nov 2009 10:28:30 -0000
***************
*** 1252,1261 ****
if (struct_return)
{
! regcache_cooked_write_unsigned (regcache, regnum--,
! struct_addr & 0xff);
! regcache_cooked_write_unsigned (regcache, regnum--,
! (struct_addr >> 8) & 0xff);
}
for (i = 0; i < nargs; i++)
--- 1252,1265 ----
if (struct_return)
{
! regcache_cooked_write_unsigned
! (regcache, regnum--, (struct_addr >> 8) & 0xff);
! regcache_cooked_write_unsigned
! (regcache, regnum--, struct_addr & 0xff);
! /* SP being post decremented, we need to reserve one byte so
that the
! return address won't overwrite the result (or vice-versa).
*/
! if (sp == struct_addr)
! sp--;
}
for (i = 0; i < nargs; i++)