[lld] r290247 - [ELF] - Linkerscript: Fall back to search paths when INCLUDE not found
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 21 01:42:25 PST 2016
Author: grimar
Date: Wed Dec 21 03:42:25 2016
New Revision: 290247
URL: http://llvm.org/viewvc/llvm-project?rev=290247&view=rev
Log:
[ELF] - Linkerscript: Fall back to search paths when INCLUDE not found
>From https://sourceware.org/binutils/docs/ld/File-Commands.html:
The file will be searched for in the current directory, and in any
directory specified with the -L option.
Patch done by Alexander Richardson.
Differential revision: https://reviews.llvm.org/D27831
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/test/ELF/linkerscript/linkerscript.s
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=290247&r1=290246&r2=290247&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Wed Dec 21 03:42:25 2016
@@ -1171,8 +1171,14 @@ void ScriptParser::readGroup() {
}
void ScriptParser::readInclude() {
- StringRef Tok = next();
- auto MBOrErr = MemoryBuffer::getFile(unquote(Tok));
+ StringRef Tok = unquote(next());
+ // https://sourceware.org/binutils/docs/ld/File-Commands.html:
+ // The file will be searched for in the current directory, and in any
+ // directory specified with the -L option.
+ auto MBOrErr = MemoryBuffer::getFile(Tok);
+ if (!MBOrErr)
+ if (Optional<std::string> Path = findFromSearchPaths(Tok))
+ MBOrErr = MemoryBuffer::getFile(*Path);
if (!MBOrErr) {
setError("cannot open " + Tok);
return;
Modified: lld/trunk/test/ELF/linkerscript/linkerscript.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/linkerscript.s?rev=290247&r1=290246&r2=290247&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/linkerscript.s (original)
+++ lld/trunk/test/ELF/linkerscript/linkerscript.s Wed Dec 21 03:42:25 2016
@@ -33,6 +33,14 @@
# RUN: ld.lld %t.script1
# RUN: llvm-readobj %t2 > /dev/null
+# RUN: echo "INCLUDE \"foo.script\"" > %t.script
+# RUN: echo "OUTPUT(\"%t.out\")" > %T/foo.script
+# RUN: not ld.lld %t.script > %t.log 2>&1
+# RUN: FileCheck -check-prefix=INCLUDE_ERR %s < %t.log
+# INCLUDE_ERR: error: {{.+}}.script:1: cannot open foo.script
+# INCLUDE_ERR-NEXT: error: {{.+}}.script:1: INCLUDE "foo.script"
+# RUN: ld.lld -L %T %t.script %t
+
# RUN: echo "FOO(BAR)" > %t.script
# RUN: not ld.lld -o foo %t.script > %t.log 2>&1
# RUN: FileCheck -check-prefix=ERR1 %s < %t.log
More information about the llvm-commits
mailing list