<div dir="ltr">I think this falls in the category of undefined behaviors if there was a spec of the linker script. Since there's no standard or specification for the linker script, we need to do something that we think reasonable. A pitfall we want to avoid is to copy every detail of the GNU linker. So can you please minimize the impact of the patch to the regular flow? I'd restore code for __start/__stop symbols and for RegularSections, and reorder "non-regular" sections if instructed to do so.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 30, 2015 at 2:53 AM, Denis Protivensky <span dir="ltr"><<a href="mailto:dprotivensky@accesssoftek.com" target="_blank">dprotivensky@accesssoftek.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">denis-protivensky added a comment.<br>
<span class=""><br>
> I don't think we need that protection. If users try to reorder such<br>
<br>
>  sections, we should do that as instructed, no?<br>
<br>
<br>
</span>First of all, I reproduced the case when defining 'specific' section in the SECTIONS command affects its ordering in the resulting file without the check, so this check works as I expected.<br>
<br>
Concerning ordering of 'specific' sections:<br>
The goal of the SECTIONS command is to layout sections from input files to the corresponding output sections. 'Specific' sections as .got, .plt, .interp and most others don't have input sections at all and are generated by the linker logic. This means that we cannot affect the contents of such sections, and the output section description command of format<br>
<br>
  .interp : { *(.interp) }<br>
<br>
is void because there are no input .interp sections, and such empty output sections are discarded by linker rules. The only way this format of command worked is to define custom .interp section (possibly of SHT_PROGBITS/_NOBITS type). Then it will be considered during layout, but that's a specific case and it's checked in tests (with .shstrtab custom section).<br>
I conclude that output section descriptions affect only PROGBITS/NOBITS section types, which are represented as OutputSection/MergeOutputSection in lld, and we currently create only these sections from output section descriptions.<br>
That's why I think the ordering should also affect only these sections, which are stored in `RegularSections` map in code.<br>
<br>
Just as a note: ld doesn't seem as well to reorder 'specific' sections even if defined in linker script.<br>
<br>
<br>
<a href="http://reviews.llvm.org/D14140" rel="noreferrer" target="_blank">http://reviews.llvm.org/D14140</a><br>
<br>
<br>
<br>
</blockquote></div><br></div>