diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c index f7e00d7..903bf20 100644 --- a/gdb/tilegx-tdep.c +++ b/gdb/tilegx-tdep.c @@ -324,23 +324,27 @@ tilegx_push_dummy_call (struct gdbarch *gdbarch, } /* Align SP. */ - stack_dest = (stack_dest + 7) & ~0x7; + stack_dest = align_down(stack_dest, 8); /* 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 + 7) & (~7)) - typelen; - val = alloca (typelen + slacklen); - memcpy (val, value_contents (args[j]), typelen); + val = xmalloc (typelen + slacklen); + back_to = make_cleanup (xfree, val); + memcpy (val, contents, 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 double words for linkage space to the stack. */ @@ -434,17 +438,16 @@ tilegx_analyze_prologue (struct gdbarch* gdbarch, instbuf, instbuf_size); if (status == 0) { /* fix gdb.base/gdb1250 - * breakpoint is set before dynamic library loaded, thus gdb - * does a partial symbol name finding and sets the breakpoint - * in the plt stub. our 32-bundle prefetch window is too large - * for this situation to cause a memory access error. - * For plt stub, we just need to return directly. - * - * x86 does not have this problem, because the first instruction - * in their plt stub is jump, which ends the analysis also. + breakpoint is set before dynamic library loaded, thus gdb + does a partial symbol name finding and sets the breakpoint + in the plt stub. our 32-bundle prefetch window is too large + for this situation to cause a memory access error. + For plt stub, we just need to return directly. + + x86 does not have this problem, because the first instruction + in their plt stub is jump, which ends the analysis also. */ - if (strcmp(find_pc_section(instbuf_start)->the_bfd_section->name, - ".plt") == 0) + if (in_plt_section (instbuf_start, NULL)) return instbuf_start; memory_error (status, next_addr); }