[lld] r207689 - [ELF] Factor out the code builds a library search directory path
Simon Atanasyan
simon at atanasyan.com
Wed Apr 30 12:03:51 PDT 2014
Author: atanasyan
Date: Wed Apr 30 14:03:51 2014
New Revision: 207689
URL: http://llvm.org/viewvc/llvm-project?rev=207689&view=rev
Log:
[ELF] Factor out the code builds a library search directory path
into the separate function.
No functional changes.
Modified:
lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp?rev=207689&r1=207688&r2=207689&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp Wed Apr 30 14:03:51 2014
@@ -215,6 +215,16 @@ ELFLinkingContext::create(llvm::Triple t
}
}
+static void buildSearchPath(SmallString<128> &path, StringRef dir,
+ StringRef sysRoot) {
+ if (!dir.startswith("=/"))
+ path.assign(dir);
+ else {
+ path.assign(sysRoot);
+ path.append(dir.substr(1));
+ }
+}
+
ErrorOr<StringRef> ELFLinkingContext::searchLibrary(StringRef libName) const {
bool foundFile = false;
StringRef pathref;
@@ -222,13 +232,7 @@ ErrorOr<StringRef> ELFLinkingContext::se
for (StringRef dir : _inputSearchPaths) {
// Search for dynamic library
if (!_isStaticExecutable) {
- path.clear();
- if (dir.startswith("=/")) {
- path.assign(_sysrootPath);
- path.append(dir.substr(1));
- } else {
- path.assign(dir);
- }
+ buildSearchPath(path, dir, _sysrootPath);
llvm::sys::path::append(path, Twine("lib") + libName + ".so");
pathref = path.str();
if (llvm::sys::fs::exists(pathref)) {
@@ -237,13 +241,7 @@ ErrorOr<StringRef> ELFLinkingContext::se
}
// Search for static libraries too
if (!foundFile) {
- path.clear();
- if (dir.startswith("=/")) {
- path.assign(_sysrootPath);
- path.append(dir.substr(1));
- } else {
- path.assign(dir);
- }
+ buildSearchPath(path, dir, _sysrootPath);
llvm::sys::path::append(path, Twine("lib") + libName + ".a");
pathref = path.str();
if (llvm::sys::fs::exists(pathref)) {
More information about the llvm-commits
mailing list