[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 11:15:53 PDT 2015


----- Original Message -----
> From: "Rui Ueyama" <ruiu at google.com>
> To: "Hal Finkel" <hfinkel at anl.gov>
> Cc: "llvm-commits" <llvm-commits at lists.llvm.org>
> Sent: Tuesday, October 13, 2015 1:05:01 PM
> Subject: Re: [lld] r250190 - [ELF2] Ensure strict weak ordering in section sorting (v2)
> 
> 
> 
> 
> On Tue, Oct 13, 2015 at 10:57 AM, Hal Finkel via llvm-commits <
> llvm-commits at lists.llvm.org > wrote:
> 
> 
> 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;
> 
> 
> 
> If A != B, and both A and B are either X or !X, then

Right, but as I said in the commit message, A and B are not only either X or !X. At least SHT_DYNAMIC, SHT_PROGBITS, and SHT_NOBITS show up in a simple test case. There are lots of types.

Thanks again,
Hal

> 
> 
> return A != X && B == X;
> 
> 
> and
> 
> 
> return A != X;
> 
> 
> are the same.
> 
> 
> 
> return getPPC64SectionRank(A->getName()) <
> getPPC64SectionRank(B->getName());
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> 
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory


More information about the llvm-commits mailing list