[lld] r349557 - Reject .so files if -static is given.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 18 14:30:23 PST 2018


Author: ruiu
Date: Tue Dec 18 14:30:23 2018
New Revision: 349557

URL: http://llvm.org/viewvc/llvm-project?rev=349557&view=rev
Log:
Reject .so files if -static is given.

Previously, if you pass -static to lld, lld searches for only foo.a
and skips foo.so for -lfoo option. However, it didn't reject .so files
if you directly pass their pathnames via the command line, which is a bug.

Differential Revision: https://reviews.llvm.org/D55845

Added:
    lld/trunk/test/ELF/static-error.s
Modified:
    lld/trunk/ELF/Driver.cpp
    lld/trunk/test/ELF/tls-static.s

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=349557&r1=349556&r2=349557&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Tue Dec 18 14:30:23 2018
@@ -224,7 +224,7 @@ void LinkerDriver::addFile(StringRef Pat
     return;
   }
   case file_magic::elf_shared_object:
-    if (Config->Relocatable) {
+    if (Config->Static || Config->Relocatable) {
       error("attempted static link of dynamic object " + Path);
       return;
     }

Added: lld/trunk/test/ELF/static-error.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/static-error.s?rev=349557&view=auto
==============================================================================
--- lld/trunk/test/ELF/static-error.s (added)
+++ lld/trunk/test/ELF/static-error.s Tue Dec 18 14:30:23 2018
@@ -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

Modified: lld/trunk/test/ELF/tls-static.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/tls-static.s?rev=349557&r1=349556&r2=349557&view=diff
==============================================================================
--- lld/trunk/test/ELF/tls-static.s (original)
+++ lld/trunk/test/ELF/tls-static.s Tue Dec 18 14:30:23 2018
@@ -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:




More information about the llvm-commits mailing list