[lld] r250212 - [ELF2] Simplify the NOBITS sorting logic

Hal Finkel via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 13 12:27:13 PDT 2015


Author: hfinkel
Date: Tue Oct 13 14:27:12 2015
New Revision: 250212

URL: http://llvm.org/viewvc/llvm-project?rev=250212&view=rev
Log:
[ELF2] Simplify the NOBITS sorting logic

As Rafael suggested in his review of r250190, we can simplify this by writing
it like the earlier checks.

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=250212&r1=250211&r2=250212&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Oct 13 14:27:12 2015
@@ -327,9 +327,10 @@ static bool compareOutputSections(Output
   // 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() == SHT_NOBITS || B->getType() == SHT_NOBITS) &&
-      A->getType() != B->getType())
-    return A->getType() != SHT_NOBITS && B->getType() == SHT_NOBITS;
+  bool AIsNoBits = A->getType() == SHT_NOBITS;
+  bool BIsNoBits = B->getType() == SHT_NOBITS;
+  if (AIsNoBits != BIsNoBits)
+    return BIsNoBits;
 
   // Some architectures have additional ordering restrictions for sections
   // within the same PT_LOAD.




More information about the llvm-commits mailing list