Make a decision about whether we should warn on missing entry or not early.
authorRui Ueyama <ruiu@google.com>
Wed, 7 Dec 2016 04:06:21 +0000 (04:06 +0000)
committerRui Ueyama <ruiu@google.com>
Wed, 7 Dec 2016 04:06:21 +0000 (04:06 +0000)
Config->WarnMissingEntry is a single-purpose boolean variable, and
I think it's easier to understand than Config->HasEntry.

llvm-svn: 288883

lld/ELF/Config.h
lld/ELF/Driver.cpp
lld/ELF/Writer.cpp

index d9aec9e..9d7be7d 100644 (file)
@@ -107,7 +107,6 @@ struct Configuration {
   bool GcSections;
   bool GdbIndex;
   bool GnuHash = false;
-  bool HasEntry = false;
   bool ICF;
   bool Mips64EL = false;
   bool MipsN32Abi = false;
@@ -131,6 +130,7 @@ struct Configuration {
   bool Trace;
   bool Verbose;
   bool WarnCommon;
+  bool WarnMissingEntry;
   bool ZCombreloc;
   bool ZExecstack;
   bool ZNodelete;
index 58dd8d6..e891f7c 100644 (file)
@@ -521,7 +521,6 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
   Config->EnableNewDtags = !Args.hasArg(OPT_disable_new_dtags);
   Config->ExportDynamic = Args.hasArg(OPT_export_dynamic);
   Config->FatalWarnings = Args.hasArg(OPT_fatal_warnings);
-  Config->HasEntry = Args.hasArg(OPT_entry);
   Config->GcSections = getArg(Args, OPT_gc_sections, OPT_no_gc_sections, false);
   Config->GdbIndex = Args.hasArg(OPT_gdb_index);
   Config->ICF = Args.hasArg(OPT_icf);
@@ -577,6 +576,7 @@ 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
index 9f2eb14..6330d70 100644 (file)
@@ -1412,14 +1412,14 @@ template <class ELFT> typename ELFT::uint Writer<ELFT>::getEntryAddr() {
 
   // Case 4
   if (OutputSectionBase *Sec = findSection(".text")) {
-    if (!Config->Shared || Config->HasEntry)
+    if (Config->WarnMissingEntry)
       warn("cannot find entry symbol " + Config->Entry + "; defaulting to 0x" +
            utohexstr(Sec->Addr));
     return Sec->Addr;
   }
 
   // Case 5
-  if (!Config->Shared || Config->HasEntry)
+  if (Config->WarnMissingEntry)
     warn("cannot find entry symbol " + Config->Entry +
          "; not setting start address");
   return 0;