summaryrefslogtreecommitdiff
path: root/lld/ELF/Driver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF/Driver.cpp')
-rw-r--r--lld/ELF/Driver.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index ed214ab29d4c..ed773f5e69f7 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -324,7 +324,7 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) {
return;
}
case file_magic::elf_shared_object: {
- if (config->isStatic || config->relocatable) {
+ if (config->isStatic) {
error("attempted static link of dynamic object " + path);
return;
}
@@ -1892,6 +1892,9 @@ void LinkerDriver::createFiles(opt::InputArgList &args) {
// For --{push,pop}-state.
std::vector<std::tuple<bool, bool, bool>> stack;
+ // -r implies -Bstatic and has precedence over -Bdynamic.
+ config->isStatic = config->relocatable;
+
// Iterate over argv to process input files and positional arguments.
std::optional<MemoryBufferRef> defaultScript;
InputFile::isInGroup = false;
@@ -1946,7 +1949,8 @@ void LinkerDriver::createFiles(opt::InputArgList &args) {
config->isStatic = true;
break;
case OPT_Bdynamic:
- config->isStatic = false;
+ if (!config->relocatable)
+ config->isStatic = false;
break;
case OPT_whole_archive:
inWholeArchive = true;