[lld] r282427 - [ELF] - Fix for: Bug 30521 - lld exits non-zero return value linking a library with no entry symbol

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 26 12:04:42 PDT 2016


Author: grimar
Date: Mon Sep 26 14:04:42 2016
New Revision: 282427

URL: http://llvm.org/viewvc/llvm-project?rev=282427&view=rev
Log:
[ELF] - Fix for: Bug 30521 - lld exits non-zero return value linking a library with no entry symbol

PR30521 was about linking shared library. After r282295 code when linking -shared produced
"entry symbol not found" warning, what in combination with --fatal-errors failed linkage.

Patch fixes logic (and adds testcases) to follow next rules:

1) If entry was specified and not found report warning.
2) If entry was not specified then:
 a) Emit warning if not -shared.
 b) Do not emit warning if -shared.

Differential revision: https://reviews.llvm.org/D24913

Modified:
    lld/trunk/ELF/Driver.cpp
    lld/trunk/test/ELF/entry.s

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=282427&r1=282426&r2=282427&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Mon Sep 26 14:04:42 2016
@@ -675,7 +675,7 @@ template <class ELFT> void LinkerDriver:
     // if it is resolvable.
     Config->Entry = (Config->EMachine == EM_MIPS) ? "__start" : "_start";
   }
-  if (!HasEntryAddr) {
+  if (!HasEntryAddr && !Config->Entry.empty()) {
     if (Symtab.find(Config->Entry))
       Config->EntrySym = Symtab.addUndefined(Config->Entry);
     else

Modified: lld/trunk/test/ELF/entry.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/entry.s?rev=282427&r1=282426&r2=282427&view=diff
==============================================================================
--- lld/trunk/test/ELF/entry.s (original)
+++ lld/trunk/test/ELF/entry.s Mon Sep 26 14:04:42 2016
@@ -1,9 +1,16 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
+
 # RUN: ld.lld -e foobar %t1 -o %t2 2>&1 | FileCheck -check-prefix=WARN %s
 # RUN: llvm-readobj -file-headers %t2 | FileCheck -check-prefix=NOENTRY %s
+# RUN: ld.lld %t1 -o %t2 2>&1 | FileCheck -check-prefix=WARN2 %s
+
+# RUN: ld.lld -shared -e foobar %t1 -o %t2 2>&1 | FileCheck -check-prefix=WARN %s
+# RUN: ld.lld -shared --fatal-warnings -e entry %t1 -o %t2
+# RUN: ld.lld -shared --fatal-warnings %t1 -o %t2
+
 # RUN: ld.lld %t1 -o %t2 -e entry
 # RUN: llvm-readobj -file-headers %t2 | FileCheck -check-prefix=SYM %s
-# RUN: ld.lld %t1 -shared -o %t2 -e entry
+# RUN: ld.lld %t1 --fatal-warnings -shared -o %t2 -e entry
 # RUN: llvm-readobj -file-headers %t2 | FileCheck -check-prefix=DSO %s
 # RUN: ld.lld %t1 -o %t2 --entry=4096
 # RUN: llvm-readobj -file-headers %t2 | FileCheck -check-prefix=DEC %s
@@ -13,6 +20,7 @@
 # RUN: llvm-readobj -file-headers %t2 | FileCheck -check-prefix=OCT %s
 
 # WARN: entry symbol foobar not found, assuming 0
+# WARN2: entry symbol _start not found, assuming 0
 
 # NOENTRY: Entry: 0x0
 # SYM: Entry: 0x11000




More information about the llvm-commits mailing list