<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Oct 13, 2015 at 10:57 AM, Hal Finkel via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: hfinkel<br>
Date: Tue Oct 13 12:57:46 2015<br>
New Revision: 250190<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=250190&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=250190&view=rev</a><br>
Log:<br>
[ELF2] Ensure strict weak ordering in section sorting (v2)<br>
<br>
The fix in r250109 to ensure a strict weak ordering in the section sorting was<br>
a bit overzealous. We only use the NOBITS comparison if either A or B is a<br>
NOBITS section. Otherwise, we fall through to the target-specific ranking<br>
function. Failure to do this causes the sorting to fail in cases where, for<br>
example, a .dynamic section happens to end up in between .got and .toc, etc. in<br>
the initial ordering (.dynamic has a type SHT_DYNAMIC, compared to SHT_PROGBITS<br>
or SHT_NOBITS).<br>
<br>
Modified:<br>
    lld/trunk/ELF/Writer.cpp<br>
<br>
Modified: lld/trunk/ELF/Writer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=250190&r1=250189&r2=250190&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=250190&r1=250189&r2=250190&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/Writer.cpp (original)<br>
+++ lld/trunk/ELF/Writer.cpp Tue Oct 13 12:57:46 2015<br>
@@ -312,13 +312,14 @@ static bool compareOutputSections(Output<br>
   if (AIsExec != BIsExec)<br>
     return BIsExec;<br>
<br>
-  // If we got here we know that both A and B and in the same PT_LOAD.<br>
+  // If we got here we know that both A and B are in the same PT_LOAD.<br>
   // The last requirement we have is to put nobits section last. The<br>
   // reason is that the only thing the dynamic linker will see about<br>
   // them is a p_memsz that is larger than p_filesz. Seeing that it<br>
   // zeros the end of the PT_LOAD, so that has to correspond to the<br>
   // nobits sections.<br>
-  if (A->getType() != B->getType())<br>
+  if ((A->getType() == SHT_NOBITS || B->getType() == SHT_NOBITS) &&<br>
+      A->getType() != B->getType())<br>
     return A->getType() != SHT_NOBITS && B->getType() == SHT_NOBITS;<br></blockquote><div><br></div><div>If A != B, and both A and B are either X or !X, then</div><div><br></div><div>  return A != X && B == X;</div><div><br></div><div>and</div><div><br></div><div>  return A != X;</div><div><br></div><div>are the same.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
   return getPPC64SectionRank(A->getName()) < getPPC64SectionRank(B->getName());<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>