2
0
Fork 0
genodepkgs/overlay/llvm-11/lld/genode.patch

69 lines
2.6 KiB
Diff

diff --git a/ELF/Driver.cpp b/ELF/Driver.cpp
index 4637a3b30..11c12f032 100644
--- a/ELF/Driver.cpp
+++ b/ELF/Driver.cpp
@@ -254,12 +254,7 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) {
// file has a DT_SONAME or not because we haven't parsed it yet.
// Here, we set the default soname for the file because we might
// need it later.
- //
- // If a file was specified by -lfoo, the directory part is not
- // significant, as a user did not specify it. This behavior is
- // compatible with GNU.
- files.push_back(
- make<SharedFile>(mbref, withLOption ? path::filename(path) : path));
+ files.push_back(make<SharedFile>(MBRef, Path));
return;
case file_magic::bitcode:
case file_magic::elf_relocatable:
diff --git a/ELF/DriverUtils.cpp b/ELF/DriverUtils.cpp
index e33b07c0c..ece0e7343 100644
--- a/ELF/DriverUtils.cpp
+++ b/ELF/DriverUtils.cpp
@@ -205,14 +205,16 @@ std::string elf::createResponseFile(const opt::InputArgList &args) {
// Find a file by concatenating given paths. If a resulting path
// starts with "=", the character is replaced with a --sysroot value.
static Optional<std::string> findFile(StringRef path1, const Twine &path2) {
- SmallString<128> s;
+ SmallString<256> s;
if (path1.startswith("="))
path::append(s, config->sysroot, path1.substr(1), path2);
else
path::append(s, path1, path2);
- if (fs::exists(s))
- return std::string(s);
+ SmallString<256> RealPath;
+ fs::real_path(s, RealPath);
+ if (fs::exists(RealPath))
+ return RealPath.str().str();
return None;
}
@@ -228,10 +230,21 @@ Optional<std::string> elf::findFromSearchPaths(StringRef path) {
Optional<std::string> elf::searchLibraryBaseName(StringRef name) {
for (StringRef dir : config->searchPaths) {
if (!config->isStatic)
- if (Optional<std::string> s = findFile(dir, "lib" + name + ".so"))
- return s;
- if (Optional<std::string> s = findFile(dir, "lib" + name + ".a"))
- return s;
+ if (Name.size() == 1) {
+ if (Optional<std::string> S = findFile(dir, "lib" + Name + ".lib.so"))
+ return S;
+ if (Optional<std::string> S = findFile(dir, "lib" + Name + ".so"))
+ return S;
+ } else {
+ if (Optional<std::string> S = findFile(dir, Name + ".lib.so"))
+ return S;
+ if (Optional<std::string> S = findFile(Dir, "lib" + Name + ".so"))
+ return S;
+ }
+ if (Optional<std::string> S = findFile(dir, Name + ".lib.a"))
+ return S;
+ if (Optional<std::string> S = findFile(dir, "lib" + Name + ".a"))
+ return S;
}
return None;
}