[lld] r217214 - [PECOFF] Run cvtres.exe with /machine:x64.

Rui Ueyama ruiu at google.com
Thu Sep 4 17:26:28 PDT 2014


Author: ruiu
Date: Thu Sep  4 19:26:28 2014
New Revision: 217214

URL: http://llvm.org/viewvc/llvm-project?rev=217214&view=rev
Log:
[PECOFF] Run cvtres.exe with /machine:x64.

If we are creating a PE+ executable, we need to run cvtres with
/machine:x64 instead of /machine:x86. Otherwise the resulting executable
would be invalid.

Modified:
    lld/trunk/lib/Driver/WinLinkDriver.cpp

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=217214&r1=217213&r2=217214&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Thu Sep  4 19:26:28 2014
@@ -295,7 +295,8 @@ static bool isResoruceFile(StringRef pat
 
 // Merge Windows resource files and convert them to a single COFF file.
 // The temporary file path is set to result.
-static bool convertResourceFiles(std::vector<std::string> inFiles,
+static bool convertResourceFiles(PECOFFLinkingContext &ctx,
+                                 std::vector<std::string> inFiles,
                                  std::string &result) {
   // Create an output file path.
   SmallString<128> outFile;
@@ -313,7 +314,7 @@ static bool convertResourceFiles(std::ve
 
   std::vector<const char *> args;
   args.push_back(programPath.c_str());
-  args.push_back("/machine:x86");
+  args.push_back(ctx.is64Bit() ? "/machine:x64" : "/machine:x86");
   args.push_back("/readonly");
   args.push_back("/nologo");
   args.push_back(outFileArg.c_str());
@@ -1263,7 +1264,7 @@ bool WinLinkDriver::parse(int argc, cons
     if (it != inputFiles.begin()) {
       std::vector<std::string> resFiles(inputFiles.begin(), it);
       std::string resObj;
-      if (!convertResourceFiles(resFiles, resObj)) {
+      if (!convertResourceFiles(ctx, resFiles, resObj)) {
         diag << "Failed to convert resource files\n";
         return false;
       }





More information about the llvm-commits mailing list