[lld] r240749 - COFF: Don't read non-x64 object files.

Rui Ueyama ruiu at google.com
Thu Jun 25 17:42:22 PDT 2015


Author: ruiu
Date: Thu Jun 25 19:42:21 2015
New Revision: 240749

URL: http://llvm.org/viewvc/llvm-project?rev=240749&view=rev
Log:
COFF: Don't read non-x64 object files.

Currently the new LLD supports only x86-64.

Modified:
    lld/trunk/COFF/InputFiles.cpp
    lld/trunk/test/COFF/long-section-name.test

Modified: lld/trunk/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=240749&r1=240748&r2=240749&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.cpp (original)
+++ lld/trunk/COFF/InputFiles.cpp Thu Jun 25 19:42:21 2015
@@ -23,6 +23,8 @@ using namespace llvm::object;
 using namespace llvm::support::endian;
 using llvm::COFF::ImportHeader;
 using llvm::COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE;
+using llvm::COFF::IMAGE_FILE_MACHINE_AMD64;
+using llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN;
 using llvm::RoundUpToAlignment;
 using llvm::sys::fs::identify_magic;
 using llvm::sys::fs::file_magic;
@@ -98,6 +100,11 @@ std::error_code ObjectFile::parse() {
     llvm::errs() << getName() << " is not a COFF file.\n";
     return make_error_code(LLDError::InvalidFile);
   }
+  if (COFFObj->getMachine() != IMAGE_FILE_MACHINE_AMD64 &&
+      COFFObj->getMachine() != IMAGE_FILE_MACHINE_UNKNOWN) {
+    llvm::errs() << getName() << " is not an x64 object file.\n";
+    return make_error_code(LLDError::InvalidFile);
+  }
 
   // Read section and symbol tables.
   if (auto EC = initializeChunks())

Modified: lld/trunk/test/COFF/long-section-name.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/long-section-name.test?rev=240749&r1=240748&r2=240749&view=diff
==============================================================================
--- lld/trunk/test/COFF/long-section-name.test (original)
+++ lld/trunk/test/COFF/long-section-name.test Thu Jun 25 19:42:21 2015
@@ -4,7 +4,7 @@
 
 ---
 header:
-  Machine:         IMAGE_FILE_MACHINE_I386
+  Machine:         IMAGE_FILE_MACHINE_AMD64
   Characteristics: [  ]
 sections:
   - Name:            .text_long_section_name





More information about the llvm-commits mailing list