[ELF] mergeCmp: work around irreflexivity bug
authorFangrui Song <i@maskray.me>
Sat, 6 Aug 2022 00:08:37 +0000 (17:08 -0700)
committerFangrui Song <i@maskray.me>
Sat, 6 Aug 2022 00:08:37 +0000 (17:08 -0700)
commitabd9807590fc10eb92eb22aea7b50dbf08db7e9d
tree8e7ed62f0fe87dc4d1a747cd0e70332e879d52da
parent3fbbf28173406ed74c9791d172fff5c5b1aab823
[ELF] mergeCmp: work around irreflexivity bug

Some tests (e.g. aarch64-feature-pac.s) segfault in libstdc++ _GLIBCXX_DEBUG
builds (enabled by LLVM_ENABLE_EXPENSIVE_CHECKS).

dyn_cast<ThunkSection> is incorrectly true for any SyntheticSection. std::merge
transitively calls mergeCmp(x, x) (due to __glibcxx_requires_irreflexive_pred)
and will segfault in `ta->getTargetInputSection()`. The dyn_cast<ThunkSection>
issue should be eventually fixed properly, bug `a != b` is robust enough for now.
lld/ELF/Relocations.cpp