From a29948873fe6026fef4d8b8acb067e0f1ffb1028 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 26 Jun 2015 00:42:21 +0000 Subject: [PATCH] COFF: Don't read non-x64 object files. Currently the new LLD supports only x86-64. llvm-svn: 240749 --- lld/COFF/InputFiles.cpp | 7 +++++++ lld/test/COFF/long-section-name.test | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp index c4b8226..f616d4c 100644 --- a/lld/COFF/InputFiles.cpp +++ b/lld/COFF/InputFiles.cpp @@ -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()) diff --git a/lld/test/COFF/long-section-name.test b/lld/test/COFF/long-section-name.test index 2c0a764..ebe5f08 100644 --- a/lld/test/COFF/long-section-name.test +++ b/lld/test/COFF/long-section-name.test @@ -4,7 +4,7 @@ --- header: - Machine: IMAGE_FILE_MACHINE_I386 + Machine: IMAGE_FILE_MACHINE_AMD64 Characteristics: [ ] sections: - Name: .text_long_section_name -- 2.7.4