[lld] abd9807 - [ELF] mergeCmp: work around irreflexivity bug
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 5 17:08:42 PDT 2022
Author: Fangrui Song
Date: 2022-08-05T17:08:37-07:00
New Revision: abd9807590fc10eb92eb22aea7b50dbf08db7e9d
URL: https://github.com/llvm/llvm-project/commit/abd9807590fc10eb92eb22aea7b50dbf08db7e9d
DIFF: https://github.com/llvm/llvm-project/commit/abd9807590fc10eb92eb22aea7b50dbf08db7e9d.diff
LOG: [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.
Added:
Modified:
lld/ELF/Relocations.cpp
Removed:
################################################################################
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index df33df4ae777..b2e6499e95fd 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -1712,7 +1712,8 @@ static bool mergeCmp(const InputSection *a, const InputSection *b) {
if (a->outSecOff < b->outSecOff)
return true;
- if (a->outSecOff == b->outSecOff) {
+ // FIXME dyn_cast<ThunkSection> is non-null for any SyntheticSection.
+ if (a->outSecOff == b->outSecOff && a != b) {
auto *ta = dyn_cast<ThunkSection>(a);
auto *tb = dyn_cast<ThunkSection>(b);
More information about the llvm-commits
mailing list