[PATCH] D50688: [LLD] Warn if non-alloc sections occur before alloc sections in linker scripts
Konstantin Schwarz via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 20 00:41:59 PDT 2018
kschwarz added a comment.
At least it is a restriction of what we support in linker scripts, but I would also consider this a bug.
A solution would be to sort also the linker script supplied sections (as done in the previous version of the patch). However, as pointed out by Peter, its not exactly matching bfd's behaviour.
Keeping the section order given by the linker script and still allow interleaving of alloc/non-alloc sections complicates (at least) the creation of program headers even further.
Would a patch in that direction be acceptable?
================
Comment at: ELF/Writer.cpp:1621
+ NonAllocSec = nullptr;
+ }
+
----------------
grimar wrote:
> I think `Writer<ELFT>::checkSections()` is the correct place for this code. Can it be moved there?
>
> (I also think you'll be able to simplify the conditions a bit, to remove `OS->SectionIndex` check).
In `checkSections` we do not know anymore which output sections were added via linkerscript and which are synthetic sections. The existing algorithm will group the orphan sections by "category" (in `findOrphanPos`), which will group all non-alloc synthetic sections behind the first non-alloc linker script section. Thus, we would issue warnings for synthetic instead of user specified sections most of the time.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D50688
More information about the llvm-commits
mailing list