summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShankar Easwaran <shankare@codeaurora.org>2013-04-05 03:50:15 +0000
committerShankar Easwaran <shankare@codeaurora.org>2013-04-05 03:50:15 +0000
commita4323a5cca42dfce15b1a63e934ea3d2ce5572de (patch)
tree243c19278d888ec7bdebd6c43bfc36c6b6e2271c
parent95923058eb748facc764f52d5deb928a564c5038 (diff)
downloadbcm5719-llvm-a4323a5cca42dfce15b1a63e934ea3d2ce5572de.tar.gz
bcm5719-llvm-a4323a5cca42dfce15b1a63e934ea3d2ce5572de.zip
This fixes a SIGSEGV failure in ReaderArchive while trying to trace what
InputFile is being pulled from the Archive library to resolve a symbol. The buffer which was being used was already being handed over to the MemoryBuffer object and was being accessed after the hand over. Moving it before the buffer is handed over. llvm-svn: 178838
-rw-r--r--lld/lib/ReaderWriter/ELF/ELFTargetInfo.cpp33
-rw-r--r--lld/lib/ReaderWriter/ReaderArchive.cpp4
2 files changed, 27 insertions, 10 deletions
diff --git a/lld/lib/ReaderWriter/ELF/ELFTargetInfo.cpp b/lld/lib/ReaderWriter/ELF/ELFTargetInfo.cpp
index 338096d3a2c..577f5a86107 100644
--- a/lld/lib/ReaderWriter/ELF/ELFTargetInfo.cpp
+++ b/lld/lib/ReaderWriter/ELF/ELFTargetInfo.cpp
@@ -67,7 +67,7 @@ bool ELFTargetInfo::validate(raw_ostream &diagnostics) {
_entrySymbolName = "_start";
}
}
-
+
if (_inputFiles.empty()) {
diagnostics << "No input files\n";
return true;
@@ -144,14 +144,31 @@ std::unique_ptr<ELFTargetInfo> ELFTargetInfo::create(llvm::Triple triple) {
}
bool ELFTargetInfo::appendLibrary(StringRef libName) {
- SmallString<128> fullPath;
+ bool foundFile = false;
+ StringRef pathref;
for (StringRef dir : _inputSearchPaths) {
- // FIXME: need to handle other extensions, like .so
- fullPath.assign(dir);
- llvm::sys::path::append(fullPath, Twine("lib") + libName + ".a");
- StringRef pathref = fullPath.str();
- unsigned pathlen = pathref.size();
- if (llvm::sys::fs::exists(pathref)) {
+ // Search for dynamic library
+ if (!_isStaticExecutable) {
+ SmallString<128> dynlibPath;
+ dynlibPath.assign(dir);
+ llvm::sys::path::append(dynlibPath, Twine("lib") + libName + ".so");
+ pathref = dynlibPath.str();
+ if (llvm::sys::fs::exists(pathref)) {
+ foundFile = true;
+ }
+ }
+ // Search for static libraries too
+ if (!foundFile) {
+ SmallString<128> archivefullPath;
+ archivefullPath.assign(dir);
+ llvm::sys::path::append(archivefullPath, Twine("lib") + libName + ".a");
+ pathref = archivefullPath.str();
+ if (llvm::sys::fs::exists(pathref)) {
+ foundFile = true;
+ }
+ }
+ if (foundFile) {
+ unsigned pathlen = pathref.size();
char *x = _extraStrings.Allocate<char>(pathlen);
memcpy(x, pathref.data(), pathlen);
appendInputFile(StringRef(x,pathlen));
diff --git a/lld/lib/ReaderWriter/ReaderArchive.cpp b/lld/lib/ReaderWriter/ReaderArchive.cpp
index d3287dd429d..1928e2fa0f7 100644
--- a/lld/lib/ReaderWriter/ReaderArchive.cpp
+++ b/lld/lib/ReaderWriter/ReaderArchive.cpp
@@ -45,9 +45,9 @@ public:
OwningPtr<MemoryBuffer> buff;
if (ci->getMemoryBuffer(buff, true))
return nullptr;
- std::unique_ptr<MemoryBuffer> mb(buff.take());
if (_targetInfo.logInputFiles())
llvm::outs() << buff->getBufferIdentifier() << "\n";
+ std::unique_ptr<MemoryBuffer> mb(buff.take());
if (_targetInfo.parseFile(mb, result))
return nullptr;
@@ -153,7 +153,7 @@ public:
}
}
- std::unordered_map<StringRef,
+ std::unordered_map<StringRef,
llvm::object::Archive::child_iterator> _symbolMemberMap;
}; // class FileArchive
OpenPOWER on IntegriCloud