[PATCH] D14140: [ELF2] SECTIONS command basic support

Denis Protivensky via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 30 02:53:14 PDT 2015


denis-protivensky added a comment.

> I don't think we need that protection. If users try to reorder such

>  sections, we should do that as instructed, no?


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.

Concerning ordering of 'specific' sections:
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

  .interp : { *(.interp) }

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).
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.
That's why I think the ordering should also affect only these sections, which are stored in `RegularSections` map in code.

Just as a note: ld doesn't seem as well to reorder 'specific' sections even if defined in linker script.


http://reviews.llvm.org/D14140





More information about the llvm-commits mailing list