2009-11-13 Tristan Gingold <gingold@adacore.com>
authorTristan Gingold <gingold@adacore.com>
Fri, 13 Nov 2009 10:32:58 +0000 (10:32 +0000)
committerTristan Gingold <gingold@adacore.com>
Fri, 13 Nov 2009 10:32:58 +0000 (10:32 +0000)
* avr-tdep.c (avr_push_dummy_call): Fix endianness issue and avoid
overlap between returned structure and return address/parameters.

gdb/ChangeLog
gdb/avr-tdep.c

index 275955c..5111dbc 100644 (file)
@@ -1,3 +1,8 @@
+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.
+
 2009-11-12  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * remote-fileio.c (remote_fileio_func_read): Limit console
index ba6e8cb..0c76cf4 100644 (file)
@@ -1252,10 +1252,14 @@ avr_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
   if (struct_return)
     {
-      regcache_cooked_write_unsigned (regcache, regnum--,
-                                      struct_addr & 0xff);
-      regcache_cooked_write_unsigned (regcache, regnum--,
-                                      (struct_addr >> 8) & 0xff);
+      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++)