summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2014-07-15 17:17:30 +0000
committerSimon Atanasyan <simon@atanasyan.com>2014-07-15 17:17:30 +0000
commit64c0ac2b35df65e38c966089f9a7ab9075bf7f58 (patch)
treec2093bee27114d037493703dc539241db0ab021e /lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
parentbc94c94be40d289948b4043fe4d973295061e484 (diff)
downloadbcm5719-llvm-64c0ac2b35df65e38c966089f9a7ab9075bf7f58.tar.gz
bcm5719-llvm-64c0ac2b35df65e38c966089f9a7ab9075bf7f58.zip
[ELF] Implement parsing `-l` prefixed items in the `GROUP` linker script command.
There are two forms of `-l` prefixed expression: * -l<libname> * -l:<filename> In the first case a linker should construct a full library name `lib + libname + .[so|a]` and search this library as usual. In the second case a linker should use the `<filename>` as is and search this file through library search directories. The patch reviewed by Shankar Easwaran. llvm-svn: 213077
Diffstat (limited to 'lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp')
-rw-r--r--lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp b/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
index 23036bca9f9..fe33d403d10 100644
--- a/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
+++ b/lld/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
@@ -163,18 +163,23 @@ static void buildSearchPath(SmallString<128> &path, StringRef dir,
}
ErrorOr<StringRef> ELFLinkingContext::searchLibrary(StringRef libName) const {
+ bool hasColonPrefix = libName[0] == ':';
+ Twine soName =
+ hasColonPrefix ? libName.drop_front() : Twine("lib", libName) + ".so";
+ Twine archiveName =
+ hasColonPrefix ? libName.drop_front() : Twine("lib", libName) + ".a";
SmallString<128> path;
for (StringRef dir : _inputSearchPaths) {
// Search for dynamic library
if (!_isStaticExecutable) {
buildSearchPath(path, dir, _sysrootPath);
- llvm::sys::path::append(path, Twine("lib") + libName + ".so");
+ llvm::sys::path::append(path, soName);
if (llvm::sys::fs::exists(path.str()))
return StringRef(*new (_allocator) std::string(path.str()));
}
// Search for static libraries too
buildSearchPath(path, dir, _sysrootPath);
- llvm::sys::path::append(path, Twine("lib") + libName + ".a");
+ llvm::sys::path::append(path, archiveName);
if (llvm::sys::fs::exists(path.str()))
return StringRef(*new (_allocator) std::string(path.str()));
}
OpenPOWER on IntegriCloud