[ELF2/LinkerScript] Fix OUTPUT_FORMAT directive parsing
Differential Revision: http://reviews.llvm.org/D13668
llvm-svn: 250106
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index f255da3..4d05e10 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -212,6 +212,14 @@
// Error checking only for now.
expect("(");
next();
+ StringRef Tok = next();
+ if (Tok == ")")
+ return;
+ if (Tok != ",")
+ error("unexpected token: " + Tok);
+ next();
+ expect(",");
+ next();
expect(")");
}
diff --git a/lld/test/elf2/linkerscript-ouputformat.s b/lld/test/elf2/linkerscript-ouputformat.s
new file mode 100644
index 0000000..9de9cc6
--- /dev/null
+++ b/lld/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