Index: lld/ELF/ScriptLexer.cpp =================================================================== --- lld/ELF/ScriptLexer.cpp +++ lld/ELF/ScriptLexer.cpp @@ -176,6 +176,10 @@ if (s.startswith("\"")) return {s}; + // "/DISCARD/" is a special directive. + if (s == "/DISCARD/") + return {s}; + // Split S with operators as separators. std::vector ret; while (!s.empty()) { Index: lld/test/ELF/linkerscript/fill-with-discard.test =================================================================== --- /dev/null +++ lld/test/ELF/linkerscript/fill-with-discard.test @@ -0,0 +1,10 @@ +# REQUIRES: x86 +# RUN: llvm-mc /dev/null -o %t.o -filetype=obj -triple=x86_64-unknown-linux +# RUN: ld.lld -o %t --script %s %t.o + +## Check we are able to parse scripts where "/DISCARD/" follows a section fill expression. + +SECTIONS { + .foo : { *(.foo) } =0x90909090 + /DISCARD/ : { *(.bar) } +}