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()) 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.