Print a warning message if ENTRY() symbol is not found.
authorRui Ueyama <ruiu@google.com>
Thu, 8 Dec 2016 22:26:31 +0000 (22:26 +0000)
committerRui Ueyama <ruiu@google.com>
Thu, 8 Dec 2016 22:26:31 +0000 (22:26 +0000)
llvm-svn: 289146

lld/ELF/Driver.cpp
lld/test/ELF/linkerscript/linkerscript.s

index a2c96b8..67f0678 100644 (file)
@@ -570,7 +570,6 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
   Config->SortSection = getSortKind(Args);
   Config->Target2 = getTarget2Option(Args);
   Config->UnresolvedSymbols = getUnresolvedSymbolOption(Args);
-  Config->WarnMissingEntry = (Args.hasArg(OPT_entry) || !Config->Shared);
 
   // --omagic is an option to create old-fashioned executables in which
   // .text segments are writable. Today, the option is still in use to
@@ -779,6 +778,7 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) {
   // Use default entry point name if no name was given via the command
   // line nor linker scripts. For some reason, MIPS entry point name is
   // different from others.
+  Config->WarnMissingEntry = (!Config->Entry.empty() || !Config->Shared);
   if (Config->Entry.empty() && !Config->Relocatable)
     Config->Entry = (Config->EMachine == EM_MIPS) ? "__start" : "_start";
 
index 718e1d2..2b7ad8e 100644 (file)
 
 # ENTRY-SCRIPT: Entry: 0x1
 
+# RUN: echo "ENTRY(no_such_symbol);" > %t.script
+# RUN: ld.lld -o %t2 %t.script %t 2>&1 | \
+# RUN:   FileCheck -check-prefix=ENTRY-MISSING %s
+
+# ENTRY-MISSING: warning: cannot find entry symbol no_such_symbol
+
 # RUN: echo "OUTPUT_FORMAT(elf64-x86-64) /*/*/ GROUP(\"%t\" )" > %t.script
 # RUN: ld.lld -o %t2 %t.script
 # RUN: llvm-readobj %t2 > /dev/null