aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2022-08-05 17:08:37 -0700
committerTom Stellard <tstellar@redhat.com>2022-08-08 12:39:51 -0700
commit4acca1b014ece0073fd33c384b86b7a29dd3df9d (patch)
tree4bee26a1da82d51864dd5f1b37264eddd7c21af5
parent8160d4a2a9518696ca151fd0315769fceb022e0d (diff)
downloadllvm-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.cpp3
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);