summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/Driver.cpp2
-rw-r--r--lld/test/ELF/static-error.s13
-rw-r--r--lld/test/ELF/tls-static.s1
3 files changed, 14 insertions, 2 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index a8582416732..1da557493c1 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -224,7 +224,7 @@ void LinkerDriver::addFile(StringRef Path, bool WithLOption) {
return;
}
case file_magic::elf_shared_object:
- if (Config->Relocatable) {
+ if (Config->Static || Config->Relocatable) {
error("attempted static link of dynamic object " + Path);
return;
}
diff --git a/lld/test/ELF/static-error.s b/lld/test/ELF/static-error.s
new file mode 100644
index 00000000000..1ae98ab2c32
--- /dev/null
+++ b/lld/test/ELF/static-error.s
@@ -0,0 +1,13 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/shared.s -o %t.o
+// RUN: ld.lld -shared -o %t.so %t.o
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: ld.lld -o /dev/null %t.o %t.so
+// RUN: not ld.lld -o /dev/null -static %t.o %t.so 2>&1 | FileCheck %s
+
+// CHECK: attempted static link of dynamic object
+
+.global _start
+_start:
+ nop
diff --git a/lld/test/ELF/tls-static.s b/lld/test/ELF/tls-static.s
index 3e1aead01a3..61d504b2e85 100644
--- a/lld/test/ELF/tls-static.s
+++ b/lld/test/ELF/tls-static.s
@@ -4,7 +4,6 @@
// RUN: ld.lld -static %t -o %tout
// RUN: ld.lld %t -o %tout
// RUN: ld.lld -shared %tso -o %tshared
-// RUN: ld.lld -static %t %tshared -o %tout
.global _start
_start:
OpenPOWER on IntegriCloud