Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -675,7 +675,7 @@ // 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 Index: test/ELF/entry.s =================================================================== --- test/ELF/entry.s +++ test/ELF/entry.s @@ -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