From: Alan Modra Date: Fri, 7 Oct 2016 12:24:45 +0000 (+1030) Subject: Fold arithmetic integer expressions fallout X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=769553e65f6ea5829edab1e70fd54b058435d85f;p=deliverable%2Fbinutils-gdb.git Fold arithmetic integer expressions fallout * ldexp.c (MAX): Define. (exp_unop, exp_binop, exp_trinop): Alloc at least enough for etree_type.value. --- diff --git a/ld/ChangeLog b/ld/ChangeLog index 7be0a2acba..6fb93bc33a 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,9 @@ +2016-10-07 Alan Modra + + * ldexp.c (MAX): Define. + (exp_unop, exp_binop, exp_trinop): Alloc at least enough for + etree_type.value. + 2016-10-07 Alan Modra * testsuite/lib/ld-lib.exp (is_generic_elf): New, extracted from.. diff --git a/ld/ldexp.c b/ld/ldexp.c index a5931fdb2d..b2c762036d 100644 --- a/ld/ldexp.c +++ b/ld/ldexp.c @@ -1273,11 +1273,13 @@ exp_value_fold (etree_type *tree) } } +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + etree_type * exp_binop (int code, etree_type *lhs, etree_type *rhs) { - etree_type *new_e = (etree_type *) stat_alloc (sizeof (new_e->binary)); - + etree_type *new_e = (etree_type *) stat_alloc (MAX (sizeof (new_e->binary), + sizeof (new_e->value))); new_e->type.node_code = code; new_e->type.filename = lhs->type.filename; new_e->type.lineno = lhs->type.lineno; @@ -1296,8 +1298,8 @@ exp_binop (int code, etree_type *lhs, etree_type *rhs) etree_type * exp_trinop (int code, etree_type *cond, etree_type *lhs, etree_type *rhs) { - etree_type *new_e = (etree_type *) stat_alloc (sizeof (new_e->trinary)); - + etree_type *new_e = (etree_type *) stat_alloc (MAX (sizeof (new_e->trinary), + sizeof (new_e->value))); new_e->type.node_code = code; new_e->type.filename = cond->type.filename; new_e->type.lineno = cond->type.lineno; @@ -1315,8 +1317,8 @@ exp_trinop (int code, etree_type *cond, etree_type *lhs, etree_type *rhs) etree_type * exp_unop (int code, etree_type *child) { - etree_type *new_e = (etree_type *) stat_alloc (sizeof (new_e->unary)); - + etree_type *new_e = (etree_type *) stat_alloc (MAX (sizeof (new_e->unary), + sizeof (new_e->value))); new_e->unary.type.node_code = code; new_e->unary.type.filename = child->type.filename; new_e->unary.type.lineno = child->type.lineno;