libdwfl: Fix relocation overlap sanity check.

We would not relocate when the relocation section data or the target
section date would overlap with one of the ELF headers. This is only
really necessary if the data comes directly from the mmapped file.
Otherwise there is no real overlap and the relocations can be safely
applied.

One particular thing we got wrong with the original sanity check was
when the relocation data or target data section was compressed. In
that case it could happen we overestimated the size (because the Shdr
would have been updated to show the uncompressed data size). But
uncompressed data is always malloced and so cannot overlap with the
mmapped Elf header structures.

When building with CFLAGS="-g -Og" this showed up as a failure in
run-strip-reloc.sh for strip-compressed.o. Where the .debug_loc
section decompressed would "overlap" with the shdrs at the end of
the file and so wouldn't get relocations applied.

Signed-off-by: Mark Wielaard <mark@klomp.org>
2 files changed