Fold arithmetic integer expressions
authorAlan Modra <amodra@gmail.com>
Tue, 4 Oct 2016 00:11:26 +0000 (10:41 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 4 Oct 2016 00:11:26 +0000 (10:41 +1030)
commit9ad39107ca6e4efcda0f48a6abf528844a2f11aa
tree92e5e540dc59caa5c66b91b06d55c9af0e97615c
parent128d08b1587e537667c3079cc01915a94964e5a0
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.
ld/ChangeLog
ld/ldexp.c
This page took 0.025915 seconds and 4 git commands to generate.