Fold arithmetic integer expressions
Commit
b751e639 regressed arm linux kernel builds, that have an
ASSERT (((__hyp_idmap_text_end - (__hyp_idmap_text_start
& ~ (((0x1 << 0xc) - 0x1))))
<= (0x1 << 0xc)), HYP init code too big or misaligned)
Due to some insanity in ld expression evaluation, the integer values
0x1 and 0xc above are treated as absolute addresses (ie. they have an
associated section, *ABS*, see exp_fold_tree_1 case etree_value) while
the expression (0x1 << 0xc) has a plain number result. The left hand
side of the inequality happens to evaluate to a "negative" .text
section relative value. Comparing a section relative value against an
absolute value works since the section relative value is first
converted to absolute. Comparing a section relative value against a
number just compares the offsets, which fails since the "negative"
offset is really a very large positive number.
This patch works around the problem by folding integer expressions, so
the assert again becomes
ASSERT (((__hyp_idmap_text_end - (__hyp_idmap_text_start
& 0xfffffffffffff000))
<= 0x1000), HYP init code too big or misaligned)
* ldexp.c (exp_value_fold): New function.
(exp_unop, exp_binop, exp_trinop): Use it.