[lld] r363016 - llvm-lib: Implement /machine: argument
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 10 18:13:41 PDT 2019
Author: nico
Date: Mon Jun 10 18:13:41 2019
New Revision: 363016
URL: http://llvm.org/viewvc/llvm-project?rev=363016&view=rev
Log:
llvm-lib: Implement /machine: argument
And share some code with lld-link.
While here, also add a FIXME about PR42180 and merge r360150 to llvm-lib.
Differential Revision: https://reviews.llvm.org/D63021
Modified:
lld/trunk/COFF/Driver.cpp
lld/trunk/COFF/Driver.h
lld/trunk/COFF/DriverUtils.cpp
lld/trunk/COFF/SymbolTable.cpp
Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=363016&r1=363015&r2=363016&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Mon Jun 10 18:13:41 2019
@@ -1205,8 +1205,11 @@ void LinkerDriver::link(ArrayRef<const c
Args.hasFlag(OPT_appcontainer, OPT_appcontainer_no, false);
// Handle /machine
- if (auto *Arg = Args.getLastArg(OPT_machine))
+ if (auto *Arg = Args.getLastArg(OPT_machine)) {
Config->Machine = getMachineType(Arg->getValue());
+ if (Config->Machine == IMAGE_FILE_MACHINE_UNKNOWN)
+ fatal(Twine("unknown /machine argument: ") + Arg->getValue());
+ }
// Handle /nodefaultlib:<filename>
for (auto *Arg : Args.filtered(OPT_nodefaultlib))
Modified: lld/trunk/COFF/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.h?rev=363016&r1=363015&r2=363016&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.h (original)
+++ lld/trunk/COFF/Driver.h Mon Jun 10 18:13:41 2019
@@ -138,10 +138,6 @@ private:
void printHelp(const char *Argv0);
-// For /machine option.
-MachineTypes getMachineType(StringRef Arg);
-StringRef machineToStr(MachineTypes MT);
-
// Parses a string in the form of "<integer>[,<integer>]".
void parseNumbers(StringRef Arg, uint64_t *Addr, uint64_t *Size = nullptr);
Modified: lld/trunk/COFF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DriverUtils.cpp?rev=363016&r1=363015&r2=363016&view=diff
==============================================================================
--- lld/trunk/COFF/DriverUtils.cpp (original)
+++ lld/trunk/COFF/DriverUtils.cpp Mon Jun 10 18:13:41 2019
@@ -72,34 +72,6 @@ private:
} // anonymous namespace
-// Returns /machine's value.
-MachineTypes getMachineType(StringRef S) {
- MachineTypes MT = StringSwitch<MachineTypes>(S.lower())
- .Cases("x64", "amd64", AMD64)
- .Cases("x86", "i386", I386)
- .Case("arm", ARMNT)
- .Case("arm64", ARM64)
- .Default(IMAGE_FILE_MACHINE_UNKNOWN);
- if (MT != IMAGE_FILE_MACHINE_UNKNOWN)
- return MT;
- fatal("unknown /machine argument: " + S);
-}
-
-StringRef machineToStr(MachineTypes MT) {
- switch (MT) {
- case ARMNT:
- return "arm";
- case ARM64:
- return "arm64";
- case AMD64:
- return "x64";
- case I386:
- return "x86";
- default:
- llvm_unreachable("unknown machine type");
- }
-}
-
// Parses a string in the form of "<integer>[,<integer>]".
void parseNumbers(StringRef Arg, uint64_t *Addr, uint64_t *Size) {
StringRef S1, S2;
Modified: lld/trunk/COFF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/SymbolTable.cpp?rev=363016&r1=363015&r2=363016&view=diff
==============================================================================
--- lld/trunk/COFF/SymbolTable.cpp (original)
+++ lld/trunk/COFF/SymbolTable.cpp Mon Jun 10 18:13:41 2019
@@ -18,6 +18,7 @@
#include "llvm/IR/LLVMContext.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/ToolDrivers/llvm-lib/LibDriver.h"
#include <utility>
using namespace llvm;
More information about the llvm-commits
mailing list