The valueDelta map was used to calculate the symbol value deltas from
the previous iteration. Since the symbol values themselves are also
updated every iteration, the following invariant holds:
sa[i].offset == sa[i].d->value + valueDelta[sa[i].d]
Note that sa[i].offset contains the original value of sa[i].d and is
never changed.
This means that the current way of updating symbol values can be
rewritten to not need the valueDelta map:
sa[i].d->value -= delta - valueDelta.find(sa[i].d)->second; <=> (replace invariant) sa[i].d->value -= delta - (sa[i].offset - sa[i].d->value); <=> sa[i].d->value = sa[i].d->value - (delta - (sa[i].offset - sa[i].d->value)); <=> sa[i].d->value = sa[i].d->value - delta + sa[i].offset - sa[i].d->value; <=> sa[i].d->value = sa[i].offset - delta;
This patch implements this simplification. I believe this improves the
readability of the code as it took me quite some time to understand the
use of valueDelta. It might also have a slight performance benefit as
it removes one iteration over all relocations every relax iteration.