summaryrefslogtreecommitdiffstats
path: root/lld/ELF/DriverUtils.cpp
diff options
context:
space:
mode:
authorAlexander Richardson <arichardson.kde@gmail.com>2017-11-20 15:43:20 +0000
committerAlexander Richardson <arichardson.kde@gmail.com>2017-11-20 15:43:20 +0000
commit1de78471f524e79dc77ecacbe09fada47bfd7418 (patch)
treeb9fdcb325bdaf2133ff38f4a93cacd40666101af /lld/ELF/DriverUtils.cpp
parent24194525057b73ecc1d78b7853ce1bbd6ceaf9c2 (diff)
downloadbcm5719-llvm-1de78471f524e79dc77ecacbe09fada47bfd7418.tar.gz
bcm5719-llvm-1de78471f524e79dc77ecacbe09fada47bfd7418.zip
[ELF] Fall back to search dirs for linker scripts specified with -T
Summary: This matches the behaviour of ld.bfd: https://sourceware.org/binutils/docs/ld/Options.html#Options If scriptfile does not exist in the current directory, ld looks for it in the directories specified by any preceding '-L' options. Multiple '-T' options accumulate. Reviewers: ruiu, grimar Reviewed By: ruiu, grimar Subscribers: emaste, llvm-commits Differential Revision: https://reviews.llvm.org/D40129 llvm-svn: 318655
Diffstat (limited to 'lld/ELF/DriverUtils.cpp')
-rw-r--r--lld/ELF/DriverUtils.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lld/ELF/DriverUtils.cpp b/lld/ELF/DriverUtils.cpp
index ca13b309c4a..901760c439a 100644
--- a/lld/ELF/DriverUtils.cpp
+++ b/lld/ELF/DriverUtils.cpp
@@ -207,3 +207,12 @@ Optional<std::string> elf::searchLibrary(StringRef Name) {
}
return None;
}
+
+// If a linker script doesn't exist in the current directory, we also look for
+// the script in the '-L' search paths. This matches the behaviour of both '-T'
+// and linker script INPUT() directives in ld.bfd.
+Optional<std::string> elf::searchLinkerScript(StringRef Name) {
+ if (fs::exists(Name))
+ return Name.str();
+ return findFromSearchPaths(Name);
+}
OpenPOWER on IntegriCloud