summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/LinkerScript.cpp3
-rw-r--r--lld/test/ELF/linkerscript/discard-section-err.s5
2 files changed, 7 insertions, 1 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 7c31ace9a5b..8c20bf60432 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -338,7 +338,8 @@ LinkerScript::computeInputSections(const InputSectionDescription *Cmd) {
void LinkerScript::discard(ArrayRef<InputSectionBase *> V) {
for (InputSectionBase *S : V) {
S->Live = false;
- if (S == InX::ShStrTab || S == InX::Dynamic || S == InX::DynSymTab)
+ if (S == InX::ShStrTab || S == InX::Dynamic || S == InX::DynSymTab ||
+ S == InX::DynStrTab)
error("discarding " + S->Name + " section is not allowed");
discard(S->DependentSections);
}
diff --git a/lld/test/ELF/linkerscript/discard-section-err.s b/lld/test/ELF/linkerscript/discard-section-err.s
index bfa37e02c5c..5d9955545d9 100644
--- a/lld/test/ELF/linkerscript/discard-section-err.s
+++ b/lld/test/ELF/linkerscript/discard-section-err.s
@@ -16,3 +16,8 @@
# RUN: not ld.lld -pie -o %t --script %t.script %t.o 2>&1 | \
# RUN: FileCheck -check-prefix=DYNSYM %s
# DYNSYM: discarding .dynsym section is not allowed
+
+# RUN: echo "SECTIONS { /DISCARD/ : { *(.dynstr) } }" > %t.script
+# RUN: not ld.lld -pie -o %t --script %t.script %t.o 2>&1 | \
+# RUN: FileCheck -check-prefix=DYNSTR %s
+# DYNSTR: discarding .dynstr section is not allowed
OpenPOWER on IntegriCloud