Tentative fix for #863636, but it sometimes makes the problem worse
This should work in theory and does in practise *except* for the case of
readelf where it works on small cases but fails for large cases and sometimes
makes those cases worse, see the bug report for details.