[lld] r288883 - Make a decision about whether we should warn on missing entry or not early.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 6 20:06:21 PST 2016


Author: ruiu
Date: Tue Dec  6 22:06:21 2016
New Revision: 288883

URL: http://llvm.org/viewvc/llvm-project?rev=288883&view=rev
Log:
Make a decision about whether we should warn on missing entry or not early.

Config->WarnMissingEntry is a single-purpose boolean variable, and
I think it's easier to understand than Config->HasEntry.

Modified:
    lld/trunk/ELF/Config.h
    lld/trunk/ELF/Driver.cpp
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=288883&r1=288882&r2=288883&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Tue Dec  6 22:06:21 2016
@@ -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;

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=288883&r1=288882&r2=288883&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Tue Dec  6 22:06:21 2016
@@ -521,7 +521,6 @@ void LinkerDriver::readConfigs(opt::Inpu
   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::Inpu
   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

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=288883&r1=288882&r2=288883&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Dec  6 22:06:21 2016
@@ -1412,14 +1412,14 @@ template <class ELFT> typename ELFT::uin
 
   // 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;




More information about the llvm-commits mailing list