[lld] r305613 - Error on trying to discard .dynamic.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 16 16:45:36 PDT 2017
Author: rafael
Date: Fri Jun 16 18:45:35 2017
New Revision: 305613
URL: http://llvm.org/viewvc/llvm-project?rev=305613&view=rev
Log:
Error on trying to discard .dynamic.
We would crash instead before.
Added:
lld/trunk/test/ELF/linkerscript/discard-section-err.s
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/test/ELF/linkerscript/sections.s
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=305613&r1=305612&r2=305613&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Fri Jun 16 18:45:35 2017
@@ -338,8 +338,8 @@ LinkerScript::computeInputSections(const
void LinkerScript::discard(ArrayRef<InputSectionBase *> V) {
for (InputSectionBase *S : V) {
S->Live = false;
- if (S == InX::ShStrTab)
- error("discarding .shstrtab section is not allowed");
+ if (S == InX::ShStrTab || S == InX::Dynamic)
+ error("discarding " + S->Name + " section is not allowed");
discard(S->DependentSections);
}
}
Added: 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=305613&view=auto
==============================================================================
--- lld/trunk/test/ELF/linkerscript/discard-section-err.s (added)
+++ lld/trunk/test/ELF/linkerscript/discard-section-err.s Fri Jun 16 18:45:35 2017
@@ -0,0 +1,13 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+
+# RUN: echo "SECTIONS { /DISCARD/ : { *(.shstrtab) } }" > %t.script
+# RUN: not ld.lld -o %t --script %t.script %t.o 2>&1 | \
+# RUN: FileCheck -check-prefix=SHSTRTAB %s
+# SHSTRTAB: discarding .shstrtab section is not allowed
+
+# RUN: echo "SECTIONS { /DISCARD/ : { *(.dynamic) } }" > %t.script
+# RUN: not ld.lld -pie -o %t --script %t.script %t.o 2>&1 | \
+# RUN: FileCheck -check-prefix=DYNAMIC %s
+# DYNAMIC: discarding .dynamic section is not allowed
Modified: lld/trunk/test/ELF/linkerscript/sections.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/sections.s?rev=305613&r1=305612&r2=305613&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/sections.s (original)
+++ lld/trunk/test/ELF/linkerscript/sections.s Fri Jun 16 18:45:35 2017
@@ -67,12 +67,6 @@
# SEC-SWAP-NAMES: 7 .shstrtab 0000003b {{[0-9a-f]*}}
# SEC-SWAP-NAMES: 8 .strtab 00000008 {{[0-9a-f]*}}
-# Attemp to discard .shstrtab section.
-# RUN: echo "SECTIONS { /DISCARD/ : { *(.shstrtab) } }" > %t.script
-# RUN: not ld.lld -o %t5 --script %t.script %t 2>&1 | \
-# RUN: FileCheck -check-prefix=SEC-DISCARD %s
-# SEC-DISCARD: discarding .shstrtab section is not allowed
-
# Multiple SECTIONS command specifying additional input section descriptions
# for the same output section description - input sections are merged into
# one output section.
More information about the llvm-commits
mailing list