* h8300-tdep.c (h8300_push_dummy_call): Replace unsafe alloca

with xmalloc/cleanup.
        * mt-tdep.c (mt_push_dummy_call): Likewise.
        * tilegx-tdep.c (tilegx_push_dummy_call): Likewise.
        * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise.
This commit is contained in:
Siddhesh Poyarekar 2012-08-24 03:57:22 +00:00
parent e7d50cc9e6
commit ecfb0d68c5
5 changed files with 31 additions and 7 deletions

View File

@ -1,3 +1,11 @@
2012-08-24 Siddhesh Poyarekar <siddhesh@redhat.com>
* h8300-tdep.c (h8300_push_dummy_call): Replace unsafe alloca
with xmalloc/cleanup.
* mt-tdep.c (mt_push_dummy_call): Likewise.
* tilegx-tdep.c (tilegx_push_dummy_call): Likewise.
* xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise.
2012-08-24 Yao Qi <yao@codesourcery.com>
* jv-exp.y (push_expression_name): Add "." at the end of error

View File

@ -666,13 +666,15 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
for (argument = 0; argument < nargs; argument++)
{
struct cleanup *back_to;
struct type *type = value_type (args[argument]);
int len = TYPE_LENGTH (type);
char *contents = (char *) value_contents (args[argument]);
/* Pad the argument appropriately. */
int padded_len = align_up (len, wordsize);
gdb_byte *padded = alloca (padded_len);
gdb_byte *padded = xmalloc (padded_len);
back_to = make_cleanup (xfree, padded);
memset (padded, 0, padded_len);
memcpy (len < wordsize ? padded + padded_len - len : padded,
@ -720,6 +722,8 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
subsequent arguments go on the stack. */
reg = E_ARGLAST_REGNUM + 1;
}
do_cleanups (back_to);
}
/* Store return address. */

View File

@ -845,16 +845,20 @@ mt_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
for (j = nargs - 1; j >= i; j--)
{
gdb_byte *val;
struct cleanup *back_to;
const gdb_byte *contents = value_contents (args[j]);
/* Right-justify the value in an aligned-length buffer. */
typelen = TYPE_LENGTH (value_type (args[j]));
slacklen = (wordsize - (typelen % wordsize)) % wordsize;
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 this data to the stack. */
stack_dest -= typelen + slacklen;
write_memory (stack_dest, val, typelen + slacklen);
do_cleanups (back_to);
}
/* Finally, if a param needs to be split between registers and stack,

View File

@ -343,16 +343,20 @@ tilegx_push_dummy_call (struct gdbarch *gdbarch,
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 = 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 words for linkage space to the stack. */

View File

@ -279,16 +279,20 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch,
for (j = nargs - 1; j >= i; j--)
{
char *val;
struct cleanup *back_to;
const gdb_byte *bytes = value_contents (args[j]);
typelen = TYPE_LENGTH (value_enclosing_type (args[j]));
slacklen = typelen & 1;
val = alloca (typelen + slacklen);
memcpy (val, value_contents (args[j]), typelen);
val = xmalloc (typelen + slacklen);
back_to = make_cleanup (xfree, val);
memcpy (val, bytes, typelen);
memset (val + typelen, 0, slacklen);
/* Now write this data to the stack. The stack grows upwards. */
write_memory (stack_dest, val, typelen + slacklen);
stack_dest += typelen + slacklen;
do_cleanups (back_to);
}
store_unsigned_integer (buf, xstormy16_pc_size, byte_order, bp_addr);