Index: ELF/LinkerScript.cpp =================================================================== --- ELF/LinkerScript.cpp +++ ELF/LinkerScript.cpp @@ -1217,8 +1217,13 @@ setError("unknown command " + Tok); } Cmd->Phdrs = readOutputSectionPhdrs(); - if (peek().startswith("=")) - Cmd->Filler = readOutputSectionFiller(next().drop_front()); + if (peek().startswith("=")) { + StringRef Filler = next().drop_front(); + // GNU linkers accepts a space between '=' and fill expression. + if (Filler.empty()) + Filler = next(); + Cmd->Filler = readOutputSectionFiller(Filler); + } return Cmd; } Index: test/ELF/linkerscript/sections-padding.s =================================================================== --- test/ELF/linkerscript/sections-padding.s +++ test/ELF/linkerscript/sections-padding.s @@ -31,6 +31,11 @@ # RUN: | FileCheck --check-prefix=ERR2 %s # ERR2: invalid filler expression: 0x99XX +## Check case with space between '=' and expression: +# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } = 0x1122 }" > %t.script +# RUN: ld.lld -o %t.out --script %t.script %t +# RUN: llvm-objdump -s %t.out | FileCheck -check-prefix=YES %s + .section .mysec.1,"a" .align 16 .byte 0x66