[PATCH] D14140: [ELF2] SECTIONS command basic support
Rafael EspĂndola via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 5 08:50:29 PST 2015
> 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.
It is not clear if this is needed by real program. For now just leave
it out to have a simpler code. Even if it is needed, it would be
better to just organize the code as
* add sections from input files
* sort
* add linker generated sections
* sort the end + merge
no?
Cheers,
Rafael
More information about the llvm-commits
mailing list