[lld] r305615 - Error when discarding .dynstr.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 16 16:53:36 PDT 2017
Author: rafael
Date: Fri Jun 16 18:53:36 2017
New Revision: 305615
URL: http://llvm.org/viewvc/llvm-project?rev=305615&view=rev
Log:
Error when discarding .dynstr.
We would crash before.
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/test/ELF/linkerscript/discard-section-err.s
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=305615&r1=305614&r2=305615&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Fri Jun 16 18:53:36 2017
@@ -338,7 +338,8 @@ LinkerScript::computeInputSections(const
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);
}
Modified: lld/trunk/test/ELF/linkerscript/discard-section-err.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/discard-section-err.s?rev=305615&r1=305614&r2=305615&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/discard-section-err.s (original)
+++ lld/trunk/test/ELF/linkerscript/discard-section-err.s Fri Jun 16 18:53:36 2017
@@ -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
More information about the llvm-commits
mailing list