[lld] r254004 - ELF: Improve error handling of unknown emulation names.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 24 10:55:37 PST 2015


Author: ruiu
Date: Tue Nov 24 12:55:36 2015
New Revision: 254004

URL: http://llvm.org/viewvc/llvm-project?rev=254004&view=rev
Log:
ELF: Improve error handling of unknown emulation names.

This patch reverts r253985 and implements the same feature
in a less intrusive way.

Modified:
    lld/trunk/ELF/Driver.cpp

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=254004&r1=254003&r2=254004&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Tue Nov 24 12:55:36 2015
@@ -52,12 +52,8 @@ static std::pair<ELFKind, uint16_t> pars
     return {ELF64LEKind, EM_X86_64};
   if (S == "aarch64linux")
     return {ELF64LEKind, EM_AARCH64};
-  if (S == "i386pe")
-    return {ELFNoneKind, EM_386};
-  if (S == "i386pep")
-    return {ELFNoneKind, EM_X86_64};
-  if (S == "thumb2pe")
-    return {ELFNoneKind, EM_ARM};
+  if (S == "i386pe" || S == "i386pep" || S == "thumb2pe")
+    error("Windows targets are not supported on the ELF frontend: " + S);
   error("Unknown emulation: " + S);
 }
 
@@ -110,21 +106,9 @@ static bool hasZOption(opt::InputArgList
 }
 
 void LinkerDriver::main(ArrayRef<const char *> ArgsArr) {
+  initSymbols();
 
   opt::InputArgList Args = parseArgs(&Alloc, ArgsArr);
-
-  if (auto *Arg = Args.getLastArg(OPT_m)) {
-    StringRef S = Arg->getValue();
-    std::pair<ELFKind, uint16_t> P = parseEmulation(S);
-    Config->EKind = P.first;
-    Config->EMachine = P.second;
-    Config->Emulation = S;
-  }
-
-  if((Config->EKind == ELFNoneKind) && (Config->EMachine !=  EM_NONE))
-    error("windows coff targets aren't supported on the gnu frontend.");
-
-  initSymbols();
   createFiles(Args);
 
   // Traditional linkers can generate re-linkable object files instead
@@ -161,6 +145,14 @@ void LinkerDriver::createFiles(opt::Inpu
   if (!RPaths.empty())
     Config->RPath = llvm::join(RPaths.begin(), RPaths.end(), ":");
 
+  if (auto *Arg = Args.getLastArg(OPT_m)) {
+    StringRef S = Arg->getValue();
+    std::pair<ELFKind, uint16_t> P = parseEmulation(S);
+    Config->EKind = P.first;
+    Config->EMachine = P.second;
+    Config->Emulation = S;
+  }
+
   Config->AllowMultipleDefinition = Args.hasArg(OPT_allow_multiple_definition);
   Config->Bsymbolic = Args.hasArg(OPT_Bsymbolic);
   Config->DiscardAll = Args.hasArg(OPT_discard_all);




More information about the llvm-commits mailing list