[committed] avr: fix clash between returned structure and return address
Tristan Gingold
gingold@adacore.com
Fri Nov 13 10:29:00 GMT 2009
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++)
More information about the Gdb-patches
mailing list