[PATCH] D29640: [ELF] - Linkerscript - fix handling of OUTPUT_ARCH command.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 7 07:13:55 PST 2017


grimar created this revision.

OUTPUT_ARCH command can contain architecture valuse separated with ":", like:

OUTPUT_ARCH(i386:x86-64)

I think r294006 "Handle numbers followed by ":" in linker scripts." broke that,
because handles ":" as separate token. So now LLD does not accept that.

This trivial patch fixes the issue and adds testcase.


https://reviews.llvm.org/D29640

Files:
  ELF/LinkerScript.cpp
  test/ELF/linkerscript/outputarch.s


Index: test/ELF/linkerscript/outputarch.s
===================================================================
--- test/ELF/linkerscript/outputarch.s
+++ test/ELF/linkerscript/outputarch.s
@@ -8,3 +8,8 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-freebsd %s -o %t1
 # RUN: not ld.lld -shared -o %t2 %t1 %t.script
 # RUN: llvm-readobj %t2 > /dev/null
+
+# RUN: echo "OUTPUT_ARCH(i386:x86-64)" > %t.script
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-freebsd %s -o %t1
+# RUN: ld.lld -o %t2 %t1 %t.script
+# RUN: llvm-readobj %t2 > /dev/null
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -1249,6 +1249,9 @@
   // Error checking only for now.
   expect("(");
   skip();
+  // Handle cases like i386:x86-64.
+  if (consume(":"))
+    skip();
   expect(")");
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29640.87427.patch
Type: text/x-patch
Size: 880 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170207/7d94d300/attachment.bin>


More information about the llvm-commits mailing list