[PECOFF] Add a field for machine type to PECOFFLinkingContext.

So that we can determine what the target architecture is. Adding this
field does not mean that we are going to support non-i386 architectures
soon; there are many things to do to support them, and I'm focusing on
i386 now. But this is the first step toward multi architecture support.

llvm-svn: 190627
diff --git a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
index 48ee6cb..542e1e9 100644
--- a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
+++ b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
@@ -55,6 +55,12 @@
     return true;
   }
 
+  // Architectures other than i386 is not supported yet.
+  if (_machineType != llvm::COFF::IMAGE_FILE_MACHINE_I386) {
+    diagnostics << "Machine type other than x86 is not supported.\n";
+    return true;
+  }
+
   _reader = createReaderPECOFF(*this);
   _writer = createWriterPECOFF(*this);
   return false;
diff --git a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
index 50021af..0428cc1 100644
--- a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
+++ b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
@@ -145,7 +145,7 @@
     std::memset(&_coffHeader, 0, sizeof(_coffHeader));
     std::memset(&_peHeader, 0, sizeof(_peHeader));
 
-    _coffHeader.Machine = llvm::COFF::IMAGE_FILE_MACHINE_I386;
+    _coffHeader.Machine = context.getMachineType();
     _coffHeader.TimeDateStamp = time(NULL);
 
     // The size of PE header including optional data directory is always 224.