[ELF] --emit-relocs: adjust offsets of .rel[a].eh_frame relocations
authorFangrui Song <i@maskray.me>
Mon, 28 Mar 2022 23:23:13 +0000 (16:23 -0700)
committerFangrui Song <i@maskray.me>
Mon, 28 Mar 2022 23:23:13 +0000 (16:23 -0700)
commit6faba31e0d88ce71e87567ddb51d2444524b8a81
treec2b6de83198d69fda902d216190c83f8c1a3f471
parentf7381a795ab235d34c94eaf01dc880eb5b89619d
[ELF] --emit-relocs: adjust offsets of .rel[a].eh_frame relocations

.eh_frame pieces may be dropped due to GC/ICF. When --emit-relocs adds
relocations against .eh_frame, the offsets need to be adjusted. Use the same
way as MergeInputSection with a special case handling outSecOff==-1 for an
invalid piece (see eh-frame-marker.s).

This exposes an issue in mips64-eh-abs-reloc.s that we don't reliably
handle anyway. Just add --no-check-dynamic-relocations to paper over it.

Original patch by Ayrton Muñoz

Differential Revision: https://reviews.llvm.org/D122459
lld/ELF/InputSection.cpp
lld/ELF/InputSection.h
lld/test/ELF/eh-frame-merge.s
lld/test/ELF/mips64-eh-abs-reloc.s