[LLD][ELF] - Don't keep empty output sections which have explicit program headers.
authorGeorgii Rymar <grimar@accesssoftek.com>
Fri, 27 Nov 2020 18:42:35 +0000 (21:42 +0300)
committerGeorgii Rymar <grimar@accesssoftek.com>
Wed, 2 Dec 2020 08:19:21 +0000 (11:19 +0300)
commit3f5dc57fd18106766f45216b5ddd4648d2fb4629
tree8bfc2820f1eca180b019bdcfdb999a452e333e93
parentc266c56d545dfecf767b312771f716b394c5d5eb
[LLD][ELF] - Don't keep empty output sections which have explicit program headers.

This reverts a side effect introduced in the code cleanup patch D43571:
LLD started to emit empty output sections that are explicitly assigned to a segment.

This patch fixes the issue by removing the !sec.phdrs.empty() special case from
isDiscardable. As compensation, we add an early phdrs propagation step (see the inline comment).
This is similar to one that we do in adjustSectionsAfterSorting.

Differential revision: https://reviews.llvm.org/D92301
lld/ELF/LinkerScript.cpp
lld/test/ELF/linkerscript/empty-relaplt-dyntags.test
lld/test/ELF/linkerscript/implicit-program-header.test
lld/test/ELF/linkerscript/orphan-phdrs.s