<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Oct 16, 2015 at 7:37 AM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
This and previous patches add more walks over all the output sections.<br>
<br>
A normal file normally has less than 100 output sections, so this is<br>
not normally a problem, but it is possible to craft a file with an<br>
arbitrary large number of output sections. I am not sure if we care<br>
about it or not. I just wanted to make sure you know about the<br>
possibility.<br></blockquote><div><br></div><div>Total number of function calls did not change. Previously, we call two functions from one for-loop, and now they are called separately from two for-loops. So the cost by this change is one for-each loop and no more than that. If that's a complex data structure, I would probably care, but this is a std::vector. I believe that that's extremely cheap.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Cheers,<br>
Rafael<br>
<br>
<br>
<br>
On 15 October 2015 at 17:50, Rui Ueyama via llvm-commits<br>
<div class="HOEnZb"><div class="h5"><<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
> Author: ruiu<br>
> Date: Thu Oct 15 16:50:30 2015<br>
> New Revision: 250463<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=250463&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=250463&view=rev</a><br>
> Log:<br>
> ELF2: Do not treat .strtab specially when creating sections.<br>
><br>
> String table is added to end of the file so that all the other sections<br>
> are finalized before string table. But we can just add section names to<br>
> the string table before calling finalize() on any section instead.<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=250463&r1=250462&r2=250463&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=250463&r1=250462&r2=250463&view=diff</a><br>
> ==============================================================================<br>
> --- lld/trunk/ELF/Writer.cpp (original)<br>
> +++ lld/trunk/ELF/Writer.cpp Thu Oct 15 16:50:30 2015<br>
> @@ -470,7 +470,10 @@ template <class ELFT> void Writer<ELFT>:<br>
>    }<br>
>    addCommonSymbols(CommonSymbols);<br>
><br>
> +  // This order is not the same as the final output order<br>
> +  // because we sort the sections using their attributes below.<br>
>    OutputSections.push_back(Out<ELFT>::SymTab);<br>
> +  OutputSections.push_back(Out<ELFT>::StrTab);<br>
>    if (isOutputDynamic()) {<br>
>      OutputSections.push_back(Out<ELFT>::DynSymTab);<br>
>      OutputSections.push_back(Out<ELFT>::HashTab);<br>
> @@ -487,21 +490,19 @@ template <class ELFT> void Writer<ELFT>:<br>
>    std::stable_sort(OutputSections.begin(), OutputSections.end(),<br>
>                     compareOutputSections<ELFT>);<br>
><br>
> -  // Always put StrTabSec last so that no section names are added to it after<br>
> -  // it's finalized.<br>
> -  OutputSections.push_back(Out<ELFT>::StrTab);<br>
> -<br>
>    for (unsigned I = 0, N = OutputSections.size(); I < N; ++I)<br>
>      OutputSections[I]->SectionIndex = I + 1;<br>
><br>
> -  // Fill the DynStrTab early.<br>
> +  for (OutputSectionBase<ELFT::Is64Bits> *Sec : OutputSections)<br>
> +    Out<ELFT>::StrTab->add(Sec->getName());<br>
> +<br>
> +  // Fill the DynStrTab early because Dynamic adds strings to<br>
> +  // DynStrTab but .dynstr may appear before .dynamic.<br>
>    Out<ELFT>::Dynamic->finalize();<br>
><br>
> -  // Fix each section's header (e.g. sh_size, sh_link, etc.)<br>
> -  for (OutputSectionBase<ELFT::Is64Bits> *Sec : OutputSections) {<br>
> -    Out<ELFT>::StrTab->add(Sec->getName());<br>
> +  // Fill other section headers.<br>
> +  for (OutputSectionBase<ELFT::Is64Bits> *Sec : OutputSections)<br>
>      Sec->finalize();<br>
> -  }<br>
><br>
>    // If we have a .opd section (used under PPC64 for function descriptors),<br>
>    // store a pointer to it here so that we can use it later when processing<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>
</div></div></blockquote></div><br></div></div>