[PATCH] D13668: [ELF2/LinkerScript] Fix OUTPUT_FORMAT directive parsing

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 12 13:47:48 PDT 2015


davide updated this revision to Diff 37163.
davide added a comment.

Now with the correct diff. I also renamed the test. Sorry for messing up the name at least a couple of times, but apparently the code was the only place where I got it right :)


http://reviews.llvm.org/D13668

Files:
  ELF/LinkerScript.cpp
  test/elf2/linkerscript-ouputformat.s

Index: test/elf2/linkerscript-ouputformat.s
===================================================================
--- test/elf2/linkerscript-ouputformat.s
+++ test/elf2/linkerscript-ouputformat.s
@@ -0,0 +1,12 @@
+# REQUIRES: x86
+# RUN: echo "OUTPUT_FORMAT(\"elf64-x86-64-default\", \"elf64-x86-64-big\", \
+# RUN: \"elf64-x86-64-big\")" > %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(\"elf64-x86-64-default\", \"elf64-x86-64-big\")" \
+# RUN:  > %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
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(")");
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13668.37163.patch
Type: text/x-patch
Size: 1211 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151012/404b7fb7/attachment.bin>


More information about the llvm-commits mailing list