Index: ELF/LinkerScript.cpp =================================================================== --- ELF/LinkerScript.cpp +++ ELF/LinkerScript.cpp @@ -211,6 +211,14 @@ void LinkerScript::readOutputFormat() { // Error checking only for now. expect("("); + StringRef Tok = next(); + Tok = next(); + if (Tok == ")") + return; + if (Tok != ",") + error("unexpected token: " + Tok); + next(); + expect(","); next(); expect(")"); } Index: test/elf2/linkerscript-ouputformat.s =================================================================== --- test/elf2/linkerscript-ouputformat.s +++ test/elf2/linkerscript-ouputformat.s @@ -0,0 +1,10 @@ +# REQUIRES: x86 +# RUN: echo "OUTPUT_FORMAT(x, y, z)" > %t.script +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-freebsd %s -o %t1 +# RUN: ld.lld2 -shared -o %t2 %t1 %t.script +# RUN: llvm-readobj %t2 > /dev/null + +# RUN: echo "OUTPUT_FORMAT(x, y)" > %t.script +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-freebsd %s -o %t1 +# RUN: not ld.lld2 -shared -o %t2 %t1 %t.script +# RUN: llvm-readobj %t2 > /dev/null