Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC/TileGX 1/6] fix args alignment bug
@ 2013-01-18  9:23 Jiong Wang
  2013-01-18 13:14 ` Joel Brobecker
  2013-09-17  3:11 ` [RFC/TileGX 1/2] fix gdbserver build failure Jiong Wang
  0 siblings, 2 replies; 24+ messages in thread
From: Jiong Wang @ 2013-01-18  9:23 UTC (permalink / raw)
  To: gdb-patches; +Cc: Walter Lee

[-- Attachment #1: Type: text/plain, Size: 243 bytes --]

for tilegx, args pushed on stack should be aligned to 64bit.

gdb/ChangeLog:

        * tilegx-tdep.c (tilegx_push_dummy_call): args pushed on stack
        should be aligned to 64bit.

please review.

---
Regards,
Jiong
Tilera Corporation.



[-- Attachment #2: 0001-tilegx-tdep.c-tilegx_push_dummy_call-stack-alignment.patch --]
[-- Type: text/x-patch, Size: 2034 bytes --]

---
 gdb/tilegx-tdep.c |   20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c
index 0c560ba..2f1d824 100644
--- a/gdb/tilegx-tdep.c
+++ b/gdb/tilegx-tdep.c
@@ -292,7 +292,7 @@ tilegx_push_dummy_call (struct gdbarch *gdbarch,
   int argreg = TILEGX_R0_REGNUM;
   int i, j;
   int typelen, slacklen, alignlen;
-  static const gdb_byte two_zero_words[8] = { 0 };
+  static const gdb_byte four_zero_words[16] = { 0 };
 
   /* If struct_return is 1, then the struct return address will
      consume one argument-passing register.  */
@@ -326,18 +326,6 @@ tilegx_push_dummy_call (struct gdbarch *gdbarch,
   /* Align SP.  */
   stack_dest = tilegx_frame_align (gdbarch, stack_dest);
 
-  /* Loop backwards through arguments to determine stack alignment.  */
-  alignlen = 0;
-
-  for (j = nargs - 1; j >= i; j--)
-    {
-      typelen = TYPE_LENGTH (value_enclosing_type (args[j]));
-      alignlen += (typelen + 3) & (~3);
-    }
-
-  if (alignlen & 0x4)
-    stack_dest -= 4;
-
   /* Loop backwards through remaining arguments and push them on
      the stack, word aligned.  */
   for (j = nargs - 1; j >= i; j--)
@@ -347,7 +335,7 @@ tilegx_push_dummy_call (struct gdbarch *gdbarch,
       const gdb_byte *contents = value_contents (args[j]);
 
       typelen = TYPE_LENGTH (value_enclosing_type (args[j]));
-      slacklen = ((typelen + 3) & (~3)) - typelen;
+      slacklen = ((typelen + 7) & (~7)) - typelen;
       val = xmalloc (typelen + slacklen);
       back_to = make_cleanup (xfree, val);
       memcpy (val, contents, typelen);
@@ -360,8 +348,8 @@ tilegx_push_dummy_call (struct gdbarch *gdbarch,
     }
 
   /* Add 2 words for linkage space to the stack.  */
-  stack_dest = stack_dest - 8;
-  write_memory (stack_dest, two_zero_words, 8);
+  stack_dest = stack_dest - 16;
+  write_memory (stack_dest, four_zero_words, 16);
 
   /* Update stack pointer.  */
   regcache_cooked_write_unsigned (regcache, TILEGX_SP_REGNUM, stack_dest);
-- 
1.7.10.3



^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2013-09-18  1:56 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-18  9:23 [RFC/TileGX 1/6] fix args alignment bug Jiong Wang
2013-01-18 13:14 ` Joel Brobecker
2013-01-18 15:00   ` Jiong Wang
2013-01-22 10:28     ` Jiong Wang
2013-01-29 14:49       ` Jiong Wang
2013-01-30  4:34         ` Jiong Wang
2013-01-30  5:47           ` Joel Brobecker
2013-01-30  5:55             ` Jiong Wang
2013-02-08 18:33     ` Joel Brobecker
2013-09-17  3:11 ` [RFC/TileGX 1/2] fix gdbserver build failure Jiong Wang
2013-09-17  3:24   ` [RFC/TileGX 2/2] fix gdbserver runtime crash Jiong Wang
2013-09-17 12:33     ` Joel Brobecker
2013-09-17 12:39       ` Jiong Wang
2013-09-17 13:22         ` Jiong Wang
2013-09-17 13:29           ` Joel Brobecker
2013-09-17 14:06             ` [COMMITTED][RFC/TileGX " Jiong Wang
2013-09-17 12:30   ` [RFC/TileGX 1/2] fix gdbserver build failure Joel Brobecker
2013-09-17 12:33     ` Jiong Wang
2013-09-17 13:21       ` Jiong Wang
2013-09-17 13:30         ` Joel Brobecker
2013-09-17 13:36           ` Jiong Wang
2013-09-17 13:43             ` Joel Brobecker
2013-09-17 14:04               ` [COMMITTED][RFC/TileGX " Jiong Wang
2013-09-18  1:56                 ` Yao Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox