From 85696377fc2c76ea51463c5896f63c96a5ace92e Mon Sep 17 00:00:00 2001 From: Jiong Wang Date: Thu, 6 Dec 2012 12:13:03 +0800 Subject: [PATCH 1/5] * tilegx-tdep.c (tilegx_push_dummy_call): stack alignment should be 64bit for tilegx, when push args on stack, the alignment should be 64bit --- gdb/tilegx-tdep.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c index 627a470..2f7f253 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. */ @@ -324,44 +324,28 @@ 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; + stack_dest = (stack_dest + 7) & ~0x7; /* Loop backwards through remaining arguments and push them on the stack, word aligned. */ for (j = nargs - 1; j >= i; j--) { gdb_byte *val; - struct cleanup *back_to; - const gdb_byte *contents = value_contents (args[j]); typelen = TYPE_LENGTH (value_enclosing_type (args[j])); - slacklen = ((typelen + 3) & (~3)) - typelen; - val = xmalloc (typelen + slacklen); - back_to = make_cleanup (xfree, val); - memcpy (val, contents, typelen); + slacklen = ((typelen + 7) & (~7)) - typelen; + val = alloca (typelen + slacklen); + memcpy (val, value_contents (args[j]), typelen); memset (val + typelen, 0, slacklen); /* Now write data to the stack. The stack grows downwards. */ stack_dest -= typelen + slacklen; write_memory (stack_dest, val, typelen + slacklen); - do_cleanups (back_to); } - /* Add 2 words for linkage space to the stack. */ - stack_dest = stack_dest - 8; - write_memory (stack_dest, two_zero_words, 8); + /* Add 2 double words for linkage space to the stack. */ + 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.4