diff options
author | Fangrui Song <i@maskray.me> | 2022-08-05 17:08:37 -0700 |
---|---|---|
committer | Tom Stellard <tstellar@redhat.com> | 2022-08-08 12:39:51 -0700 |
commit | 4acca1b014ece0073fd33c384b86b7a29dd3df9d (patch) | |
tree | 4bee26a1da82d51864dd5f1b37264eddd7c21af5 | |
parent | 8160d4a2a9518696ca151fd0315769fceb022e0d (diff) | |
download | llvm-4acca1b014ece0073fd33c384b86b7a29dd3df9d.zip llvm-4acca1b014ece0073fd33c384b86b7a29dd3df9d.tar.gz llvm-4acca1b014ece0073fd33c384b86b7a29dd3df9d.tar.bz2 |
[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.
(cherry picked from commit abd9807590fc10eb92eb22aea7b50dbf08db7e9d)
-rw-r--r-- | lld/ELF/Relocations.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index e54e1eb..53af34e 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -1705,7 +1705,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); |