[PATCH] D35945: [ELF] - Linkerscript: better diagnostic for INPUT/GROUP commands.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 3 04:10:42 PDT 2017


grimar updated this revision to Diff 109511.
grimar retitled this revision from "[ELF] - Linkerscript: better disgnostic for INPUT/GROUP commands." to "[ELF] - Linkerscript: better diagnostic for INPUT/GROUP commands.".
grimar added a comment.

- Addressed review comment.


https://reviews.llvm.org/D35945

Files:
  ELF/ScriptParser.cpp
  test/ELF/linkerscript/group.s


Index: test/ELF/linkerscript/group.s
===================================================================
--- test/ELF/linkerscript/group.s
+++ test/ELF/linkerscript/group.s
@@ -51,6 +51,20 @@
 # RUN: ld.lld -o %t2 %t.script
 # RUN: llvm-readobj %t2 > /dev/null
 
+# RUN: echo "INPUT(/no_such_file)" > %t.script
+# RUN: not ld.lld -o %t2 %t.script 2>&1 | FileCheck -check-prefix=ERR %s
+# ERR: cannot open {{.*}}no_such_file: {{[Nn]}}o such file or directory
+# ERR: {{.*}}.script:1: unable to find /no_such_file
+
+# RUN: echo "INPUT(AS_NEEDED(/no_such_file))" > %t.script
+# RUN: not ld.lld -o %t2 %t.script 2>&1 | FileCheck -check-prefix=ERR %s
+
+# RUN: echo "GROUP(/no_such_file)" > %t.script
+# RUN: not ld.lld -o %t2 %t.script 2>&1 | FileCheck -check-prefix=ERR %s
+
+# RUN: echo "GROUP(AS_NEEDED(/no_such_file))" > %t.script
+# RUN: not ld.lld -o %t2 %t.script 2>&1 | FileCheck -check-prefix=ERR %s
+
 .globl _start
 _start:
   ret
Index: ELF/ScriptParser.cpp
===================================================================
--- ELF/ScriptParser.cpp
+++ ELF/ScriptParser.cpp
@@ -282,8 +282,13 @@
   expect("(");
   bool Orig = Config->AsNeeded;
   Config->AsNeeded = true;
-  while (!Error && !consume(")"))
-    addFile(unquote(next()));
+  while (!ErrorCount && !consume(")")) {
+    StringRef File = unquote(next());
+    addFile(File);
+    if (ErrorCount)
+      setError("unable to find " + File);
+  }
+
   Config->AsNeeded = Orig;
 }
 
@@ -304,11 +309,16 @@
 
 void ScriptParser::readGroup() {
   expect("(");
-  while (!Error && !consume(")")) {
-    if (consume("AS_NEEDED"))
+  while (!Error && !consume(")") && !ErrorCount) {
+    if (consume("AS_NEEDED")) {
       readAsNeeded();
-    else
-      addFile(unquote(next()));
+      continue;
+    }
+
+    StringRef File = unquote(next());
+    addFile(File);
+    if (ErrorCount)
+      setError("unable to find " + File);
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35945.109511.patch
Type: text/x-patch
Size: 1906 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170803/84dd49c3/attachment.bin>


More information about the llvm-commits mailing list