diff options
author | Alan Modra <amodra@gmail.com> | 2016-10-07 22:54:45 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2016-10-07 22:59:30 +1030 |
commit | 769553e65f6ea5829edab1e70fd54b058435d85f (patch) | |
tree | 9f48dfbe791b360a5b6f18849ba5bf41a9845d9b | |
parent | 362c0c4d9cc9f320d1e85755404879a13ebed91a (diff) | |
download | gdb-769553e65f6ea5829edab1e70fd54b058435d85f.zip gdb-769553e65f6ea5829edab1e70fd54b058435d85f.tar.gz gdb-769553e65f6ea5829edab1e70fd54b058435d85f.tar.bz2 |
Fold arithmetic integer expressions fallout
* ldexp.c (MAX): Define.
(exp_unop, exp_binop, exp_trinop): Alloc at least enough for
etree_type.value.
-rw-r--r-- | ld/ChangeLog | 6 | ||||
-rw-r--r-- | ld/ldexp.c | 14 |
2 files changed, 14 insertions, 6 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 7be0a2a..6fb93bc 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,5 +1,11 @@ 2016-10-07 Alan Modra <amodra@gmail.com> + * ldexp.c (MAX): Define. + (exp_unop, exp_binop, exp_trinop): Alloc at least enough for + etree_type.value. + +2016-10-07 Alan Modra <amodra@gmail.com> + * testsuite/lib/ld-lib.exp (is_generic_elf): New, extracted from.. * testsuite/ld-elf/elf.exp: ..here. @@ -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; |