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

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 10 01:07:59 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL310554: [ELF] - Linkerscript: disallow discarding COMMON. (authored by grimar).

Changed prior to commit:
  https://reviews.llvm.org/D36468?vs=110394&id=110525#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36468

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


Index: lld/trunk/ELF/LinkerScript.cpp
===================================================================
--- lld/trunk/ELF/LinkerScript.cpp
+++ lld/trunk/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);
   }
Index: lld/trunk/test/ELF/linkerscript/discard-section-err.s
===================================================================
--- lld/trunk/test/ELF/linkerscript/discard-section-err.s
+++ lld/trunk/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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36468.110525.patch
Type: text/x-patch
Size: 1321 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170810/f7973687/attachment.bin>


More information about the llvm-commits mailing list