diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2018-08-20 14:20:59 +0000 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2018-08-20 08:20:59 -0600 |
commit | be3cfb9da549517523d9ee9177d327481dc788de (patch) | |
tree | 9c706675ec67b2766d7a1c167c2d4e40ef27fe11 /gcc/expr.c | |
parent | abcd1775e067600918da69330f8ff3f1f6734b4c (diff) | |
download | gcc-be3cfb9da549517523d9ee9177d327481dc788de.zip gcc-be3cfb9da549517523d9ee9177d327481dc788de.tar.gz gcc-be3cfb9da549517523d9ee9177d327481dc788de.tar.bz2 |
re PR target/86984 (invalid relocation accessing a const char array)
PR target/86984
* expr.c (expand_assignment): Assert that bitpos is positive.
(store_field): Likewise
(expand_expr_real_1): Make sure that bitpos is positive.
* config/alpha/alpha.h (CONSTANT_ADDRESS_P): Avoid signed
integer overflow.
PR target/86984
* gcc.target/alpha/pr86984.c: New test.
From-SVN: r263664
Diffstat (limited to 'gcc/expr.c')
-rw-r--r-- | gcc/expr.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -5270,6 +5270,7 @@ expand_assignment (tree to, tree from, bool nontemporal) MEM_VOLATILE_P (to_rtx) = 1; } + gcc_checking_assert (known_ge (bitpos, 0)); if (optimize_bitfield_assignment_op (bitsize, bitpos, bitregion_start, bitregion_end, mode1, to_rtx, to, from, @@ -7046,6 +7047,7 @@ store_field (rtx target, poly_int64 bitsize, poly_int64 bitpos, } /* Store the value in the bitfield. */ + gcc_assert (known_ge (bitpos, 0)); store_bit_field (target, bitsize, bitpos, bitregion_start, bitregion_end, mode, temp, reverse); @@ -10545,6 +10547,14 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, mode2 = CONSTANT_P (op0) ? TYPE_MODE (TREE_TYPE (tem)) : GET_MODE (op0); + /* Make sure bitpos is not negative, it can wreak havoc later. */ + if (maybe_lt (bitpos, 0)) + { + gcc_checking_assert (offset == NULL_TREE); + offset = size_int (bits_to_bytes_round_down (bitpos)); + bitpos = num_trailing_bits (bitpos); + } + /* If we have either an offset, a BLKmode result, or a reference outside the underlying object, we must force it to memory. Such a case can occur in Ada if we have unchecked conversion @@ -10795,6 +10805,7 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, && GET_MODE_CLASS (ext_mode) == MODE_INT) reversep = TYPE_REVERSE_STORAGE_ORDER (type); + gcc_checking_assert (known_ge (bitpos, 0)); op0 = extract_bit_field (op0, bitsize, bitpos, unsignedp, (modifier == EXPAND_STACK_PARM ? NULL_RTX : target), |