summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Driver.cpp
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2017-04-12 00:13:48 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2017-04-12 00:13:48 +0000
commita76349bffe3ad01cfffbc14f8077ab2df65314aa (patch)
treea5e7edbae0cd51bb0363de7cde64d2665162c679 /lld/ELF/Driver.cpp
parent13c8daf57ad364852abdfaca369f05459eb01b7f (diff)
downloadbcm5719-llvm-a76349bffe3ad01cfffbc14f8077ab2df65314aa.tar.gz
bcm5719-llvm-a76349bffe3ad01cfffbc14f8077ab2df65314aa.zip
[lld] Keep full library path in DT_NEEDED.
Fixes PR32572. When (a) a library has no soname and (b) library is given on the command line with path (and not through -L/-l flags) DT_NEEDED entry for such library keeps the path as given. This behavior is consistent with gold and bfd, and is used in compiler-rt test suite. This is a second attempt after r300007 got reverted. This time relro-omagic test is changed in a way to avoid hardcoding the path to the test directory in the objdump'd binary. llvm-svn: 300011
Diffstat (limited to 'lld/ELF/Driver.cpp')
-rw-r--r--lld/ELF/Driver.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 8e7ada6ec10..8eb95f188b7 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -153,7 +153,7 @@ LinkerDriver::getArchiveMembers(MemoryBufferRef MB) {
// Opens and parses a file. Path has to be resolved already.
// Newly created memory buffers are owned by this driver.
-void LinkerDriver::addFile(StringRef Path) {
+void LinkerDriver::addFile(StringRef Path, bool WithLOption) {
using namespace sys::fs;
Optional<MemoryBufferRef> Buffer = readFile(Path);
@@ -184,6 +184,11 @@ void LinkerDriver::addFile(StringRef Path) {
return;
}
Files.push_back(createSharedFile(MBRef));
+ // If the library is found at an explicitly given path use the entire path
+ // as he default soname. Such libraries should not require RPATH or
+ // LD_LIBRARY_PATH to run.
+ Files.back()->DefaultSoName =
+ WithLOption ? sys::path::filename(Path) : Path;
return;
default:
if (InLib)
@@ -196,7 +201,7 @@ void LinkerDriver::addFile(StringRef Path) {
// Add a given library by searching it from input search paths.
void LinkerDriver::addLibrary(StringRef Name) {
if (Optional<std::string> Path = searchLibrary(Name))
- addFile(*Path);
+ addFile(*Path, /*WithLOption=*/true);
else
error("unable to find library -l" + Name);
}
@@ -762,7 +767,7 @@ void LinkerDriver::createFiles(opt::InputArgList &Args) {
addLibrary(Arg->getValue());
break;
case OPT_INPUT:
- addFile(Arg->getValue());
+ addFile(Arg->getValue(), /*WithLOption=*/false);
break;
case OPT_alias_script_T:
case OPT_script:
OpenPOWER on IntegriCloud