[lld] r218105 - Driver: accept /machine:arm for Windows linker

Saleem Abdulrasool compnerd at compnerd.org
Thu Sep 18 23:09:30 PDT 2014


Author: compnerd
Date: Fri Sep 19 01:09:30 2014
New Revision: 218105

URL: http://llvm.org/viewvc/llvm-project?rev=218105&view=rev
Log:
Driver: accept /machine:arm for Windows linker

Accept /machine:arm as an argument.  This is changed to support ARM NT.
Although there is no way to differentiate between ARM (Windows CE) and ARM NT
(Windows on ARM), since LLVM currently only supports Windows on ARM, simply take
/machine:arm to mean Windows on ARM.

Modified:
    lld/trunk/lib/Driver/WinLinkDriver.cpp
    lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
    lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=218105&r1=218104&r2=218105&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Fri Sep 19 01:09:30 2014
@@ -188,8 +188,10 @@ static bool parseSubsystem(StringRef arg
 }
 
 static llvm::COFF::MachineTypes stringToMachineType(StringRef str) {
+  // FIXME: we have no way to differentiate between ARM and ARMNT currently.
+  // However, given that LLVM only supports ARM NT, default to that for now.
   return llvm::StringSwitch<llvm::COFF::MachineTypes>(str.lower())
-      .Case("arm", llvm::COFF::IMAGE_FILE_MACHINE_ARM)
+      .Case("arm", llvm::COFF::IMAGE_FILE_MACHINE_ARMNT)
       .Case("ebc", llvm::COFF::IMAGE_FILE_MACHINE_EBC)
       .Case("x64", llvm::COFF::IMAGE_FILE_MACHINE_AMD64)
       .Case("x86", llvm::COFF::IMAGE_FILE_MACHINE_I386)

Modified: lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp?rev=218105&r1=218104&r2=218105&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp Fri Sep 19 01:09:30 2014
@@ -74,10 +74,13 @@ bool PECOFFLinkingContext::validateImpl(
     return false;
   }
 
-  // Architectures other than x86/x64 is not supported yet.
-  if (_machineType != llvm::COFF::IMAGE_FILE_MACHINE_I386 &&
-      _machineType != llvm::COFF::IMAGE_FILE_MACHINE_AMD64) {
-    diagnostics << "Machine type other than x86/x64 is not supported.\n";
+  switch (_machineType) {
+  case llvm::COFF::IMAGE_FILE_MACHINE_I386:
+  case llvm::COFF::IMAGE_FILE_MACHINE_AMD64:
+  case llvm::COFF::IMAGE_FILE_MACHINE_ARMNT:
+    break;
+  default:
+    diagnostics << "Machine type other than arm/x86/x86_64 is not supported.\n";
     return false;
   }
 

Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=218105&r1=218104&r2=218105&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Fri Sep 19 01:09:30 2014
@@ -221,9 +221,8 @@ TEST_F(WinLinkParserTest, MachineX64) {
 }
 
 TEST_F(WinLinkParserTest, MachineArm) {
-  EXPECT_FALSE(parse("link.exe", "/machine:arm", "a.obj", nullptr));
-  EXPECT_TRUE(StringRef(errorMessage()).startswith(
-      "Machine type other than x86/x64 is not supported"));
+  EXPECT_TRUE(parse("link.exe", "/machine:arm", "a.obj", nullptr));
+  EXPECT_EQ(llvm::COFF::IMAGE_FILE_MACHINE_ARMNT, _context.getMachineType());
 }
 
 TEST_F(WinLinkParserTest, MajorImageVersion) {





More information about the llvm-commits mailing list