summaryrefslogtreecommitdiffstats
path: root/lld/ELF/LinkerScript.cpp
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2018-02-23 10:15:54 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2018-02-23 10:15:54 +0000
commit3cdf0d969a81bd0b293eda328a99e8cdfa272d74 (patch)
treea7b9aa90172cb8f973308cabd848ce9c3776edbf /lld/ELF/LinkerScript.cpp
parent1fdb280bec1ff9c41a3bdbc6b4385696aa7fe0be (diff)
downloadbcm5719-llvm-3cdf0d969a81bd0b293eda328a99e8cdfa272d74.tar.gz
bcm5719-llvm-3cdf0d969a81bd0b293eda328a99e8cdfa272d74.zip
[ELF] - Report error if removed empty output section declaration used undefined symbols.
This is for fixing PR36297. Issue itself is that if we have SECTIONS { .bar (a+b) : { *(.stub) } }; script and no section .stub, when LLD will remove .bar, but produce output with undefined symbols a and b. Differential revision: https://reviews.llvm.org/D43069 llvm-svn: 325875
Diffstat (limited to 'lld/ELF/LinkerScript.cpp')
-rw-r--r--lld/ELF/LinkerScript.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index e9ea4f84587..0426c503df0 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -767,6 +767,13 @@ void LinkerScript::removeEmptyCommands() {
}
static bool isAllSectionDescription(const OutputSection &Cmd) {
+ // We do not want to remove sections that have custom address or align
+ // expressions set even if them are empty. We keep them because we
+ // want to be sure that any expressions can be evaluated and report
+ // an error otherwise.
+ if (Cmd.AddrExpr || Cmd.AlignExpr || Cmd.LMAExpr)
+ return false;
+
for (BaseCommand *Base : Cmd.SectionCommands)
if (!isa<InputSectionDescription>(*Base))
return false;
OpenPOWER on IntegriCloud