[lld] r257076 - ELF: Move error checking code of the driver into one place. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 7 09:33:25 PST 2016
Author: ruiu
Date: Thu Jan 7 11:33:25 2016
New Revision: 257076
URL: http://llvm.org/viewvc/llvm-project?rev=257076&view=rev
Log:
ELF: Move error checking code of the driver into one place. NFC.
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=257076&r1=257075&r2=257076&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Thu Jan 7 11:33:25 2016
@@ -107,6 +107,24 @@ void LinkerDriver::addFile(StringRef Pat
}
}
+// Some command line options or some combinations of them are not allowed.
+// This function checks for such errors.
+static void checkOptions(opt::InputArgList &Args) {
+ // Traditional linkers can generate re-linkable object files instead
+ // of executables or DSOs. We don't support that since the feature
+ // does not seem to provide more value than the static archiver.
+ if (Args.hasArg(OPT_relocatable))
+ error("-r option is not supported. Use 'ar' command instead.");
+
+ // The MIPS ABI as of 2016 does not support the GNU-style symbol lookup
+ // table which is a relatively new feature.
+ if (Config->EMachine == EM_MIPS && Config->GnuHash)
+ error("The .gnu.hash section is not compatible with the MIPS target.");
+
+ if (Config->EMachine == EM_AMDGPU && !Config->Entry.empty())
+ error("-e option is not valid for AMDGPU.");
+}
+
static StringRef
getString(opt::InputArgList &Args, unsigned Key, StringRef Default = "") {
if (auto *Arg = Args.getLastArg(Key))
@@ -126,12 +144,7 @@ void LinkerDriver::main(ArrayRef<const c
opt::InputArgList Args = parseArgs(&Alloc, ArgsArr);
createFiles(Args);
-
- // Traditional linkers can generate re-linkable object files instead
- // of executables or DSOs. We don't support that since the feature
- // does not seem to provide more value than the static archiver.
- if (Args.hasArg(OPT_relocatable))
- error("-r option is not supported. Use 'ar' command instead.");
+ checkOptions(Args);
switch (Config->EKind) {
case ELF32LEKind:
@@ -250,12 +263,6 @@ void LinkerDriver::createFiles(opt::Inpu
if (Files.empty())
error("no input files.");
-
- if (Config->GnuHash && Config->EMachine == EM_MIPS)
- error("The .gnu.hash section is not compatible with the MIPS target.");
-
- if (!Config->Entry.empty() && Config->EMachine == EM_AMDGPU)
- error("-e option is not valid for AMDGPU.");
}
template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) {
More information about the llvm-commits
mailing list