[lld] r250190 - [ELF2] Ensure strict weak ordering in section sorting (v2)
Hal Finkel via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 13 10:57:47 PDT 2015
Author: hfinkel
Date: Tue Oct 13 12:57:46 2015
New Revision: 250190
URL: http://llvm.org/viewvc/llvm-project?rev=250190&view=rev
Log:
[ELF2] Ensure strict weak ordering in section sorting (v2)
The fix in r250109 to ensure a strict weak ordering in the section sorting was
a bit overzealous. We only use the NOBITS comparison if either A or B is a
NOBITS section. Otherwise, we fall through to the target-specific ranking
function. Failure to do this causes the sorting to fail in cases where, for
example, a .dynamic section happens to end up in between .got and .toc, etc. in
the initial ordering (.dynamic has a type SHT_DYNAMIC, compared to SHT_PROGBITS
or SHT_NOBITS).
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=250190&r1=250189&r2=250190&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Oct 13 12:57:46 2015
@@ -312,13 +312,14 @@ static bool compareOutputSections(Output
if (AIsExec != BIsExec)
return BIsExec;
- // If we got here we know that both A and B and in the same PT_LOAD.
+ // If we got here we know that both A and B are in the same PT_LOAD.
// The last requirement we have is to put nobits section last. The
// reason is that the only thing the dynamic linker will see about
// them is a p_memsz that is larger than p_filesz. Seeing that it
// zeros the end of the PT_LOAD, so that has to correspond to the
// nobits sections.
- if (A->getType() != B->getType())
+ if ((A->getType() == SHT_NOBITS || B->getType() == SHT_NOBITS) &&
+ A->getType() != B->getType())
return A->getType() != SHT_NOBITS && B->getType() == SHT_NOBITS;
return getPPC64SectionRank(A->getName()) < getPPC64SectionRank(B->getName());
More information about the llvm-commits
mailing list