[ELF] - Linkerscript: disallow discarding COMMON.
This patch restricts following construction:
/DISCARD/ : { *(COMMON) }
Previously LLD would crash.
Differential revision: https://reviews.llvm.org/D36468
llvm-svn: 310554
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 1fb787a..805d50b 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -319,8 +319,8 @@
void LinkerScript::discard(ArrayRef<InputSectionBase *> V) {
for (InputSectionBase *S : V) {
S->Live = false;
- if (S == InX::ShStrTab || S == InX::Dynamic || S == InX::DynSymTab ||
- S == InX::DynStrTab)
+ if (S == InX::ShStrTab || S == InX::Common || S == InX::Dynamic ||
+ S == InX::DynSymTab || S == InX::DynStrTab)
error("discarding " + S->Name + " section is not allowed");
discard(S->DependentSections);
}