[PATCH] D36468: [ELF] - Linkerscript: disallow discarding COMMON.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 9 08:00:55 PDT 2017


grimar updated this revision to Diff 110394.
grimar retitled this revision from "[ELF] - Allow discard COMMON from linkerscript." to "[ELF] - Linkerscript: disallow discarding COMMON.".
grimar edited the summary of this revision.

https://reviews.llvm.org/D36468

Files:
  ELF/LinkerScript.cpp
  test/ELF/linkerscript/discard-section-err.s


Index: test/ELF/linkerscript/discard-section-err.s
===================================================================
--- test/ELF/linkerscript/discard-section-err.s
+++ test/ELF/linkerscript/discard-section-err.s
@@ -21,3 +21,10 @@
 # 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
+
+# RUN: echo "SECTIONS { /DISCARD/ : { *(COMMON) } }" > %t.script
+# RUN: not ld.lld -pie -o %t --script %t.script %t.o 2>&1 | \
+# RUN:   FileCheck -check-prefix=COMMON %s
+# COMMON: discarding COMMON section is not allowed
+
+.comm foo,4,4
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ 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);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36468.110394.patch
Type: text/x-patch
Size: 1261 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170809/01e4d2ae/attachment.bin>


More information about the llvm-commits mailing list