From 9e5f5effe58a67b7ad37e6f3317e90c63f023729 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 7 Dec 2016 04:06:21 +0000 Subject: [PATCH] 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. llvm-svn: 288883 --- lld/ELF/Config.h | 2 +- lld/ELF/Driver.cpp | 2 +- lld/ELF/Writer.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h index d9aec9e..9d7be7d 100644 --- a/lld/ELF/Config.h +++ b/lld/ELF/Config.h @@ -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; diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 58dd8d6..e891f7c 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -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 diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 9f2eb14..6330d70 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1412,14 +1412,14 @@ template typename ELFT::uint Writer::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; -- 2.7.4