[PATCH] D62768: [ELF] Don't create an output section named `/DISCARD/` if it is assigned to the special phdr `NONE`

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 2 22:31:51 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL362356: [ELF] Don't create an output section named `/DISCARD/` if it is assigned to theā€¦ (authored by MaskRay, committed by ).

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62768/new/

https://reviews.llvm.org/D62768

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


Index: lld/trunk/test/ELF/linkerscript/discard-phdr.s
===================================================================
--- lld/trunk/test/ELF/linkerscript/discard-phdr.s
+++ lld/trunk/test/ELF/linkerscript/discard-phdr.s
@@ -10,7 +10,7 @@
 # RUN:  /DISCARD/ : { *(.discard) } :NONE \
 # RUN: }" > %t.script
 # RUN: ld.lld -o %t --script %t.script %t.o
-# RUN: llvm-readelf -S -l %t | FileCheck %s
+# RUN: llvm-readelf -S -l %t | FileCheck --implicit-check-not=/DISCARD/ %s
 
 ## Check that /DISCARD/ does not interfere with the assignment of segments to
 ## sections.
Index: lld/trunk/ELF/LinkerScript.cpp
===================================================================
--- lld/trunk/ELF/LinkerScript.cpp
+++ lld/trunk/ELF/LinkerScript.cpp
@@ -824,6 +824,9 @@
 }
 
 static bool isDiscardable(OutputSection &Sec) {
+  if (Sec.Name == "/DISCARD/")
+    return true;
+
   // We do not remove empty sections that are explicitly
   // assigned to any segment.
   if (!Sec.Phdrs.empty())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62768.202650.patch
Type: text/x-patch
Size: 989 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190603/67dd8d74/attachment.bin>


More information about the llvm-commits mailing list