[PATCH] D27831: [ELF] - Linkerscript: Fall back to search paths when INCLUDE not found

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 15 15:34:59 PST 2016


arichardson created this revision.
arichardson added reviewers: ruiu, grimar.
arichardson added a subscriber: llvm-commits.
arichardson set the repository for this revision to rL LLVM.
arichardson added a project: lld.

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.


Repository:
  rL LLVM

https://reviews.llvm.org/D27831

Files:
  ELF/LinkerScript.cpp


Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -1185,7 +1185,15 @@
 
 void ScriptParser::readInclude() {
   StringRef Tok = next();
-  auto MBOrErr = MemoryBuffer::getFile(unquote(Tok));
+  auto Unquoted = unquote(Tok);
+  // 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(Unquoted);
+  if (!MBOrErr) {
+    if (auto Path = findFromSearchPaths(Unquoted))
+      MBOrErr = MemoryBuffer::getFile(*Path);
+  }
   if (!MBOrErr) {
     setError("cannot open " + Tok);
     return;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27831.81678.patch
Type: text/x-patch
Size: 750 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161215/da018e6f/attachment.bin>


More information about the llvm-commits mailing list