[lld] 943baf3 - [ELF] Make compareByFilePosition a strict weak order
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon May 13 15:47:40 PDT 2024
Author: Fangrui Song
Date: 2024-05-13T15:47:35-07:00
New Revision: 943baf327409fdcb01c9d02aa3c3368f2fca114b
URL: https://github.com/llvm/llvm-project/commit/943baf327409fdcb01c9d02aa3c3368f2fca114b
DIFF: https://github.com/llvm/llvm-project/commit/943baf327409fdcb01c9d02aa3c3368f2fca114b.diff
LOG: [ELF] Make compareByFilePosition a strict weak order
This fixes the new test linkerscript/enable-non-contiguous-regions.test
from #90007 in -stdlib=libc++ -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG builds.
adjustOutputSections does not discard the output section .potential_a
because it contained .a (which would be spilled to .actual_a).
.potential_a and .bc have the same address and will cause an assertion
failure.
Added:
Modified:
lld/ELF/Writer.cpp
Removed:
################################################################################
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 8d529f2bdb9f9..e8a7b19a95ee4 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1338,9 +1338,11 @@ static bool compareByFilePosition(InputSection *a, InputSection *b) {
OutputSection *aOut = la->getParent();
OutputSection *bOut = lb->getParent();
- if (aOut != bOut)
- return aOut->addr < bOut->addr;
- return la->outSecOff < lb->outSecOff;
+ if (aOut == bOut)
+ return la->outSecOff < lb->outSecOff;
+ if (aOut->addr == bOut->addr)
+ return aOut->sectionIndex < bOut->sectionIndex;
+ return aOut->addr < bOut->addr;
}
template <class ELFT> void Writer<ELFT>::resolveShfLinkOrder() {
More information about the llvm-commits
mailing list