COFF: Don't read non-x64 object files.

Currently the new LLD supports only x86-64.

llvm-svn: 240749
This commit is contained in:
Rui Ueyama 2015-06-26 00:42:21 +00:00
parent 8caacfabfc
commit a29948873f
2 changed files with 8 additions and 1 deletions

View File

@ -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())

View File

@ -4,7 +4,7 @@
---
header:
Machine: IMAGE_FILE_MACHINE_I386
Machine: IMAGE_FILE_MACHINE_AMD64
Characteristics: [ ]
sections:
- Name: .text_long_section_name