[PATCH] D35945: [ELF] - Linkerscript: better diagnostic for INPUT/GROUP commands.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 4 04:42:57 PDT 2017
grimar updated this revision to Diff 109708.
grimar added a comment.
- Reimplemented in a more generic way.
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: >>> location:{{.*}}.script:1
+
+# 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
@@ -251,16 +251,14 @@
}
void ScriptParser::addFile(StringRef S) {
- if (IsUnderSysroot && S.startswith("/")) {
- SmallString<128> PathData;
- StringRef Path = (Config->Sysroot + S).toStringRef(PathData);
- if (sys::fs::exists(Path)) {
- Driver->addFile(Saver.save(Path), /*WithLOption=*/false);
- return;
+ if (S.startswith("/")) {
+ if (IsUnderSysroot) {
+ SmallString<128> PathData;
+ StringRef Path = (Config->Sysroot + S).toStringRef(PathData);
+ if (sys::fs::exists(Path))
+ S = Saver.save(Path);
}
- }
- if (S.startswith("/")) {
Driver->addFile(S, /*WithLOption=*/false);
} else if (S.startswith("=")) {
if (Config->Sysroot.empty())
@@ -278,6 +276,9 @@
else
setError("unable to find " + S);
}
+
+ if (ErrorCount)
+ error(">>> location:" + getCurrentLocation());
}
void ScriptParser::readAsNeeded() {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35945.109708.patch
Type: text/x-patch
Size: 1969 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170804/4cbc3661/attachment.bin>
More information about the llvm-commits
mailing list