diff options
author | Fangrui Song <i@maskray.me> | 2024-05-13 15:47:35 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2024-05-13 15:47:35 -0700 |
commit | 943baf327409fdcb01c9d02aa3c3368f2fca114b (patch) | |
tree | 3aee6ccda77c679038366fcce9804b343cf01892 /lld | |
parent | 8960078765f141c770f70629a205b3ea88cd9781 (diff) | |
download | llvm-943baf327409fdcb01c9d02aa3c3368f2fca114b.zip llvm-943baf327409fdcb01c9d02aa3c3368f2fca114b.tar.gz llvm-943baf327409fdcb01c9d02aa3c3368f2fca114b.tar.bz2 |
[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.
Diffstat (limited to 'lld')
-rw-r--r-- | lld/ELF/Writer.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 8d529f2..e8a7b19 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() { |